~ubuntu-branches/debian/lenny/alpine/lenny

« back to all changes in this revision

Viewing changes to pico/pico.h

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2007-02-17 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20070217131742-99x5c6cpg1pbkdhw
Tags: upstream-0.82+dfsg
ImportĀ upstreamĀ versionĀ 0.82+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: pico.h 381 2007-01-23 02:07:14Z jpf@u.washington.edu $
 
3
 *
 
4
 * ========================================================================
 
5
 * Copyright 2006-2007 University of Washington
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 *     http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * ========================================================================
 
14
 *
 
15
 * Program:     pico.h - definitions for Pine's composer library
 
16
 */
 
17
 
 
18
#ifndef PICO_H
 
19
#define PICO_H
 
20
 
 
21
#include "mode.h"
 
22
 
 
23
#include "../pith/osdep/color.h"
 
24
#include "../pith/osdep/err_desc.h"
 
25
#include "../pith/charconv/utf8.h"
 
26
 
 
27
#define errstr(n)       error_description(n)
 
28
 
 
29
/*
 
30
 * Defined for attachment support
 
31
 */
 
32
#define ATTACHMENTS     1
 
33
 
 
34
 
 
35
/*
 
36
 * defs of return codes from pine mailer composer.
 
37
 */
 
38
#define BUF_CHANGED     0x01
 
39
#define COMP_CANCEL     0x02
 
40
#define COMP_EXIT       0x04
 
41
#define COMP_FAILED     0x08
 
42
#define COMP_SUSPEND    0x10
 
43
#define COMP_GOTHUP     0x20
 
44
 
 
45
 
 
46
/*
 
47
 * top line from the top of the screen for the editor to do 
 
48
 * its stuff
 
49
 */
 
50
#define COMPOSER_TOP_LINE       2
 
51
#define COMPOSER_TITLE_LINE     0
 
52
 
 
53
 
 
54
 
 
55
#define HLSZ 256
 
56
 
 
57
/*
 
58
 * definitions of Mail header structures 
 
59
 */
 
60
struct hdr_line {
 
61
        UCS     text[HLSZ];
 
62
        struct  hdr_line        *next;
 
63
        struct  hdr_line        *prev;
 
64
};
 
65
 
 
66
 
 
67
/* must be the same as HelpType in pith/helptext.h */
 
68
#define HELP_T  char **
 
69
 
 
70
 
 
71
/* 
 
72
 *  This structure controls the header line items on the screen.  An
 
73
 * instance of this should be created and passed in as an argument when
 
74
 * pico is called. The list is terminated by an entry with the name
 
75
 * element NULL.
 
76
 */
 
77
 
 
78
struct headerentry {
 
79
        char     *prompt;
 
80
        char     *name;
 
81
        HELP_T    help;
 
82
        int       prwid;              /* prompt width on screen             */
 
83
        int       maxlen;
 
84
        char    **realaddr;
 
85
        int     (*builder)();        /* Function to verify/canonicalize val */
 
86
        struct headerentry        *affected_entry, *next_affected;
 
87
                                     /* entry builder's 4th arg affects     */
 
88
        char   *(*selector)();       /* Browser for possible values         */
 
89
        char     *key_label;         /* Key label for key to call browser   */
 
90
        char   *(*fileedit)();       /* Editor for file named in header     */
 
91
        unsigned  display_it:1;      /* field is to be displayed by default */
 
92
        unsigned  break_on_comma:1;  /* Field breaks on commas              */
 
93
        unsigned  is_attach:1;       /* Special case field for attachments  */
 
94
        unsigned  rich_header:1;     /* Field is part of rich header        */
 
95
        unsigned  only_file_chars:1; /* Field is a file name                */
 
96
        unsigned  single_space:1;    /* Crush multiple spaces into one      */
 
97
        unsigned  sticky:1;          /* Can't change this via affected_entry*/
 
98
        unsigned  dirty:1;           /* We've changed this entry            */
 
99
        unsigned  start_here:1;      /* begin composer on first on lit      */
 
100
        unsigned  blank:1;           /* blank line separator                */
 
101
#ifdef  KS_OSDATAVAR
 
102
        KS_OSDATAVAR                 /* Port-Specific keymenu data */
 
103
#endif
 
104
        void     *bldr_private;      /* Data managed by builders            */
 
105
        struct    hdr_line        *hd_text;
 
106
};
 
