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

Last change on this file since 2510 was 2510, checked in by Sam Hocevar, 13 years ago
  • Add a --debug flag to the configure step.
  • 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 2510 2008-06-30 23:26:57Z 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
18#include <caca.h>
19
20enum wm_types
21{
22    WM_FULL,
23    WM_CARD,
24    WM_HSPLIT,
25    WM_VSPLIT,
26
27    WM_MAX,
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
74    /* Detaching */
75    int attached;                /* Are we attached to a terminal */
76    int socket;                  /* Socket to ask for attaching */
77    char *socket_path;           /* Socket to ask for attaching */
78    char *socket_dir;            /* Where to create the socket */
79    char *session_name;          /* Name of the session */
80
81    /* Lock */
82    int locked;
83    int lock_offset;
84    long long unsigned int  autolock_timeout;
85    char lockpass[1024];
86    char lockmsg[1024];
87
88    /* Add-ons*/
89    int mini;                    /* Thumbnails */
90    int status;                  /* Status bar */
91    int help;                    /* help */
92
93    /* ScreenSaver stuff */
94    long long unsigned int screensaver_timeout;     /* Screensaver timeout in us */
95    int in_screensaver;
96    void *screensaver_data;
97
98    int pty, prevpty;            /* Current and previous window */
99    int count;                   /* Window count */
100    int width, height;           /* caca window size */
101    struct screen **screen;      /* Windows */
102
103    struct option *config;
104    char *default_shell;
105    struct recurrent_list *recurrent_list;
106
107    cucul_canvas_t *cv;
108    caca_display_t *dp;
109};
110
111
112struct recurrent
113{
114    int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
115    void *user;
116    long long unsigned int  start_time;
117    int kill_me;
118};
119
120struct recurrent_list
121{
122    int count;
123    struct recurrent **recurrent;
124};
125
126
127
128void version(void);
129void usage(int argc, char **argv);
130
131
132struct screen_list *create_screen_list(void);
133
134int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
135int create_pty_grab(long pid, unsigned int w, unsigned int h);
136int grab_process(long pid, char *ptyname, int ptyfd);
137
138long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size);
139int set_tty_size(int fd, unsigned int w, unsigned int h);
140int update_terms(struct screen_list* screen_list);
141void refresh_screens(struct screen_list *screen_list);
142int update_screens_contents(struct screen_list* screen_list);
143long long get_us(void);
144
145int detach(struct screen_list* screen_list, caca_display_t * dp);
146int request_attach(char *socket_path);
147int create_socket(struct screen_list* screen_list);
148int read_socket(struct screen_list* screen_list, cucul_canvas_t * cv, caca_display_t ** dp);
149char ** list_sockets(char *socket_dir, char *session_name);
150
151/* Screens management */
152struct screen* create_screen(int w, int h, char *command);
153struct screen* create_screen_grab(int w, int h, int pid);
154int destroy_screen(struct screen *s);
155int add_screen(struct screen_list *list, struct screen *s);
156int remove_screen(struct screen_list *list, int n, int please_kill);
157void resize_screen(struct screen *s, int z, int h);
158
159/* Window managers */
160void update_windows_props(struct screen_list *screen_list);
161void update_windows_props_cards(struct screen_list *screen_list);
162void update_windows_props_hsplit(struct screen_list *screen_list);
163void update_windows_props_full(struct screen_list *screen_list);
164void update_windows_props_vsplit(struct screen_list *screen_list);
165
166/* Effects and addons */
167void draw_thumbnails(struct screen_list *screen_list);
168void draw_status(struct screen_list *screen_list);
169void draw_help(struct screen_list *screen_list);
170void draw_lock(struct screen_list *screen_list);
171int update_lock(int c, struct screen_list *screen_list);
172int validate_lock(struct screen_list *screen_list, char *user, char *pass);
173
174int close_screen_recurrent(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
175
176/* Input to ANSI */
177void *convert_input_ansi(unsigned int *c, int *size);
178int  handle_command_input(struct screen_list*screen_list, unsigned int c);
179
180
181/* Screensavers */
182void screensaver_init(struct screen_list *screen_list);
183void screensaver_kill(struct screen_list *screen_list);
184
185void draw_screensaver(struct screen_list *screen_list);
186void screensaver_flying_toasters(struct screen_list *screen_list);
187
188void screensaver_flying_toasters_init(struct screen_list *screen_list);
189
190void screensaver_flying_toasters_kill(struct screen_list *screen_list);
191
192
193
194/* Recurrents */
195int handle_recurrents(struct screen_list* screen_list);
196int add_recurrent(struct recurrent_list *list,
197                  int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t),
198                  void *user);
199int remove_recurrent(struct recurrent_list *list, int n);
200
201
202
203/* Configuration file */
204int read_configuration_file(char *filename, struct screen_list *screen_list);
205int parse_conf_line(char *buf, int size, struct screen_list *screen_list);
206int get_key_value(char *line, struct option *option);
207int fill_config(struct screen_list *screen_list);
208
209#if defined DEBUG
210#   include <stdio.h>
211#   include <stdarg.h>
212static inline void debug(const char *format, ...)
213{
214    int saved_errno = geterrno();
215    va_list args;
216    va_start(args, format);
217    fprintf(stderr, "** neercs debug ** ");
218    vfprintf(stderr, format, args);
219    fprintf(stderr, "\n");
220    va_end(args);
221    seterrno(saved_errno);
222}
223#else
224#   define debug(format, ...) do {} while(0)
225#endif
226
Note: See TracBrowser for help on using the repository browser.