source: neercs/trunk/src/neercs.h @ 2455

Last change on this file since 2455 was 2455, checked in by Sam Hocevar, 14 years ago
  • Do not build grab.c conditionally; instead, make grab_process() and create_pty_grab() return an error if the feature isn't available.
  • Property svn:keywords set to Id
File size: 5.8 KB
Line 
1/*
2 *  neercs        console-based window manager
3 *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
4 *                2008 Jean-Yves Lamoureux <jylam@lnxscene.org>
5 *                All Rights Reserved
6 *
7 *  $Id: neercs.h 2455 2008-06-18 23:36:52Z sam $
8 *
9 *  This program is free software. It comes without any warranty, to
10 *  the extent permitted by applicable law. You can redistribute it
11 *  and/or modify it under the terms of the Do What The Fuck You Want
12 *  To Public License, Version 2, as published by Sam Hocevar. See
13 *  http://sam.zoy.org/wtfpl/COPYING for more details.
14 */
15
16#include <stdint.h>
17#include <caca.h>
18
19enum wm_types
20{
21    WM_FULL,
22    WM_CARD,
23    WM_HSPLIT,
24    WM_VSPLIT,
25
26    WM_MAX,
27};
28
29
30struct screen
31{
32    /* Graphics stuff */
33    int init;
34    cucul_canvas_t *cv;
35    uint32_t clearattr;
36    uint8_t fg, bg;   /* ANSI-context fg/bg */
37    uint8_t dfg, dbg; /* Default fg/bg */
38    uint8_t bold, blink, italics, negative, concealed, underline;
39    uint8_t faint, strike, proportional; /* unsupported */
40
41    /* Other stuff */
42    int visible;                 /* Draw canvas and border flag */
43    int fd;                      /* pty fd */
44    unsigned char *buf;          /* text buffer */
45    long int total;              /* buffer length */
46    char *title;                 /* tty title */
47    int bell;                    /* bell occuring */
48    unsigned int scroll, s1, s2; /* FIXME, ANSI scroll properties */
49    int pid;                     /* running program pid */
50
51    int x, y;                    /* Canvas position */
52    int w, h;                    /* Canvas size */
53
54    int orig_x, orig_y;          /* Used by recurrents */
55    int orig_w, orig_h;          /* Used by recurrents */
56
57};
58
59struct screen_list
60{
61    int wm_type;                 /* Window manager type */
62    int in_bell;                 /* Bell occuring in a window  */
63    int dont_update_coords;      /* Used by recurrents */
64    /* Add-ons*/
65    int mini;                    /* Thumbnails */
66    int status;                  /* Status bar */
67    int help;                    /* help */
68
69    /* ScreenSaver stuff */
70    long long unsigned int screensaver_timeout;     /* Screensaver timeout in us */
71    int in_screensaver;
72    void *screensaver_data;
73
74    int pty, prevpty;            /* Current and previous window */
75    int count;                   /* Window count */
76    int width, height;           /* caca window size */
77    struct screen **screen;      /* Windows */
78};
79
80
81struct recurrent
82{
83    int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
84    void *user;
85    long long unsigned int  start_time;
86    int kill_me;
87};
88
89struct recurrent_list
90{
91    int count;
92    struct recurrent **recurrent;
93};
94
95
96void version(void);
97
98
99
100int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
101int create_pty_grab(pid_t pid, unsigned int w, unsigned int h);
102int grab_process(pid_t pid, char *ptyname, int ptyfd);
103
104long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size);
105int set_tty_size(int fd, unsigned int w, unsigned int h);
106int update_terms(struct screen_list* screen_list);
107void refresh_screens(cucul_canvas_t *cv,
108                     caca_display_t *dp,
109                     struct screen_list *screen_list);
110int update_screens_contents(struct screen_list* screen_list);
111long long get_ms(void);
112
113
114/* Screens management */
115struct screen* create_screen(int w, int h, char *command);
116struct screen* create_screen_grab(int w, int h, int pid);
117int destroy_screen(struct screen *s);
118int add_screen(struct screen_list *list, struct screen *s);
119int remove_screen(struct screen_list *list, int n, int please_kill);
120void resize_screen(struct screen *s, int z, int h);
121
122/* Window managers */
123void update_windows_props(cucul_canvas_t *cv, struct screen_list *screen_list);
124void update_windows_props_cards(cucul_canvas_t *cv, struct screen_list *screen_list);
125void update_windows_props_hsplit(cucul_canvas_t *cv, struct screen_list *screen_list);
126void update_windows_props_full(cucul_canvas_t *cv, struct screen_list *screen_list);
127void update_windows_props_vsplit(cucul_canvas_t *cv, struct screen_list *screen_list);
128
129/* Effects and addons */
130void draw_thumbnails(cucul_canvas_t *cv, struct screen_list *screen_list);
131void draw_status(cucul_canvas_t *cv, struct screen_list *screen_list);
132void draw_help(cucul_canvas_t *cv, struct screen_list *screen_list);
133int close_screen_recurrent(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
134
135
136/* Screensavers */
137void screensaver_init(cucul_canvas_t *cv,
138                      caca_display_t *dp,
139                      struct screen_list *screen_list);
140void screensaver_kill(cucul_canvas_t *cv,
141                      caca_display_t *dp,
142                      struct screen_list *screen_list);
143
144void draw_screensaver(cucul_canvas_t *cv,
145                      caca_display_t *dp,
146                      struct screen_list *screen_list);
147void screensaver_flying_toasters(cucul_canvas_t *cv,
148                                 caca_display_t *dp,
149                                 struct screen_list *screen_list);
150
151void screensaver_flying_toasters_init(cucul_canvas_t *cv,
152                                 caca_display_t *dp,
153                                 struct screen_list *screen_list);
154
155void screensaver_flying_toasters_kill(cucul_canvas_t *cv,
156                                 caca_display_t *dp,
157                                 struct screen_list *screen_list);
158
159
160
161/* Recurrents */
162int add_recurrent(struct recurrent_list *list,
163                  int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t),
164                  void *user);
165int remove_recurrent(struct recurrent_list *list, int n);
166
167
168#if 0
169#   define debug(f, z...) fprintf(stderr, f "\n", z)
170#else
171#   define debug(f, z...) do {} while(0)
172#endif
173
Note: See TracBrowser for help on using the repository browser.