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

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