source: owl.h @ f73e519

barnowl_perlaimdebianowlrelease-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since f73e519 was 10b866d, checked in by Erik Nygren <nygren@mit.edu>, 19 years ago
* Fixed preservation of e->dotsend across owl_editwin_clear(). * Added history for multiline edit windows (eg, for zephyr composition). The M-n and M-p keys will cycle through the history ring. In particular, it is now possible to edit the command line of a zephyr being composed: C-c it and restart it and then M-p to get the aborted composition back.
  • Property mode set to 100644
File size: 10.0 KB
Line 
1#ifndef INC_OWL_H
2#define INC_OWL_H
3
4#include <zephyr/zephyr.h>
5#include <curses.h>
6#include <sys/param.h>
7#include <EXTERN.h>
8#include <netdb.h>
9#include <regex.h>
10#include "config.h"
11
12static const char owl_h_fileIdent[] = "$Id$";
13
14#define OWL_VERSION         1.2.1-pre-1
15#define OWL_VERSION_STRING "1.2.1-pre-1"
16
17#define OWL_DEBUG 0
18#define OWL_DEBUG_FILE "/var/tmp/owldebug"
19
20#define OWL_FMTEXT_ATTR_NONE      0
21#define OWL_FMTEXT_ATTR_BOLD      1
22#define OWL_FMTEXT_ATTR_REVERSE   2
23#define OWL_FMTEXT_ATTR_UNDERLINE 4
24
25#define OWL_COLOR_BLACK     0
26#define OWL_COLOR_RED       1
27#define OWL_COLOR_GREEN     2
28#define OWL_COLOR_YELLOW    3
29#define OWL_COLOR_BLUE      4
30#define OWL_COLOR_MAGENTA   5
31#define OWL_COLOR_CYAN      6
32#define OWL_COLOR_WHITE     7
33#define OWL_COLOR_DEFAULT   8
34
35#define OWL_EDITWIN_STYLE_MULTILINE 0
36#define OWL_EDITWIN_STYLE_ONELINE   1
37
38#define OWL_MESSAGE_TYPE_ADMIN  0
39#define OWL_MESSAGE_TYPE_ZEPHYR 1
40
41#define OWL_MESSAGE_ADMINTYPE_GENERIC  0
42#define OWL_MESSAGE_ADMINTYPE_OUTGOING 1
43#define OWL_MESSAGE_ADMINTYPE_NOTADMIN 2
44
45#define OWL_DIRECTION_NONE      0
46#define OWL_DIRECTION_DOWNWARDS 1
47#define OWL_DIRECTION_UPWARDS   2
48
49#define OWL_TAB               3  /* This *HAS* to be the size of TABSTR below */
50#define OWL_TABSTR        "   "
51#define OWL_MSGTAB            7
52#define OWL_TYPWIN_SIZE       8
53#define OWL_HISTORYSIZE       50
54
55/* Indicate current state, as well as what is allowed */
56#define OWL_CTX_ANY          0xffff
57/* Only one of these may be active at a time... */
58#define OWL_CTX_MODE_BITS    0x000f
59#define OWL_CTX_STARTUP      0x0001
60#define OWL_CTX_READCONFIG   0x0002
61#define OWL_CTX_INTERACTIVE  0x0004
62/* Only one of these may be active at a time... */
63#define OWL_CTX_ACTIVE_BITS  0xfff0
64#define OWL_CTX_POPWIN       0x00f0
65#define OWL_CTX_POPLESS      0x0010
66#define OWL_CTX_RECWIN       0x0f00
67#define OWL_CTX_RECV         0x0100
68#define OWL_CTX_TYPWIN       0xf000
69#define OWL_CTX_EDIT         0x3000
70#define OWL_CTX_EDITLINE     0x1000
71#define OWL_CTX_EDITMULTI    0x2000
72
73#define OWL_USERCLUE_NONE       0
74#define OWL_USERCLUE_CLASSES    1
75#define OWL_USERCLUE_FOOBAR     2
76#define OWL_USERCLUE_BAZ        4
77
78#define OWL_WEBBROWSER_NONE     0
79#define OWL_WEBBROWSER_NETSCAPE 1
80#define OWL_WEBBROWSER_GALEON   2
81
82#define OWL_VARIABLE_OTHER      0
83#define OWL_VARIABLE_INT        1
84#define OWL_VARIABLE_BOOL       2
85#define OWL_VARIABLE_STRING     3
86
87#define OWL_FILTER_MAX_DEPTH    300
88
89#define OWL_KEYMAP_MAXSTACK 20
90
91#define OWL_KEYBINDING_COMMAND   1 /* command string */
92#define OWL_KEYBINDING_FUNCTION  2 /* function taking no args */
93
94#define OWL_DEFAULT_ZAWAYMSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
95
96#define OWL_INCLUDE_REG_TESTS  1  /* whether to build in regression tests */
97
98#define OWL_CMD_ALIAS_SUMMARY_PREFIX "command alias to: "
99
100#ifndef CTRL
101#define CTRL(key) ((key)&037)
102#endif
103#ifndef META
104#define META(key) ((key)|0200)
105#endif
106
107#define LINE 2048
108
109typedef struct _owl_variable {
110  char *name;
111  int   type;  /* OWL_VARIABLE_* */
112  void *pval_default;  /* for types other and string */
113  int   ival_default;  /* for types int and bool     */
114  char *validsettings;          /* documentation of valid settings */
115  char *docstring;              /* documentation of valid settings */
116  void *val;                    /* current value */
117  int  (*validate_fn)(struct _owl_variable *v, void *newval);
118                                /* returns 1 if newval is valid */
119  int  (*set_fn)(struct _owl_variable *v, void *newval); 
120                                /* sets the variable to a value
121                                 * of the appropriate type.
122                                 * unless documented, this
123                                 * should make a copy.
124                                 * returns 0 on success. */
125  int  (*set_fromstring_fn)(struct _owl_variable *v, char *newval);
126                                /* sets the variable to a value
127                                 * of the appropriate type.
128                                 * unless documented, this
129                                 * should make a copy.
130                                 * returns 0 on success. */
131  void *(*get_fn)(struct _owl_variable *v);
132                                /* returns a reference to the current value.
133                                 * WARNING:  this approach is hard to make
134                                 * thread-safe... */
135  int  (*get_tostring_fn)(struct _owl_variable *v, 
136                          char *buf, int bufsize, void *val); 
137                                /* converts val to a string
138                                 * and puts into buf */
139  void  (*free_fn)(struct _owl_variable *v);
140                                /* frees val as needed */
141} owl_variable;
142
143typedef struct _owl_fmtext {
144  int textlen;
145  char *textbuff;
146  char *fmbuff;
147  char *colorbuff;
148} owl_fmtext;
149
150typedef struct _owl_list {
151  int size;
152  int avail;
153  void **list;
154} owl_list;
155
156typedef struct _owl_dict_el {
157  char *k;                      /* key   */
158  void *v;                      /* value */
159} owl_dict_el;
160
161typedef struct _owl_dict {
162  int size;
163  int avail;
164  owl_dict_el *els;             /* invariant: sorted by k */
165} owl_dict;
166typedef owl_dict owl_vardict;   /* dict of variables */
167typedef owl_dict owl_cmddict;   /* dict of commands */
168
169typedef struct _owl_context {
170  int   mode;
171  void *data;           /* determined by mode */
172} owl_context;
173
174typedef struct _owl_cmd {       /* command */
175  char *name;
176
177  char *summary;                /* one line summary of command */
178  char *usage;                  /* usage synopsis */
179  char *description;            /* long description of command */
180
181  int validctx;                 /* bitmask of valid contexts */
182
183  /* we should probably have a type here that says which of
184   * the following is valid, and maybe make the below into a union... */
185
186  /* Only one of these may be non-NULL ... */
187
188  char *cmd_aliased_to;         /* what this command is aliased to... */
189 
190  /* These don't take any context */
191  char *(*cmd_args_fn)(int argc, char **argv, char *buff); 
192                                /* takes argv and the full command as buff.
193                                 * caller must free return value if !NULL */
194  void (*cmd_v_fn)(void);       /* takes no args */
195  void (*cmd_i_fn)(int i);      /* takes an int as an arg */
196
197  /* The following also take the active context if it's valid */
198  char *(*cmd_ctxargs_fn)(void *ctx, int argc, char **argv, char *buff); 
199                                /* takes argv and the full command as buff.
200                                 * caller must free return value if !NULL */
201  void (*cmd_ctxv_fn)(void *ctx);               /* takes no args */
202  void (*cmd_ctxi_fn)(void *ctx, int i);        /* takes an int as an arg */
203} owl_cmd;
204
205
206typedef struct _owl_zwrite {
207  char class[LINE];
208  char inst[LINE];
209  char realm[LINE];
210  char opcode[LINE];
211  owl_list recips;
212  int cc;
213  int noping;
214} owl_zwrite;
215
216typedef struct _owl_message {
217  int id;
218  int type;
219  int admintype;
220  ZNotice_t notice;
221  owl_fmtext fmtext;
222  int delete;
223  char hostname[MAXHOSTNAMELEN];
224  char *sender;
225  char *recip;
226  char *class;
227  char *inst;
228  char *opcode;
229  char *time;
230  char *realm;
231  char *body;
232  char *zwriteline;
233} owl_message;
234
235typedef struct _owl_mainwin {
236  int curtruncated;
237  int lastdisplayed;
238} owl_mainwin;
239
240typedef struct _owl_viewwin {
241  owl_fmtext fmtext;
242  int textlines;
243  int topline;
244  int rightshift;
245  int winlines, wincols;
246  WINDOW *curswin;
247} owl_viewwin;
248 
249typedef struct _owl_popwin {
250  WINDOW *borderwin;
251  WINDOW *popwin;
252  int lines;
253  int cols;
254  int active;
255  int needsfirstrefresh;
256  void (*handler) (int ch);
257} owl_popwin;
258
259typedef struct _owl_messagelist {
260  owl_list list;
261} owl_messagelist;
262
263typedef struct _owl_regex {
264  int negate;
265  char *string;
266  regex_t re;
267} owl_regex;
268
269typedef struct _owl_filterelement {
270  int type;
271  char *field;
272  owl_regex re;
273} owl_filterelement;
274
275typedef struct _owl_filter {
276  char *name;
277  int polarity;
278  owl_list fes; /* filterelements */
279  int color;
280} owl_filter;
281
282typedef struct _owl_view {
283  owl_filter *filter;
284  owl_messagelist ml;
285} owl_view;
286
287typedef struct _owl_history {
288  owl_list hist;
289  int cur;
290  int touched;
291  int partial;
292} owl_history;
293
294typedef struct _owl_editwin {
295  char *buff;
296  owl_history *hist;
297  int bufflen;
298  int allocated;
299  int buffx, buffy;
300  int topline;
301  int winlines, wincols, fillcol, wrapcol;
302  WINDOW *curswin;
303  int style;
304  int lock;
305  int dotsend;
306} owl_editwin;
307
308typedef struct _owl_keybinding {
309  int  *j;                      /* keypress stack (0-terminated) */ 
310  int   type;                   /* command or function? */
311  char *desc;                   /* description (or "*user*") */
312  char *command;                /* command, if of type command */
313  void (*function_fn)(void);    /* function ptr, if of type function */
314} owl_keybinding;
315
316typedef struct _owl_keymap {
317  char     *name;               /* name of keymap */
318  char     *desc;               /* description */
319  owl_list  bindings;           /* key bindings */
320  struct _owl_keymap *submap;   /* submap */
321  void (*default_fn)(int j);    /* default action (takes a keypress) */
322  void (*prealways_fn)(int j);  /* always called before a keypress is received */
323  void (*postalways_fn)(int j); /* always called after keypress is processed */
324} owl_keymap;
325
326typedef struct _owl_keyhandler {
327  owl_dict  keymaps;            /* dictionary of keymaps */
328  owl_keymap *active;           /* currently active keymap */
329  int       in_esc;             /* escape pressed? */
330  int       kpstack[OWL_KEYMAP_MAXSTACK+1]; /* current stack of keypresses */
331  int       kpstackpos;         /* location in stack (-1 = none) */
332} owl_keyhandler;
333
334typedef struct _owl_global {
335  owl_mainwin mw;
336  owl_popwin pw;
337  owl_history cmdhist;          /* command history */
338  owl_history msghist;          /* outgoing message history */
339  owl_keyhandler kh;
340  owl_list filterlist;
341  owl_list puntlist;
342  owl_vardict vars;
343  owl_cmddict cmds;
344  owl_context ctx;
345  int lines, cols;
346  int curmsg, topmsg;
347  int curmsg_vert_offset;
348  owl_view current_view;
349  owl_messagelist msglist;
350  WINDOW *recwin, *sepwin, *msgwin, *typwin;
351  int needrefresh;
352  int rightshift;
353  int resizepending;
354  int recwinlines;
355  int typwinactive;
356  char thishost[LINE];
357  char thistty[LINE];
358  char homedir[LINE];
359  int direction;
360  int zaway;
361  char *cur_zaway_msg;
362  int haveconfig;
363  int config_format;
364  char buffercommand[1024];
365  owl_editwin tw;
366  owl_viewwin vw;
367  void *perl;
368  int debug;
369  int starttime;
370  char startupargs[LINE];
371  int userclue;
372  int nextmsgid;
373  int hascolors;
374  int colorpairs;
375  owl_filterelement fe_true;
376  owl_filterelement fe_false;
377  owl_filterelement fe_null;
378} owl_global;
379
380/* globals */
381owl_global g;
382
383#include "owl_prototypes.h"
384
385/* these are missing from the zephyr includes for some reason */
386int ZGetSubscriptions(ZSubscription_t *, int *);
387int ZGetLocations(ZLocations_t *,int *);
388
389#endif /* INC_OWL_H */
Note: See TracBrowser for help on using the repository browser.