107
 
 
108
 
 
109
/*
 
110
 * Structure to pass as arg to builders.
 
111
 *
 
112
 *    me -- A pointer to the bldr_private data for the entry currently
 
113
 *            being edited.
 
114
 *  tptr -- A malloc'd copy of the displayed text for the affected_entry
 
115
 *            pointed to by the  aff argument.
 
116
 *   aff -- A pointer to the bldr_private data for the affected_entry (the
 
117
 *            entry that this entry affects).
 
118
 *  next -- The next affected_entry in the list. For example, the Lcc entry
 
119
 *            affects the To entry which affects the Fcc entry.
 
120
 */
 
121
typedef struct bld_arg {
 
122
    void          **me;
 
123
    char           *tptr;
 
124
    void          **aff;
 
125
    struct bld_arg *next;
 
126
} BUILDER_ARG;
 
127
 
 
128
#define BUILDER_SCREEN_MANGLED 0x1
 
129
#define BUILDER_MESSAGE_DISPLAYED 0x2
 
130
 
 
131
 
 
132
/*
 
133
 * structure to keep track of header display
 
134
 */
 
135
struct on_display {
 
136
    int                  p_ind;                 /* index into line */
 
137
    int                  p_len;                 /* length of line   */
 
138
    int                  p_line;                /* physical line on screen */
 
139
    int                  top_e;                 /* topline's header entry */
 
140
    struct hdr_line     *top_l;                 /* top line on display */
 
141
    int                  cur_e;                 /* current header entry */
 
142
    struct hdr_line     *cur_l;                 /* current hd_line */
 
143
};                                              /* global on_display struct */
 
144
 
 
145
 
 
146
/*
 
147
 * Structure to handle attachments
 
148
 */
 
149
typedef struct pico_atmt {
 
150
    char *description;                  /* attachment description */
 
151
    char *filename;                     /* file/pseudonym for attachment */
 
152
    char *size;                         /* size of attachment */
 
153
    char *id;                           /* attachment id */
 
154
    unsigned short flags;
 
155
    struct pico_atmt *next;
 
156
} PATMT;
 
157
 
 
158
/*
 
159
 * Structure to contain color options
 
160
 */
 
161
typedef struct pico_colors {
 
162
    COLOR_PAIR *tbcp;                   /* title bar color pair */
 
163
    COLOR_PAIR *klcp;                   /* key label color pair */
 
164
    COLOR_PAIR *kncp;                   /* key name color pair  */
 
165
    COLOR_PAIR *stcp;                   /* status color pair    */
 
166
} PCOLORS;
 
167
 
 
168
/*
 
169
 * Flags for attachment handling
 
170
 */
 
171
#define A_FLIT  0x0001                  /* Accept literal file and size      */
 
172
#define A_ERR   0x0002                  /* Problem with specified attachment */
 
173
#define A_TMP   0x0004                  /* filename is temporary, delete it  */
 
174
 
 
175
 
 
176
/*
 
177
 * Master pine composer structure.  Right now there's not much checking
 
178
 * that any of these are pointing to something, so pine must have them pointing
 
179
 * somewhere.
 
180
 */
 
