5 __IDSTRING(rcsid_types_h, "$MirOS: contrib/code/jupp/types.h,v 1.18 2017/12/02 18:33:25 tg Exp $");
8 /* Prefix to make string constants unsigned */
9 #define UC (const unsigned char *)
10 #define US (unsigned char *)
12 #define LINK(type) struct { type *next; type *prev; }
16 #define FITHEIGHT 4 /* Minimum text window height */
18 #define NPROC 8 /* Number of processes we keep track of */
20 #define INC 16 /* Pages to allocate each time */
24 #define TYPEMENU 0x0800
28 typedef struct header H;
29 typedef struct buffer B;
30 typedef struct point P;
31 typedef struct options OPTIONS;
32 typedef struct macro MACRO;
33 typedef struct cmd CMD;
34 typedef struct entry HENTRY;
35 typedef struct hash HASH;
36 typedef struct kmap KMAP;
37 typedef struct kbd KBD;
38 typedef struct key KEY;
39 typedef struct watom WATOM;
40 typedef struct screen SCREEN;
41 typedef struct window W;
42 typedef struct base BASE;
44 typedef struct menu MENU;
45 typedef struct scrn SCRN;
46 typedef struct cap CAP;
48 typedef struct stditem STDITEM;
49 typedef struct query QW;
51 typedef struct irec IREC;
52 typedef struct undo UNDO;
53 typedef struct undorec UNDOREC;
54 typedef struct search SRCH;
55 typedef struct srchrec SRCHREC;
56 typedef struct vpage VPAGE;
57 typedef struct vfile VFILE;
61 LINK(H) link; /* LINK ??? */
69 LINK(P) link; /* ?LINK ??? */
73 unsigned char *ptr; /* ??? */
78 long col; /* current column */
80 int valcol; /* bool: is col valid? */
88 unsigned char *name_regex;
89 unsigned char *contents_regex;
98 unsigned char *context;
107 int highlight; /* Set to enable highlighting */
108 unsigned char *syntax_name; /* Name of syntax to use */
109 struct high_syntax *syntax; /* Syntax for highlighting (load_dfa() from syntax_name happens in setopt()) */
110 unsigned char *map_name; /* Name of character set */
111 struct charmap *charmap; /* Character set */
112 int smarthome; /* Set for smart home key */
113 int indentfirst; /* Smart home goes to indentation point first */
114 int smartbacks; /* Set for smart backspace key */
115 int purify; /* Purify indentation */
116 int picture; /* Picture mode */
117 MACRO *mnew; /* Macro to execute for new files */
118 MACRO *mold; /* Macro to execute for existing files */
119 MACRO *msnew; /* Macro to execute before saving new files */
120 MACRO *msold; /* Macro to execute before saving existing files */
121 int vispace; /* Set to make spaces visible */
122 int hex; /* Hex edit mode */
127 int arg; /* Repeat argument */
128 CMD *cmd; /* Command address */
129 int n; /* Number of steps */
130 int size; /* Malloc size of steps */
131 MACRO **steps; /* Block */
144 unsigned char *name; /* Command name */
145 int flag; /* Execution flags */
146 int (*func) (); /* Function bound to name */
147 MACRO *m; /* Macro bound to name */
148 int arg; /* 0= arg is meaningless, 1= ok */
149 unsigned char *negarg; /* Command to use if arg was negative */
159 long mod_time; /* Last modification time for file */
165 P *marks[11]; /* Bookmarks */
166 OPTIONS o; /* Options */
167 P *oldcur; /* Last cursor position before orphaning */
168 P *oldtop; /* Last top screen position before orphaning */
169 int rdonly; /* Set for read-only */
170 int internal; /* Set for internal buffers */
171 int scratch; /* Set for scratch buffers */
172 int er; /* Error code when file was loaded */
173 pid_t pid; /* Process id */
174 int out; /* fd to write to process */
191 unsigned char *text; /* help text with attributes */
192 unsigned int lines; /* number of lines */
193 struct help *prev; /* previous help screen */
194 struct help *next; /* nex help screen */
195 unsigned char *name; /* context name for context sensitive help */
200 int k; /* Flag: 0=binding, 1=submap */
202 void *bind; /* What key is bound to */
203 KMAP *submap; /* Sub KMAP address (for prefix keys) */
207 /* A map of keycode to command/sub-map bindings */
209 KEY keys[KEYS]; /* KEYs */
212 /** A keyboard handler **/
214 KMAP *curmap; /* Current keymap */
215 KMAP *topmap; /* Top-level keymap */
216 int seq[16]; /* Current sequence of keys */
217 int x; /* What we're up to */
222 unsigned char *context; /* Context name */
223 void (*disp) (); /* Display window */
224 void (*follow) (); /* Called to have window follow cursor */
225 int (*abort) (); /* Common user functions */
228 void (*resize) (); /* Called when window changed size */
229 void (*move) (); /* Called when window moved */
230 void (*ins) (); /* Called on line insertions */
231 void (*del) (); /* Called on line deletions */
232 int what; /* Type of this thing */
236 SCRN *t; /* Screen data on this screen is output to */
238 int wind; /* Number of help lines on this screen */
240 W *topwin; /* Top-most window showing on screen */
241 W *curwin; /* Window cursor is in */
243 int w, h; /* Width and height of this screen */
247 LINK(W) link; /* Linked list of windows in order they
248 appear on the screen */
250 SCREEN *t; /* Screen this thing is on */
252 int x, y, w, h; /* Position and size of window */
253 /* Currently, x = 0, w = width of screen. */
254 /* y == -1 if window is not on screen */
256 int ny, nh; /* Temporary values for wfit */
258 int reqh; /* Requested new height or 0 for same */
259 /* This is an argument for wfit */
261 int fixed; /* If this is zero, use 'hh'. If not, this
262 is a fixed size window and this variable
265 int hh; /* Height window would be on a screen with
266 1000 lines. When the screen size changes
267 this is used to calculate the window's
270 W *win; /* Window this one operates on */
271 W *main; /* Main window of this family */
272 W *orgwin; /* Window where space from this window came */
273 int curx, cury; /* Cursor position within window */
274 KBD *kbd; /* Keyboard handler for this window */
275 WATOM *watom; /* The type of this window */
276 void *object; /* Object which inherits this */
278 union { /* FIXME: instead of void *object we should */
279 BW *bw; /* use this union to get strict type checking */
280 PW *pw; /* from C compiler (need to check and change */
281 QW *qw; /* all of the occurrencies of ->object) */
288 const unsigned char *msgt; /* Message at top of window */
289 const unsigned char *msgb; /* Message at bottom of window */
290 const unsigned char *huh; /* Name of window for context sensitive hlp */
291 int *notify; /* Address of kill notification flag */
294 /* Anything which goes in window.object must start like this: */
312 int top_changed; /* Top changed */
316 W *parent; /* Window we're in */
317 unsigned char **list; /* List of items */
318 int top; /* First item on screen */
319 int cursor; /* Item cursor is on */
320 int width; /* Width of widest item, up to 'w' max */
321 int perline; /* Number of items on each line */
322 int nitems; /* No. items in list */
323 int saved_co; /* Saved #columns of screen */
324 SCREEN *t; /* Screen we're on */
326 int (*abrt) (); /* Abort callback function */
327 int (*func) (); /* Return callback function */
328 int (*backs) (); /* Backspace callback function */
337 /* Each terminal has one of these */
342 int li; /* Height of screen */
343 int co; /* Width of screen */
344 short *scrn; /* Buffer */
347 int *updtab; /* Lines which need to be updated */
348 /* HIGHLIGHT_STATE *syntab; */ /* Syntax highlight state at start of each line */
356 CAP *cap; /* Termcap/Terminfo data */
358 int li; /* Screen height */
359 int co; /* Screen width */
361 unsigned char *ti; /* Initialization string */
362 unsigned char *cl; /* Home and clear screen... really an
364 unsigned char *cd; /* Clear to end of screen */
365 unsigned char *te; /* Restoration string */
367 int haz; /* Terminal can't print ~s */
368 int os; /* Terminal overstrikes */
369 int eo; /* Can use blank to erase even if os */
370 int ul; /* _ overstrikes */
371 int am; /* Terminal has autowrap, but not magicwrap */
372 int xn; /* Terminal has magicwrap */
374 unsigned char *so; /* Enter standout (inverse) mode */
375 unsigned char *se; /* Exit standout mode */
377 unsigned char *us; /* Enter underline mode */
378 unsigned char *ue; /* Exit underline mode */
379 unsigned char *uc; /* Single time underline character */
381 int ms; /* Ok to move when in standout/underline mode */
383 unsigned char *mb; /* Enter blinking mode */
384 unsigned char *md; /* Enter bold mode */
385 unsigned char *mh; /* Enter dim mode */
386 unsigned char *mr; /* Enter inverse mode */
387 unsigned char *me; /* Exit above modes */
389 unsigned char *Sb; /* Set background color */
390 unsigned char *Sf; /* Set foregrond color */
391 int ut; /* Screen erases with background color */
393 int da, db; /* Extra lines exist above, below */
394 unsigned char *al, *dl, *AL, *DL; /* Insert/delete lines */
395 unsigned char *cs; /* Set scrolling region */
396 int rr; /* Set for scrolling region relative addressing */
397 unsigned char *sf, *SF, *sr, *SR; /* Scroll */
399 unsigned char *dm, *dc, *DC, *ed; /* Delete characters */
400 unsigned char *im, *ic, *IC, *ip, *ei; /* Insert characters */
401 int mi; /* Set if ok to move while in insert mode */
403 unsigned char *bs; /* Move cursor left 1 */
405 unsigned char *lf; /* Move cursor down 1 */
407 unsigned char *up; /* Move cursor up 1 */
409 unsigned char *nd; /* Move cursor right 1 */
411 unsigned char *ta; /* Move cursor to next tab stop */
413 unsigned char *bt; /* Move cursor to previous tab stop */
415 int tw; /* Tab width */
417 unsigned char *ho; /* Home cursor to upper left */
419 unsigned char *ll; /* Home cursor to lower left */
421 unsigned char *cr; /* Move cursor to left edge */
423 unsigned char *RI; /* Move cursor right n */
425 unsigned char *LE; /* Move cursor left n */
427 unsigned char *UP; /* Move cursor up n */
429 unsigned char *DO; /* Move cursor down n */
431 unsigned char *ch; /* Set cursor column */
433 unsigned char *cv; /* Set cursor row */
435 unsigned char *cV; /* Goto beginning of specified line */
437 unsigned char *cm; /* Set cursor row and column */
440 unsigned char *ce; /* Clear to end of line */
443 /* Basic abilities */
444 int scroll; /* Set to use scrolling */
445 int insdel; /* Set to use insert/delete within line */
447 /* Current state of terminal */
448 int *scrn; /* Characters on screen */
449 int *attr; /* Attributes on screen */
450 int x, y; /* Current cursor position (-1 for unknown) */
451 int top, bot; /* Current scrolling region */
452 int attrib; /* Current character attributes */
453 int ins; /* Set if we're in insert mode */
455 int *updtab; /* Dirty lines table */
457 int avattr; /* Bits set for available attributes */
458 int *sary; /* Scroll buffer array */
460 int *compose; /* Line compose buffer */
461 int *ofst; /* stuff for magic */
470 unsigned char *value;
474 unsigned char *tbuf; /* Termcap entry loaded here */
476 struct sortentry *sort; /* Pointers to each capability stored in here */
477 int sortlen; /* Number of capabilities */
479 unsigned char *abuf; /* For terminfo compatible version */
480 unsigned char *abufp;
482 int div; /* tenths of MS per char */
483 int baud; /* Baud rate */
484 unsigned char *pad; /* Padding string or NULL to use NUL */
485 void (*out) (unsigned char *, unsigned char); /* Character output routine */
486 void *outptr; /* First arg passed to output routine. Second
487 arg is character to write */
488 int dopadding; /* Set if pad characters should be used */
489 const char *paste_on; /* Enable bracketed paste mode */
490 const char *paste_off; /* Disable bracketed paste mode */
495 int (*pfunc) (); /* Func which gets called when RTN is hit */
496 int (*abrt) (); /* Func which gets called when window is aborted */
497 int (*tab) (); /* Func which gets called when TAB is hit */
498 unsigned char *prompt; /* Prompt string */
499 int promptlen; /* Width of prompt string */
500 int promptofst; /* Prompt scroll offset */
501 B *hist; /* History buffer */
502 void *object; /* Object */
510 W *parent; /* Window we're in */
511 int (*func) (); /* Func. which gets called when key is hit */
514 unsigned char *prompt; /* Prompt string */
515 int promptlen; /* Width of prompt string */
516 int promptofst; /* Prompt scroll offset */
520 typedef struct mpx MPX;
522 int ackfd; /* Packetizer response descriptor */
523 int kpid; /* Packetizer process id */
524 int pid; /* Client process id */
525 void (*func) (); /* Function to call when read occures */
526 void *object; /* First arg to pass to function */
527 void (*die) (); /* Function: call when client dies or closes */
533 unsigned char *stalin; /* Status line info */
534 unsigned char *staright;
535 int staon; /* Set if status line was on */
536 long prevline; /* Previous cursor line number */
537 int changed; /* Previous changed value */
538 B *prev_b; /* Previous buffer (we need to update status line on nbuf/pbuf) */
543 int what; /* 0 repeat, >0 append n chars */
544 long start; /* Cursor search position */
545 long disp; /* Original cursor position */
546 int wrap_flag; /* Wrap flag */
550 IREC irecs; /* Linked list of positions */
551 unsigned char *pattern; /* Search pattern string */
552 unsigned char *prompt; /* Prompt (usually same as pattern unless utf-8/byte conversion) */
553 int ofst; /* Offset in pattern past prompt */
554 int dir; /* 0=fwrd, 1=bkwd */
555 int quote; /* Set to quote next char */
563 int changed; /* Status of modified flag before this record */
564 long where; /* Buffer address of this record */
565 long len; /* Length of insert or delete */
566 int del; /* Set if this is a delete */
567 B *big; /* Set to buffer containing a large amount of deleted data */
568 unsigned char *small; /* Set to malloc block containg a small amount of deleted data */
582 LINK(SRCHREC) link; /* Linked list of search & replace locations */
583 int yn; /* Did we replace? */
584 int wrap_flag; /* Did we wrap? */
585 long addr; /* Where we were */
589 unsigned char *pattern; /* Search pattern */
590 unsigned char *replacement; /* Replacement string */
591 int backwards; /* Set if search should go backwards */
592 int ignore; /* Set if we should ignore case */
593 int repeat; /* Set with repeat count (or -1 for no repeat count) */
594 int replace; /* Set if this is search & replace */
595 int rest; /* Set to do remainder of search & replace w/o query */
596 unsigned char *entire; /* Entire matched string */
597 unsigned char *pieces[26]; /* Peices of the matched string */
598 int flg; /* Set after prompted for first replace */
599 SRCHREC recs; /* Search & replace position history */
600 P *markb, *markk; /* Original marks */
601 P *wrap_p; /* Wrap point */
602 int wrap_flag; /* Set if we've wrapped */
603 int valid; /* Set if original marks are a valid block */
604 long addr; /* Addr of last replacement or -1 for none */
605 int block_restrict; /* Search restricted to marked block */
613 VPAGE *next; /* Next page with same hash value */
614 VFILE *vfile; /* Owner vfile */
615 long addr; /* Address of this page */
616 int count; /* Reference count */
617 int dirty; /* Set if page changed */
618 unsigned char *data; /* The data in the page */
624 LINK(VFILE) link; /* Doubly linked list of vfiles */
625 long size; /* Number of bytes in physical file */
626 long alloc; /* Number of bytes allocated to file */
627 int fd; /* Physical file */
628 int writeable; /* Set if we can write */
629 unsigned char *name; /* File name. 0 if unnamed */
630 int flags; /* Set if this is only a temporary file */
633 unsigned char *vpage1; /* Page address */
634 long addr; /* File address of above page */
637 unsigned char *bufp; /* Buffer pointer */
638 unsigned char *vpage; /* Buffer pointer points in here */
639 int left; /* Space left in bufp */
640 int lv; /* Amount of append space at end of buffer */