* Implement a different way to delete a password from the cache.
[alpine.git] / pico / pico.h
blob69cd8ba31cbdc9c038eb09b13928004c55a0883b
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-2022 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 * Structure to pass as arg to builders.
74 * me -- A pointer to the bldr_private data for the entry currently
75 * being edited.
76 * tptr -- A malloc'd copy of the displayed text for the affected_entry
77 * pointed to by the aff argument.
78 * aff -- A pointer to the bldr_private data for the affected_entry (the
79 * entry that this entry affects).
80 * next -- The next affected_entry in the list. For example, the Lcc entry
81 * affects the To entry which affects the Fcc entry.
83 typedef struct bld_arg {
84 void **me;
85 char *tptr;
86 void **aff;
87 struct bld_arg *next;
88 } BUILDER_ARG;
90 /*
91 * This structure controls the header line items on the screen. An
92 * instance of this should be created and passed in as an argument when
93 * pico is called. The list is terminated by an entry with the name
94 * element NULL.
97 struct headerentry {
98 char *prompt;
99 char *name;
100 HELP_T help;
101 int prwid; /* prompt width on screen */
102 int maxlen;
103 char **realaddr;
104 /* Function to verify/canonicalize val */
105 int (*builder)(char *, char **, char **, BUILDER_ARG *, int *);
106 struct headerentry *affected_entry, *next_affected;
107 /* entry builder's 4th arg affects */
108 /* Browser for possible values */
109 char *(*selector)(char **);
110 char *key_label; /* Key label for key to call browser */
111 char *(*fileedit)(char *); /* Editor for file named in header */
112 /* routine that helps with nickname completion */
113 int (*nickcmpl)(char *, char **, int, unsigned int);
114 unsigned display_it:1; /* field is to be displayed by default */
115 unsigned break_on_comma:1; /* Field breaks on commas */
116 unsigned is_attach:1; /* Special case field for attachments */
117 unsigned rich_header:1; /* Field is part of rich header */
118 unsigned only_file_chars:1; /* Field is a file name */
119 unsigned single_space:1; /* Crush multiple spaces into one */
120 unsigned sticky:1; /* Can't change this via affected_entry*/
121 unsigned dirty:1; /* We've changed this entry */
122 unsigned start_here:1; /* begin composer on first on lit */
123 unsigned blank:1; /* blank line separator */
124 unsigned sticky_special:1; /* special treatment */
125 #ifdef KS_OSDATAVAR
126 KS_OSDATAVAR /* Port-Specific keymenu data */
127 #endif
128 void *bldr_private; /* Data managed by builders */
129 struct hdr_line *hd_text;
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 /* Pine's help function */
218 int (*helper)(HELP_T, char *, int);
219 int (*showmsg)(UCS); /* Pine's display_message */
220 UCS (*suspend)(void); /* Pine's suspend */
221 void (*keybinput)(void); /* Pine's keyboard input indicator */
222 int (*tty_fix)(int); /* Let Pine fix tty state */
223 long (*newmail)(int, int); /* Pine's report_new_mail */
224 /* callback to get msg n's text */
225 long (*msgntext)(long, int (*)(int));
226 /* callback to rcv uploaded text */
227 int (*upload)(char *, size_t, long *);
228 /* callback for checkpoint file dir */
229 char *(*ckptdir)(char *, size_t);
230 /* callback to verify exit request */
231 int (*exittest)(struct headerentry *, void (*)(void), int, char **);
232 /* callback to verify cancel request */
233 char *(*canceltest)(void(*)(void));
234 int (*mimetype)(char *); /* callback to display mime type */
235 /* callback to expand address lists */
236 int (*expander)(struct headerentry *, char ***);
237 int (*user_says_noflow)(void); /* callback to tell us we're not flowing */
238 /* callback handling screen resize */
239 void (*resize)(void);
240 /* callback handling screen resize */
241 void (*winch_cleanup)(void);
242 void (*newthread)(void); /* callback to create new thread */
243 int arm_winch_cleanup; /* do the winch_cleanup if resized */
244 HELP_T search_help;
245 HELP_T ins_help;
246 HELP_T ins_m_help;
247 HELP_T composer_help;
248 HELP_T browse_help;
249 HELP_T attach_help;
250 struct headerentry *headents;
251 } PICO;
255 * Used to save and restore global pico variables that are destroyed by
256 * calling pico a second time. This happens when pico calls a selector
257 * in the HeaderEditor and that selector calls pico again.
259 typedef struct save_stuff {
260 int vtrow,
261 vtcol,
262 lbound;
263 VIDEO **vscreen,
264 **pscreen; /* save pointers */
265 struct on_display ods; /* save whole struct */
266 short delim_ps,
267 invert_ps;
268 int pico_all_done;
269 jmp_buf finstate;
270 UCS *pico_anchor; /* save pointer */
271 PICO *Pmaster; /* save pointer */
272 int fillcol;
273 UCS *pat; /* save array */
274 int ComposerTopLine,
275 ComposerEditing;
276 long gmode;
277 char *alt_speller; /* save pointer */
278 UCS *quote_str; /* save pointer */
279 UCS *wordseps; /* save pointer */
280 int currow,
281 curcol,
282 thisflag,
283 lastflag,
284 curgoal;
285 char *opertree; /* save array */
286 WINDOW *curwp; /* save pointer */
287 WINDOW *wheadp; /* save pointer */
288 BUFFER *curbp; /* save pointer */
289 BUFFER *bheadp; /* save pointer */
290 int km_popped;
291 int mrow;
292 } VARS_TO_SAVE;
295 #ifdef MOUSE
297 * Mouse buttons.
299 #define M_BUTTON_LEFT 0
300 #define M_BUTTON_MIDDLE 1
301 #define M_BUTTON_RIGHT 2
305 * Flags. (modifier keys)
307 #define M_KEY_CONTROL 0x01 /* Control key was down. */
308 #define M_KEY_SHIFT 0x02 /* Shift key was down. */
312 * Mouse Events
314 #define M_EVENT_DOWN 0x01 /* Mouse went down. */
315 #define M_EVENT_UP 0x02 /* Mouse went up. */
316 #define M_EVENT_TRACK 0x04 /* Mouse tracking */
319 * Mouse event information.
321 typedef struct mouse_struct {
322 unsigned long mevent; /* Indicates type of event: Down, Up or Track */
323 char down; /* TRUE when mouse down event */
324 char doubleclick; /* TRUE when double click. */
325 int button; /* button pressed. */
326 int flags; /* What other keys pressed. */
327 int row;
328 int col;
329 } MOUSEPRESS;
333 typedef unsigned long (*mousehandler_t)(unsigned long, int, int, int, int);
335 typedef struct point {
336 unsigned r:8; /* row value */
337 unsigned c:8; /* column value */
338 } MPOINT;
341 typedef struct menuitem {
342 unsigned val; /* return value */
343 mousehandler_t action; /* action to perform */
344 MPOINT tl; /* top-left corner of active area */
345 MPOINT br; /* bottom-right corner of active area */
346 MPOINT lbl; /* where the label starts */
347 char *label;
348 void (*label_hiliter)(int, struct menuitem *);
349 COLOR_PAIR *kncp; /* key name color pair */
350 COLOR_PAIR *klcp; /* key label color pair */
351 struct menuitem *next;
352 } MENUITEM;
353 #endif
357 * Structure used to manage keyboard input that comes as escape
358 * sequences (arrow keys, function keys, etc.)
360 typedef struct KBSTREE {
361 char value;
362 int func; /* Routine to handle it */
363 struct KBSTREE *down;
364 struct KBSTREE *left;
365 } KBESC_T;
369 * various flags that they may passed to PICO
371 #define P_HICTRL 0x80000000 /* overwrite mode */
372 #define P_CHKPTNOW 0x40000000 /* do the checkpoint on entry */
373 #define P_DELRUBS 0x20000000 /* map ^H to forwdel */
374 #define P_LOCALLF 0x10000000 /* use local vs. NVT EOL */
375 #define P_BODY 0x08000000 /* start composer in body */
376 #define P_HEADEND 0x04000000 /* start composer at end of header */
377 #define P_VIEW MDVIEW /* read-only */
378 #define P_FKEYS MDFKEY /* run in function key mode */
379 #define P_SECURE MDSCUR /* run in restricted (demo) mode */
380 #define P_TREE MDTREE /* restrict to a subtree */
381 #define P_SUSPEND MDSSPD /* allow ^Z suspension */
382 #define P_ADVANCED MDADVN /* enable advanced features */
383 #define P_CURDIR MDCURDIR /* use current dir for lookups */
384 #define P_ALTNOW MDALTNOW /* enter alt ed sans hesitation */
385 #define P_SUBSHELL MDSPWN /* spawn subshell for suspend */
386 #define P_COMPLETE MDCMPLT /* enable file name completion */
387 #define P_DOTKILL MDDTKILL /* kill from dot to eol */
388 #define P_SHOCUR MDSHOCUR /* cursor follows hilite in browser*/
389 #define P_HIBITIGN MDHBTIGN /* ignore chars with hi bit set */
390 #define P_DOTFILES MDDOTSOK /* browser displays dot files */
391 #define P_NOBODY MDHDRONLY /* Operate only on given headers */
392 #define P_ALLOW_GOTO MDGOTO /* support "Goto" in file browser */
393 #define P_REPLACE MDREPLACE /* allow "Replace" in "Where is" */
397 * Main defs
399 #ifdef maindef
400 PICO *Pmaster = NULL; /* composer specific stuff */
401 char *version = "5.09"; /* PICO version number */
403 #else
404 extern PICO *Pmaster; /* composer specific stuff */
405 extern char *version; /* pico version! */
407 #endif /* maindef */
411 * Flags for FileBrowser call
413 #define FB_READ 0x0001 /* Looking for a file to read. */
414 #define FB_SAVE 0x0002 /* Looking for a file to save. */
415 #define FB_ATTACH 0x0004 /* Looking for a file to attach */
416 #define FB_LMODEPOS 0x0008 /* ListMode is a possibility */
417 #define FB_LMODE 0x0010 /* Using ListMode now */
421 * Flags for pico_readc/pico_writec.
423 #define PICOREADC_NONE 0x00
424 #define PICOREADC_NOUCS 0x01
428 * number of keystrokes to delay removing an error message, or new mail
429 * notification, or checkpointing
431 #define MESSDELAY 25
432 #define NMMESSDELAY 60
433 #ifndef CHKPTDELAY
434 #define CHKPTDELAY 100
435 #endif
437 #include "./keydefs.h"
441 * useful function definitions
443 int pico(PICO *pm);
444 int pico_file_browse(PICO *, char *, size_t, char *, size_t, char *, size_t, int);
445 void *pico_get(void);
446 void pico_give(void *w);
447 int pico_readc(void *w, unsigned char *c, int flags);
448 int pico_writec(void *w, int c, int flags);
449 int pico_puts(void *w, char *s, int flags);
450 int pico_seek(void *w, long offset, int orig);
451 int pico_replace(void *, char *);
452 int pico_fncomplete(char *, char *, size_t);
453 #if defined(DOS) || defined(OS2)
454 int pico_nfsetcolor(char *);
455 int pico_nbsetcolor(char *);
456 int pico_rfsetcolor(char *);
457 int pico_rbsetcolor(char *);
458 #endif
459 #ifdef MOUSE
460 int register_mfunc(mousehandler_t, int, int, int, int);
461 void clear_mfunc(mousehandler_t);
462 unsigned long mouse_in_content(unsigned long, int, int, int, int);
463 unsigned long mouse_in_pico(unsigned long, int, int, int, int);
464 void mouse_get_last(mousehandler_t *, MOUSEPRESS *);
465 void register_key(int, unsigned, char *, void (*)(int, MENUITEM *),
466 int, int, int, COLOR_PAIR *, COLOR_PAIR *);
467 int mouse_on_key(int, int);
468 #endif /* MOUSE */
471 #endif /* PICO_H */