181
typedef struct pico_struct {
 
182
    void  *msgtext;                     /* ptrs to malloc'd arrays of char */
 
183
    char  *pine_anchor;                 /* ptr to pine anchor line */
 
184
    char  *pine_version;                /* string containing Pine's version */
 
185
    char  *oper_dir;                    /* Operating dir (confine to tree) */
 
186
    char  *home_dir;                    /* Home directory that should be used (WINDOWS) */
 
187
    char  *quote_str;                   /* prepended to lines of quoted text */
 
188
    char  *exit_label;                  /* Label for ^X in keymenu */
 
189
    char  *ctrlr_label;                 /* Label for ^R in keymenu */
 
190
    char  *alt_spell;                   /* Checker to use other than "spell" */
 
191
    char **alt_ed;                      /* name of alternate editor or NULL */
 
192
    int    fillcolumn;                  /* where to wrap */
 
193
    int    menu_rows;                   /* number of rows in menu (0 or 2) */
 
194
    long   edit_offset;                 /* offset into hdr line or body */
 
195
    PATMT *attachments;                 /* linked list of attachments */
 
196
    PCOLORS *colors;                    /* colors for titlebar and keymenu */
 
197
    void  *input_cs;                    /* passed to mbtow() via kbseq() */
 
198
    long   pine_flags;                  /* entry mode flags */
 
199
    /* The next few bits are features that don't fit in pine_flags      */
 
200
    /* If we had this to do over, it would probably be one giant bitmap */
 
201
    unsigned always_spell_check:1;      /* always spell-checking upon quit */
 
202
    unsigned strip_ws_before_send:1;    /* don't default strip bc of flowed */
 
203
    unsigned allow_flowed_text:1;    /* clean text when done to keep flowed */
 
204
    int   (*helper)();                  /* Pine's help function  */
 
205
    int   (*showmsg)();                 /* Pine's display_message */
 
206
    UCS   (*suspend)();                 /* Pine's suspend */
 
207
    void  (*keybinput)();               /* Pine's keyboard input indicator */
 
208
    int   (*tty_fix)();                 /* Let Pine fix tty state */
 
209
    long  (*newmail)();                 /* Pine's report_new_mail */
 
210
    long  (*msgntext)();                /* callback to get msg n's text */
 
211
    int   (*upload)();                  /* callback to rcv uplaoded text */
 
212
    char *(*ckptdir)();                 /* callback for checkpoint file dir */
 
213
    char *(*exittest)();                /* callback to verify exit request */
 
214
    char *(*canceltest)();              /* callback to verify cancel request */
 
215
    int   (*mimetype)();                /* callback to display mime type */
 
216
    int   (*expander)();                /* callback to expand address lists */
 
217
    int   (*user_says_noflow)();        /* callback to tell us we're not flowing */
 
218
    void  (*resize)();                  /* callback handling screen resize */
 
219
    void  (*winch_cleanup)();           /* callback handling screen resize */
 
220
    int    arm_winch_cleanup;           /* do the winch_cleanup if resized */
 
221
    HELP_T search_help;
 
222
    HELP_T ins_help;
 
223
    HELP_T ins_m_help;
 
224
    HELP_T composer_help;
 
225
    HELP_T browse_help;
 
226
    HELP_T attach_help;
 
227
    struct headerentry *headents;
 
228
} PICO;
 
229
 
 
230
 
 
231
/*
 
232
 * Used to save and restore global pico variables that are destroyed by
 
233
 * calling pico a second time. This happens when pico calls a selector
 
234
 * in the HeaderEditor and that selector calls pico again.
 
235
 */
 
236
typedef struct save_stuff {
 
237
    int                 vtrow,
 
238
                        vtcol,
 
239
                        lbound;
 
240
    VIDEO             **vscreen,
 
241
                      **pscreen;        /* save pointers */
 
242
    struct on_display   ods;            /* save whole struct */
 
243
    short               delim_ps,
 
244
                        invert_ps;
 
245
    int                 pico_all_done;
 
246
    jmp_buf             finstate;
 
247
    UCS                *pico_anchor;    /* save pointer */
 
248
    PICO               *Pmaster;        /* save pointer */
 
249
    int                 fillcol;
 
250
    UCS                *pat;            /* save array */
 
251
    int                 ComposerTopLine,
 
252
                        ComposerEditing;
 
253
    long                gmode;
 
254
    char               *alt_speller;    /* save pointer */
 
255
    UCS                *quote_str;      /* save pointer */
 
256
    int                 currow,
 
257
                        curcol,
 
258
                        thisflag,
 
259
                        lastflag,
 
260
                        curgoal;
 
261
    char               *opertree;       /* save array */
 
262
    WINDOW             *curwp;          /* save pointer */
 
263
    WINDOW             *wheadp;         /* save pointer */
 
264
    BUFFER             *curbp;          /* save pointer */
 
265
    BUFFER             *bheadp;         /* save pointer */
 
266
    int                 km_popped;
 
267
    int                 mrow;
 
268
} VARS_TO_SAVE;
 
269
 
 
270
 
 
271
#ifdef  MOUSE
 
