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

Last change on this file since 2473 was 2473, checked in by Jean-Yves Lamoureux, 14 years ago
  • get_ms() returns ... microseconds. Renamed to get_us(). (fsck you)
  • Also made caca refresh function-independant
  • Property svn:keywords set to Id
File size: 6.5 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 2473 2008-06-20 15:43:58Z jylam $
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 option
31{
32    char *key;
33    char *value;
34
35    struct option *next;
36};
37
38
39struct screen
40{
41    /* Graphics stuff */
42    int init;
43    cucul_canvas_t *cv;
44    uint32_t clearattr;
45    uint8_t fg, bg;   /* ANSI-context fg/bg */
46    uint8_t dfg, dbg; /* Default fg/bg */
47    uint8_t bold, blink, italics, negative, concealed, underline;
48    uint8_t faint, strike, proportional; /* unsupported */
49
50    /* Other stuff */
51    int visible;                 /* Draw canvas and border flag */
52    int fd;                      /* pty fd */
53    unsigned char *buf;          /* text buffer */
54    long int total;              /* buffer length */
55    char *title;                 /* tty title */
56    int bell;                    /* bell occuring */
57    unsigned int scroll, s1, s2; /* FIXME, ANSI scroll properties */
58    int pid;                     /* running program pid */
59
60    int x, y;                    /* Canvas position */
61    int w, h;                    /* Canvas size */
62
63    int orig_x, orig_y;          /* Used by recurrents */
64    int orig_w, orig_h;          /* Used by recurrents */
65
66};
67
68struct screen_list
69{
70    int wm_type;                 /* Window manager type */
71    int in_bell;                 /* Bell occuring in a window  */
72    int dont_update_coords;      /* Used by recurrents */
73    int attached;                /* Are we attached to a terminal */
74
75    /* Lock */
76    int locked;
77    char lockpass[1024];
78    char lockmsg[1024];
79
80    /* Add-ons*/
81    int mini;                    /* Thumbnails */
82    int status;                  /* Status bar */
83    int help;                    /* help */
84
85    /* ScreenSaver stuff */
86    long long unsigned int screensaver_timeout;     /* Screensaver timeout in us */
87    int in_screensaver;
88    void *screensaver_data;
89
90    int pty, prevpty;            /* Current and previous window */
91    int count;                   /* Window count */
92    int width, height;           /* caca window size */
93    struct screen **screen;      /* Windows */
94
95    struct option *config;
96
97};
98
99
100struct recurrent
101{
102    int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
103    void *user;
104    long long unsigned int  start_time;
105    int kill_me;
106};
107
108struct recurrent_list
109{
110    int count;
111    struct recurrent **recurrent;
112};
113
114
115
116void version(void);
117void usage(int argc, char **argv);
118
119
120
121int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
122int create_pty_grab(pid_t pid, unsigned int w, unsigned int h);
123int grab_process(pid_t pid, char *ptyname, int ptyfd);
124
125long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size);
126int set_tty_size(int fd, unsigned int w, unsigned int h);
127int update_terms(struct screen_list* screen_list);
128void refresh_screens(cucul_canvas_t *cv,
129                     caca_display_t *dp,
130                     struct screen_list *screen_list);
131int update_screens_contents(struct screen_list* screen_list);
132long long get_us(void);
133
134int detach(struct screen_list* screen_list, caca_display_t * dp);
135
136/* Screens management */
137struct screen* create_screen(int w, int h, char *command);
138struct screen* create_screen_grab(int w, int h, int pid);
139int destroy_screen(struct screen *s);
140int add_screen(struct screen_list *list, struct screen *s);
141int remove_screen(struct screen_list *list, int n, int please_kill);
142void resize_screen(struct screen *s, int z, int h);
143
144/* Window managers */
145void update_windows_props(cucul_canvas_t *cv, struct screen_list *screen_list);
146void update_windows_props_cards(cucul_canvas_t *cv, struct screen_list *screen_list);
147void update_windows_props_hsplit(cucul_canvas_t *cv, struct screen_list *screen_list);
148void update_windows_props_full(cucul_canvas_t *cv, struct screen_list *screen_list);
149void update_windows_props_vsplit(cucul_canvas_t *cv, struct screen_list *screen_list);
150
151/* Effects and addons */
152void draw_thumbnails(cucul_canvas_t *cv, struct screen_list *screen_list);
153void draw_status(cucul_canvas_t *cv, struct screen_list *screen_list);
154void draw_help(cucul_canvas_t *cv, struct screen_list *screen_list);
155void draw_lock(cucul_canvas_t *cv, struct screen_list *screen_list);
156int validate_lock(struct screen_list *screen_list, char *user, char *pass);
157
158int close_screen_recurrent(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
159
160
161/* Screensavers */
162void screensaver_init(cucul_canvas_t *cv,
163                      caca_display_t *dp,
164                      struct screen_list *screen_list);
165void screensaver_kill(cucul_canvas_t *cv,
166                      caca_display_t *dp,
167                      struct screen_list *screen_list);
168
169void draw_screensaver(cucul_canvas_t *cv,
170                      caca_display_t *dp,
171                      struct screen_list *screen_list);
172void screensaver_flying_toasters(cucul_canvas_t *cv,
173                                 caca_display_t *dp,
174                                 struct screen_list *screen_list);
175
176void screensaver_flying_toasters_init(cucul_canvas_t *cv,
177                                 caca_display_t *dp,
178                                 struct screen_list *screen_list);
179
180void screensaver_flying_toasters_kill(cucul_canvas_t *cv,
181                                 caca_display_t *dp,
182                                 struct screen_list *screen_list);
183
184
185
186/* Recurrents */
187int add_recurrent(struct recurrent_list *list,
188                  int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t),
189                  void *user);
190int remove_recurrent(struct recurrent_list *list, int n);
191
192
193
194/* Configuration file */
195int read_configuration_file(char *filename, struct screen_list *screen_list);
196int parse_conf_line(char *buf, int size, struct screen_list *screen_list);
197int get_key_value(char *line, struct option *option);
198int fill_config(struct screen_list *screen_list);
199
200#if 0
201#   define debug(f, z...) fprintf(stderr, f "\n", z)
202#else
203#   define debug(f, z...) do {} while(0)
204#endif
205
Note: See TracBrowser for help on using the repository browser.