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

Last change on this file since 2495 was 2495, checked in by Jean-Yves Lamoureux, 13 years ago
  • Removed general local variables from main() and put it in struct screen_list
  • Moved most of the input handling to input.c
  • Moved lock feature to lock.c
  • Property svn:keywords set to Id
File size: 6.7 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 2495 2008-06-28 11:22:26Z 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
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    int lock_offset;
83    char lockpass[1024];
84    char lockmsg[1024];
85
86    /* Add-ons*/
87    int mini;                    /* Thumbnails */
88    int status;                  /* Status bar */
89    int help;                    /* help */
90
91    /* ScreenSaver stuff */
92    long long unsigned int screensaver_timeout;     /* Screensaver timeout in us */
93    int in_screensaver;
94    void *screensaver_data;
95
96    int pty, prevpty;            /* Current and previous window */
97    int count;                   /* Window count */
98    int width, height;           /* caca window size */
99    struct screen **screen;      /* Windows */
100
101    struct option *config;
102    char *default_shell;
103    struct recurrent_list *recurrent_list;
104
105    cucul_canvas_t *cv;
106    caca_display_t *dp;
107};
108
109
110struct recurrent
111{
112    int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
113    void *user;
114    long long unsigned int  start_time;
115    int kill_me;
116};
117
118struct recurrent_list
119{
120    int count;
121    struct recurrent **recurrent;
122};
123
124
125
126void version(void);
127void usage(int argc, char **argv);
128
129
130struct screen_list *create_screen_list(void);
131
132int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid);
133int create_pty_grab(pid_t pid, unsigned int w, unsigned int h);
134int grab_process(pid_t pid, char *ptyname, int ptyfd);
135
136long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size);
137int set_tty_size(int fd, unsigned int w, unsigned int h);
138int update_terms(struct screen_list* screen_list);
139void refresh_screens(struct screen_list *screen_list);
140int update_screens_contents(struct screen_list* screen_list);
141long long get_us(void);
142
143int detach(struct screen_list* screen_list, caca_display_t * dp);
144int request_attach(char *socket_path);
145int create_socket(struct screen_list* screen_list);
146int read_socket(struct screen_list* screen_list, cucul_canvas_t * cv, caca_display_t ** dp);
147char ** list_sockets(char *socket_dir, char *session_name);
148
149/* Screens management */
150struct screen* create_screen(int w, int h, char *command);
151struct screen* create_screen_grab(int w, int h, int pid);
152int destroy_screen(struct screen *s);
153int add_screen(struct screen_list *list, struct screen *s);
154int remove_screen(struct screen_list *list, int n, int please_kill);
155void resize_screen(struct screen *s, int z, int h);
156
157/* Window managers */
158void update_windows_props(struct screen_list *screen_list);
159void update_windows_props_cards(struct screen_list *screen_list);
160void update_windows_props_hsplit(struct screen_list *screen_list);
161void update_windows_props_full(struct screen_list *screen_list);
162void update_windows_props_vsplit(struct screen_list *screen_list);
163
164/* Effects and addons */
165void draw_thumbnails(struct screen_list *screen_list);
166void draw_status(struct screen_list *screen_list);
167void draw_help(struct screen_list *screen_list);
168void draw_lock(struct screen_list *screen_list);
169int update_lock(int c, struct screen_list *screen_list);
170int validate_lock(struct screen_list *screen_list, char *user, char *pass);
171
172int close_screen_recurrent(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t);
173
174/* Input to ANSI */
175void *convert_input_ansi(unsigned int *c, int *size);
176int  handle_command_input(struct screen_list*screen_list, unsigned int c);
177
178
179/* Screensavers */
180void screensaver_init(struct screen_list *screen_list);
181void screensaver_kill(struct screen_list *screen_list);
182
183void draw_screensaver(struct screen_list *screen_list);
184void screensaver_flying_toasters(struct screen_list *screen_list);
185
186void screensaver_flying_toasters_init(struct screen_list *screen_list);
187
188void screensaver_flying_toasters_kill(struct screen_list *screen_list);
189
190
191
192/* Recurrents */
193int handle_recurrents(struct screen_list* screen_list);
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.