272
/*
 
273
 * Mouse buttons.
 
274
 */
 
275
#define M_BUTTON_LEFT           0
 
276
#define M_BUTTON_MIDDLE         1
 
277
#define M_BUTTON_RIGHT          2
 
278
 
 
279
 
 
280
/*
 
281
 * Flags.  (modifier keys)
 
282
 */
 
283
#define M_KEY_CONTROL           0x01    /* Control key was down. */
 
284
#define M_KEY_SHIFT             0x02    /* Shift key was down. */
 
285
 
 
286
 
 
287
/*
 
288
 * Mouse Events
 
289
 */
 
290
#define M_EVENT_DOWN            0x01    /* Mouse went down. */
 
291
#define M_EVENT_UP              0x02    /* Mouse went up. */
 
292
#define M_EVENT_TRACK           0x04    /* Mouse tracking */
 
293
 
 
294
/*
 
295
 * Mouse event information.
 
296
 */
 
297
typedef struct mouse_struct {
 
298
        unsigned long mevent;   /* Indicates type of event:  Down, Up or Track */
 
299
        char    down;           /* TRUE when mouse down event */
 
300
        char    doubleclick;    /* TRUE when double click. */
 
301
        int     button;         /* button pressed. */
 
302
        int     flags;          /* What other keys pressed. */
 
303
        int     row;
 
304
        int     col;
 
305
} MOUSEPRESS;
 
306
 
 
307
 
 
308
 
 
309
typedef unsigned long (*mousehandler_t)(unsigned long, int, int, int, int);
 
310
 
 
311
typedef struct point {
 
312
    unsigned    r:8;            /* row value                            */
 
313
    unsigned    c:8;            /* column value                         */
 
314
} MPOINT;
 
315
 
 
316
 
 
317
typedef struct menuitem {
 
318
    unsigned         val;       /* return value                         */
 
319
    mousehandler_t    action;   /* action to perform                    */
 
320
    MPOINT           tl;        /* top-left corner of active area       */
 
321
    MPOINT           br;        /* bottom-right corner of active area   */
 
322
    MPOINT           lbl;       /* where the label starts               */
 
323
    char            *label;
 
324
    void            (*label_hiliter)();
 
325
    COLOR_PAIR      *kncp;      /* key name color pair                  */
 
326
    COLOR_PAIR      *klcp;      /* key label color pair                 */ 
 
327
    struct menuitem *next;
 
328
} MENUITEM;
 
329
#endif
 
330
 
 
331
 
 
332
/*
 
333
 * Structure used to manage keyboard input that comes as escape
 
334
 * sequences (arrow keys, function keys, etc.)
 
335
 */
 
336
typedef struct  KBSTREE {
 
337
        char    value;
 
338
        int     func;              /* Routine to handle it         */
 
339
        struct  KBSTREE *down; 
 
340
        struct  KBSTREE *left;
 
341
} KBESC_T;
 
342
 
 
343
 
 
344
/*
 
345
 * various flags that they may passed to PICO
 
346
 */
 
347
#define P_HICTRL        0x80000000      /* overwrite mode               */
 
348
#define P_CHKPTNOW      0x40000000      /* do the checkpoint on entry      */
 
349
#define P_DELRUBS       0x20000000      /* map ^H to forwdel               */
 
350
#define P_LOCALLF       0x10000000      /* use local vs. NVT EOL           */
 
351
#define P_BODY          0x08000000      /* start composer in body          */
 
352
#define P_HEADEND       0x04000000      /* start composer at end of header */
 
353
#define P_VIEW          MDVIEW          /* read-only                       */
 
354
#define P_FKEYS         MDFKEY          /* run in function key mode        */
 
355
#define P_SECURE        MDSCUR          /* run in restricted (demo) mode   */
 
356
#define P_TREE          MDTREE          /* restrict to a subtree           */
 
357
#define P_SUSPEND       MDSSPD          /* allow ^Z suspension             */
 
358
#define P_ADVANCED      MDADVN          /* enable advanced features        */
 
359
#define P_CURDIR        MDCURDIR        /* use current dir for lookups     */
 
360
#define P_ALTNOW        MDALTNOW        /* enter alt ed sans hesitation    */
 
361
#define P_SUBSHELL      MDSPWN          /* spawn subshell for suspend      */
 
