2
* $Id: pico.h 381 2007-01-23 02:07:14Z jpf@u.washington.edu $
4
* ========================================================================
5
* Copyright 2006-2007 University of Washington
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
11
* http://www.apache.org/licenses/LICENSE-2.0
13
* ========================================================================
15
* Program: pico.h - definitions for Pine's composer library
23
#include "../pith/osdep/color.h"
24
#include "../pith/osdep/err_desc.h"
25
#include "../pith/charconv/utf8.h"
27
#define errstr(n) error_description(n)
30
* Defined for attachment support
36
* defs of return codes from pine mailer composer.
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
47
* top line from the top of the screen for the editor to do
50
#define COMPOSER_TOP_LINE 2
51
#define COMPOSER_TITLE_LINE 0
58
* definitions of Mail header structures
62
struct hdr_line *next;
63
struct hdr_line *prev;
67
/* must be the same as HelpType in pith/helptext.h */
68
#define HELP_T char **
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
82
int prwid; /* prompt width on screen */
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 */
102
KS_OSDATAVAR /* Port-Specific keymenu data */
104
void *bldr_private; /* Data managed by builders */
105
struct hdr_line *hd_text;
110
* Structure to pass as arg to builders.
112
* me -- A pointer to the bldr_private data for the entry currently
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.
121
typedef struct bld_arg {
125
struct bld_arg *next;
128
#define BUILDER_SCREEN_MANGLED 0x1
129
#define BUILDER_MESSAGE_DISPLAYED 0x2
133
* structure to keep track of header 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 */
147
* Structure to handle attachments
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;
159
* Structure to contain color options
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 */
169
* Flags for attachment handling
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 */
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
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 */
224
HELP_T composer_help;
227
struct headerentry *headents;
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.
236
typedef struct save_stuff {
241
**pscreen; /* save pointers */
242
struct on_display ods; /* save whole struct */
247
UCS *pico_anchor; /* save pointer */
248
PICO *Pmaster; /* save pointer */
250
UCS *pat; /* save array */
254
char *alt_speller; /* save pointer */
255
UCS *quote_str; /* save pointer */
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 */
275
#define M_BUTTON_LEFT 0
276
#define M_BUTTON_MIDDLE 1
277
#define M_BUTTON_RIGHT 2
281
* Flags. (modifier keys)
283
#define M_KEY_CONTROL 0x01 /* Control key was down. */
284
#define M_KEY_SHIFT 0x02 /* Shift key was down. */
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 */
295
* Mouse event information.
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. */
309
typedef unsigned long (*mousehandler_t)(unsigned long, int, int, int, int);
311
typedef struct point {
312
unsigned r:8; /* row value */
313
unsigned c:8; /* column value */
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 */
324
void (*label_hiliter)();
325
COLOR_PAIR *kncp; /* key name color pair */
326
COLOR_PAIR *klcp; /* key label color pair */
327
struct menuitem *next;
333
* Structure used to manage keyboard input that comes as escape
334
* sequences (arrow keys, function keys, etc.)
336
typedef struct KBSTREE {
338
int func; /* Routine to handle it */
339
struct KBSTREE *down;
340
struct KBSTREE *left;
345
* various flags that they may passed to PICO
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" */
376
PICO *Pmaster = NULL; /* composer specific stuff */
377
char *version = "4.92"; /* PICO version number */
380
extern PICO *Pmaster; /* composer specific stuff */
381
extern char *version; /* pico version! */
387
* Flags for FileBrowser call
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 */
397
* Flags for pico_readc/pico_writec.
399
#define PICOREADC_NONE 0x00
400
#define PICOREADC_NOUCS 0x01
404
* number of keystrokes to delay removing an error message, or new mail
405
* notification, or checkpointing
408
#define NMMESSDELAY 60
410
#define CHKPTDELAY 100
414
#include "./keydefs.h"
418
* useful function definitions
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 *);
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);