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