362
#define P_COMPLETE      MDCMPLT         /* enable file name completion     */
 
363
#define P_DOTKILL       MDDTKILL        /* kill from dot to eol            */
 
364
#define P_SHOCUR        MDSHOCUR        /* cursor follows hilite in browser*/
 
365
#define P_HIBITIGN      MDHBTIGN        /* ignore chars with hi bit set    */
 
366
#define P_DOTFILES      MDDOTSOK        /* browser displays dot files      */
 
367
#define P_NOBODY        MDHDRONLY       /* Operate only on given headers   */
 
368
#define P_ALLOW_GOTO    MDGOTO          /* support "Goto" in file browser  */
 
369
#define P_REPLACE       MDREPLACE       /* allow "Replace" in "Where is"   */
 
370
 
 
371
 
 
372
/*
 
373
 * Main defs 
 
374
 */
 
375
#ifdef  maindef
 
376
PICO    *Pmaster = NULL;                /* composer specific stuff */
 
377
char    *version = "4.92";              /* PICO version number */
 
378
 
 
379
#else
 
380
extern  PICO *Pmaster;                  /* composer specific stuff */
 
381
extern  char *version;                  /* pico version! */
 
382
 
 
383
#endif  /* maindef */
 
384
 
 
385
 
 
386
/*
 
387
 * Flags for FileBrowser call
 
388
 */
 
389
#define FB_READ         0x0001          /* Looking for a file to read.  */
 
390
#define FB_SAVE         0x0002          /* Looking for a file to save.  */
 
391
#define FB_ATTACH       0x0004          /* Looking for a file to attach */
 
392
#define FB_LMODEPOS     0x0008          /* ListMode is a possibility    */
 
393
#define FB_LMODE        0x0010          /* Using ListMode now           */
 
394
 
 
395
 
 
396
/*
 
397
 * Flags for pico_readc/pico_writec.
 
398
 */
 
399
#define PICOREADC_NONE  0x00
 
400
#define PICOREADC_NOUCS 0x01
 
401
 
 
402
 
 
403
/*
 
404
 * number of keystrokes to delay removing an error message, or new mail
 
405
 * notification, or checkpointing
 
406
 */
 
407
#define MESSDELAY       25
 
408
#define NMMESSDELAY     60
 
409
#ifndef CHKPTDELAY
 
410
#define CHKPTDELAY      100
 
411
#endif
 
412
 
 
413
/*
 
414
#include "./keydefs.h"
 
415
 
 
416
 
 
417
/*
 
418
 * useful function definitions
 
419
 */
 
420
int   pico(PICO *pm);
 
421
int   pico_file_browse(PICO *, char *, size_t, char *, size_t, char *, size_t, int);
 
422
void *pico_get(void);
 
423
void  pico_give(void *w);
 
424
int   pico_readc(void *w, unsigned char *c, int flags);
 
425
int   pico_writec(void *w, int c, int flags);
 
426
int   pico_puts(void *w, char *s, int flags);
 
427
int   pico_seek(void *w, long offset, int orig);
 
428
int   pico_replace(void *, char *);
 
429
int   pico_fncomplete(char *, size_t, char *, size_t);
 
430
#if defined(DOS) || defined(OS2)
 
431
int   pico_nfsetcolor(char *);
 
432
int   pico_nbsetcolor(char *);
 
433
int   pico_rfsetcolor(char *);
 
434
int   pico_rbsetcolor(char *);
 
435
#endif
 
436
#ifdef  MOUSE
 
437
int   register_mfunc(mousehandler_t, int, int, int, int);
 
438
void  clear_mfunc(mousehandler_t);
 
439
unsigned long mouse_in_content(unsigned long, int, int, int, int);
 
440
unsigned long mouse_in_pico(unsigned long, int, int, int, int);
 
441
void  mouse_get_last(mousehandler_t *, MOUSEPRESS *);
 
442
void  register_key(int, unsigned, char *, void (*)(),
 
443
                   int, int, int, COLOR_PAIR *, COLOR_PAIR *);
 
444
int   mouse_on_key(int, int);
 
445
#endif  /* MOUSE */
 
446
 
 
447
 
 
448
#endif  /* PICO_H */