1 /* $MirOS: contrib/code/jupp/types.h,v 1.15 2017/01/11 22:56:49 tg Exp $ */
8 /* Prefix to make string constants unsigned */
9 #define US (unsigned char *)
11 #ifdef HAVE_SYS_TYPES_H
12 #include <sys/types.h> /* we need pid_t */
16 #if defined(DEBUG) || defined(__COVERITY__)
17 #define mkssert(e) do { if (!(e)) exit(255); } while (/* CONSTCOND */ 0)
19 #define mkssert(e) do { } while (/* CONSTCOND */ 0)
23 #define NELEM(a) (sizeof(a) / sizeof((a)[0]))
25 #define LINK(type) struct { type *next; type *prev; }
29 #define FITHEIGHT 4 /* Minimum text window height */
31 #define NPROC 8 /* Number of processes we keep track of */
33 #define INC 16 /* Pages to allocate each time */
37 #define TYPEMENU 0x0800
41 typedef struct header H;
42 typedef struct buffer B;
43 typedef struct point P;
44 typedef struct options OPTIONS;
45 typedef struct macro MACRO;
46 typedef struct cmd CMD;
47 typedef struct entry HENTRY;
48 typedef struct hash HASH;
49 typedef struct kmap KMAP;
50 typedef struct kbd KBD;
51 typedef struct key KEY;
52 typedef struct watom WATOM;
53 typedef struct screen SCREEN;
54 typedef struct window W;
55 typedef struct base BASE;
57 typedef struct menu MENU;
58 typedef struct scrn SCRN;
59 typedef struct cap CAP;
61 typedef struct stditem STDITEM;
62 typedef struct query QW;
64 typedef struct irec IREC;
65 typedef struct undo UNDO;
66 typedef struct undorec UNDOREC;
67 typedef struct search SRCH;
68 typedef struct srchrec SRCHREC;
69 typedef struct vpage VPAGE;
70 typedef struct vfile VFILE;
74 LINK(H) link; /* LINK ??? */
82 LINK(P) link; /* ?LINK ??? */
86 unsigned char *ptr; /* ??? */
91 long col; /* current column */
93 int valcol; /* bool: is col valid? */
101 unsigned char *name_regex;
102 unsigned char *contents_regex;
111 unsigned char *context;
120 int highlight; /* Set to enable highlighting */
121 unsigned char *syntax_name; /* Name of syntax to use */
122 struct high_syntax *syntax; /* Syntax for highlighting (load_dfa() from syntax_name happens in setopt()) */
123 unsigned char *map_name; /* Name of character set */
124 struct charmap *charmap; /* Character set */
125 int smarthome; /* Set for smart home key */
126 int indentfirst; /* Smart home goes to indentation point first */
127 int smartbacks; /* Set for smart backspace key */
128 int purify; /* Purify indentation */
129 int picture; /* Picture mode */
130 MACRO *mnew; /* Macro to execute for new files */
131 MACRO *mold; /* Macro to execute for existing files */
132 MACRO *msnew; /* Macro to execute before saving new files */
133 MACRO *msold; /* Macro to execute before saving existing files */
134 int vispace; /* Set to make spaces visible */
135 int hex; /* Hex edit mode */
140 int arg; /* Repeat argument */
141 CMD *cmd; /* Command address */
142 int n; /* Number of steps */
143 int size; /* Malloc size of steps */
144 MACRO **steps; /* Block */
157 unsigned char *name; /* Command name */
158 int flag; /* Execution flags */
159 int (*func) (); /* Function bound to name */
160 MACRO *m; /* Macro bound to name */
161 int arg; /* 0= arg is meaningless, 1= ok */
162 unsigned char *negarg; /* Command to use if arg was negative */
172 long mod_time; /* Last modification time for file */
178 P *marks[11]; /* Bookmarks */
179 OPTIONS o; /* Options */
180 P *oldcur; /* Last cursor position before orphaning */
181 P *oldtop; /* Last top screen position before orphaning */
182 int rdonly; /* Set for read-only */
183 int internal; /* Set for internal buffers */
184 int scratch; /* Set for scratch buffers */
185 int er; /* Error code when file was loaded */
186 pid_t pid; /* Process id */
187 int out; /* fd to write to process */
204 unsigned char *text; /* help text with attributes */
205 unsigned int lines; /* number of lines */
206 struct help *prev; /* previous help screen */
207 struct help *next; /* nex help screen */
208 unsigned char *name; /* context name for context sensitive help */
213 int k; /* Flag: 0=binding, 1=submap */
215 void *bind; /* What key is bound to */
216 KMAP *submap; /* Sub KMAP address (for prefix keys) */
220 /* A map of keycode to command/sub-map bindings */
222 KEY keys[KEYS]; /* KEYs */
225 /** A keyboard handler **/
227 KMAP *curmap; /* Current keymap */
228 KMAP *topmap; /* Top-level keymap */
229 int seq[16]; /* Current sequence of keys */
230 int x; /* What we're up to */
235 unsigned char *context; /* Context name */
236 void (*disp) (); /* Display window */
237 void (*follow) (); /* Called to have window follow cursor */
238 int (*abort) (); /* Common user functions */
241 void (*resize) (); /* Called when window changed size */
242 void (*move) (); /* Called when window moved */
243 void (*ins) (); /* Called on line insertions */
244 void (*del) (); /* Called on line deletions */
245 int what; /* Type of this thing */
249 SCRN *t; /* Screen data on this screen is output to */
251 int wind; /* Number of help lines on this screen */
253 W *topwin; /* Top-most window showing on screen */
254 W *curwin; /* Window cursor is in */
256 int w, h; /* Width and height of this screen */
260 LINK(W) link; /* Linked list of windows in order they
261 appear on the screen */
263 SCREEN *t; /* Screen this thing is on */
265 int x, y, w, h; /* Position and size of window */
266 /* Currently, x = 0, w = width of screen. */
267 /* y == -1 if window is not on screen */
269 int ny, nh; /* Temporary values for wfit */
271 int reqh; /* Requested new height or 0 for same */
272 /* This is an argument for wfit */
274 int fixed; /* If this is zero, use 'hh'. If not, this
275 is a fixed size window and this variable
278 int hh; /* Height window would be on a screen with
279 1000 lines. When the screen size changes
280 this is used to calculate the window's
283 W *win; /* Window this one operates on */
284 W *main; /* Main window of this family */
285 W *orgwin; /* Window where space from this window came */
286 int curx, cury; /* Cursor position within window */
287 KBD *kbd; /* Keyboard handler for this window */
288 WATOM *watom; /* The type of this window */
289 void *object; /* Object which inherits this */
291 union { /* FIXME: instead of void *object we should */
292 BW *bw; /* use this union to get strict type checking */
293 PW *pw; /* from C compiler (need to check and change */
294 QW *qw; /* all of the occurrencies of ->object) */
301 const unsigned char *msgt; /* Message at top of window */
302 const unsigned char *msgb; /* Message at bottom of window */
303 const unsigned char *huh; /* Name of window for context sensitive hlp */
304 int *notify; /* Address of kill notification flag */
307 /* Anything which goes in window.object must start like this: */
325 int top_changed; /* Top changed */
329 W *parent; /* Window we're in */
330 unsigned char **list; /* List of items */
331 int top; /* First item on screen */
332 int cursor; /* Item cursor is on */
333 int width; /* Width of widest item, up to 'w' max */
334 int perline; /* Number of items on each line */
335 int nitems; /* No. items in list */
336 int saved_co; /* Saved #columns of screen */
337 SCREEN *t; /* Screen we're on */
339 int (*abrt) (); /* Abort callback function */
340 int (*func) (); /* Return callback function */
341 int (*backs) (); /* Backspace callback function */
350 /* Each terminal has one of these */
355 int li; /* Height of screen */
356 int co; /* Width of screen */
357 short *scrn; /* Buffer */
360 int *updtab; /* Lines which need to be updated */
361 /* HIGHLIGHT_STATE *syntab; */ /* Syntax highlight state at start of each line */
369 CAP *cap; /* Termcap/Terminfo data */
371 int li; /* Screen height */
372 int co; /* Screen width */
374 unsigned char *ti; /* Initialization string */
375 unsigned char *cl; /* Home and clear screen... really an
377 unsigned char *cd; /* Clear to end of screen */
378 unsigned char *te; /* Restoration string */
380 int haz; /* Terminal can't print ~s */
381 int os; /* Terminal overstrikes */
382 int eo; /* Can use blank to erase even if os */
383 int ul; /* _ overstrikes */
384 int am; /* Terminal has autowrap, but not magicwrap */
385 int xn; /* Terminal has magicwrap */
387 unsigned char *so; /* Enter standout (inverse) mode */
388 unsigned char *se; /* Exit standout mode */
390 unsigned char *us; /* Enter underline mode */
391 unsigned char *ue; /* Exit underline mode */
392 unsigned char *uc; /* Single time underline character */
394 int ms; /* Ok to move when in standout/underline mode */
396 unsigned char *mb; /* Enter blinking mode */
397 unsigned char *md; /* Enter bold mode */
398 unsigned char *mh; /* Enter dim mode */
399 unsigned char *mr; /* Enter inverse mode */
400 unsigned char *me; /* Exit above modes */
402 unsigned char *Sb; /* Set background color */
403 unsigned char *Sf; /* Set foregrond color */
404 int ut; /* Screen erases with background color */
406 int da, db; /* Extra lines exist above, below */
407 unsigned char *al, *dl, *AL, *DL; /* Insert/delete lines */
408 unsigned char *cs; /* Set scrolling region */
409 int rr; /* Set for scrolling region relative addressing */
410 unsigned char *sf, *SF, *sr, *SR; /* Scroll */
412 unsigned char *dm, *dc, *DC, *ed; /* Delete characters */
413 unsigned char *im, *ic, *IC, *ip, *ei; /* Insert characters */
414 int mi; /* Set if ok to move while in insert mode */
416 unsigned char *bs; /* Move cursor left 1 */
418 unsigned char *lf; /* Move cursor down 1 */
420 unsigned char *up; /* Move cursor up 1 */
422 unsigned char *nd; /* Move cursor right 1 */
424 unsigned char *ta; /* Move cursor to next tab stop */
426 unsigned char *bt; /* Move cursor to previous tab stop */
428 int tw; /* Tab width */
430 unsigned char *ho; /* Home cursor to upper left */
432 unsigned char *ll; /* Home cursor to lower left */
434 unsigned char *cr; /* Move cursor to left edge */
436 unsigned char *RI; /* Move cursor right n */
438 unsigned char *LE; /* Move cursor left n */
440 unsigned char *UP; /* Move cursor up n */
442 unsigned char *DO; /* Move cursor down n */
444 unsigned char *ch; /* Set cursor column */
446 unsigned char *cv; /* Set cursor row */
448 unsigned char *cV; /* Goto beginning of specified line */
450 unsigned char *cm; /* Set cursor row and column */
453 unsigned char *ce; /* Clear to end of line */
456 /* Basic abilities */
457 int scroll; /* Set to use scrolling */
458 int insdel; /* Set to use insert/delete within line */
460 /* Current state of terminal */
461 int *scrn; /* Characters on screen */
462 int *attr; /* Attributes on screen */
463 int x, y; /* Current cursor position (-1 for unknown) */
464 int top, bot; /* Current scrolling region */
465 int attrib; /* Current character attributes */
466 int ins; /* Set if we're in insert mode */
468 int *updtab; /* Dirty lines table */
470 int avattr; /* Bits set for available attributes */
471 int *sary; /* Scroll buffer array */
473 int *compose; /* Line compose buffer */
474 int *ofst; /* stuff for magic */
483 unsigned char *value;
487 unsigned char *tbuf; /* Termcap entry loaded here */
489 struct sortentry *sort; /* Pointers to each capability stored in here */
490 int sortlen; /* Number of capabilities */
492 unsigned char *abuf; /* For terminfo compatible version */
493 unsigned char *abufp;
495 int div; /* tenths of MS per char */
496 int baud; /* Baud rate */
497 unsigned char *pad; /* Padding string or NULL to use NUL */
498 void (*out) (unsigned char *, unsigned char); /* Character output routine */
499 void *outptr; /* First arg passed to output routine. Second
500 arg is character to write */
501 int dopadding; /* Set if pad characters should be used */
502 const char *paste_on; /* Enable bracketed paste mode */
503 const char *paste_off; /* Disable bracketed paste mode */
508 int (*pfunc) (); /* Func which gets called when RTN is hit */
509 int (*abrt) (); /* Func which gets called when window is aborted */
510 int (*tab) (); /* Func which gets called when TAB is hit */
511 unsigned char *prompt; /* Prompt string */
512 int promptlen; /* Width of prompt string */
513 int promptofst; /* Prompt scroll offset */
514 B *hist; /* History buffer */
515 void *object; /* Object */
523 W *parent; /* Window we're in */
524 int (*func) (); /* Func. which gets called when key is hit */
527 unsigned char *prompt; /* Prompt string */
528 int promptlen; /* Width of prompt string */
529 int promptofst; /* Prompt scroll offset */
533 typedef struct mpx MPX;
535 int ackfd; /* Packetizer response descriptor */
536 int kpid; /* Packetizer process id */
537 int pid; /* Client process id */
538 void (*func) (); /* Function to call when read occures */
539 void *object; /* First arg to pass to function */
540 void (*die) (); /* Function: call when client dies or closes */
546 unsigned char *stalin; /* Status line info */
547 unsigned char *staright;
548 int staon; /* Set if status line was on */
549 long prevline; /* Previous cursor line number */
550 int changed; /* Previous changed value */
551 B *prev_b; /* Previous buffer (we need to update status line on nbuf/pbuf) */
556 int what; /* 0 repeat, >0 append n chars */
557 long start; /* Cursor search position */
558 long disp; /* Original cursor position */
559 int wrap_flag; /* Wrap flag */
563 IREC irecs; /* Linked list of positions */
564 unsigned char *pattern; /* Search pattern string */
565 unsigned char *prompt; /* Prompt (usually same as pattern unless utf-8/byte conversion) */
566 int ofst; /* Offset in pattern past prompt */
567 int dir; /* 0=fwrd, 1=bkwd */
568 int quote; /* Set to quote next char */
576 int changed; /* Status of modified flag before this record */
577 long where; /* Buffer address of this record */
578 long len; /* Length of insert or delete */
579 int del; /* Set if this is a delete */
580 B *big; /* Set to buffer containing a large amount of deleted data */
581 unsigned char *small; /* Set to malloc block containg a small amount of deleted data */
595 LINK(SRCHREC) link; /* Linked list of search & replace locations */
596 int yn; /* Did we replace? */
597 int wrap_flag; /* Did we wrap? */
598 long addr; /* Where we were */
602 unsigned char *pattern; /* Search pattern */
603 unsigned char *replacement; /* Replacement string */
604 int backwards; /* Set if search should go backwards */
605 int ignore; /* Set if we should ignore case */
606 int repeat; /* Set with repeat count (or -1 for no repeat count) */
607 int replace; /* Set if this is search & replace */
608 int rest; /* Set to do remainder of search & replace w/o query */
609 unsigned char *entire; /* Entire matched string */
610 unsigned char *pieces[26]; /* Peices of the matched string */
611 int flg; /* Set after prompted for first replace */
612 SRCHREC recs; /* Search & replace position history */
613 P *markb, *markk; /* Original marks */
614 P *wrap_p; /* Wrap point */
615 int wrap_flag; /* Set if we've wrapped */
616 int valid; /* Set if original marks are a valid block */
617 long addr; /* Addr of last replacement or -1 for none */
618 int block_restrict; /* Search restricted to marked block */
626 VPAGE *next; /* Next page with same hash value */
627 VFILE *vfile; /* Owner vfile */
628 long addr; /* Address of this page */
629 int count; /* Reference count */
630 int dirty; /* Set if page changed */
631 unsigned char *data; /* The data in the page */
637 LINK(VFILE) link; /* Doubly linked list of vfiles */
638 long size; /* Number of bytes in physical file */
639 long alloc; /* Number of bytes allocated to file */
640 int fd; /* Physical file */
641 int writeable; /* Set if we can write */
642 unsigned char *name; /* File name. 0 if unnamed */
643 int flags; /* Set if this is only a temporary file */
646 unsigned char *vpage1; /* Page address */
647 long addr; /* File address of above page */
650 unsigned char *bufp; /* Buffer pointer */
651 unsigned char *vpage; /* Buffer pointer points in here */
652 int left; /* Space left in bufp */
653 int lv; /* Amount of append space at end of buffer */