5 __IDSTRING(rcsid_types_h, "$MirOS: contrib/code/jupp/types.h,v 1.28 2017/12/08 02:46:46 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; }
20 #define FITHEIGHT 4 /* Minimum text window height */
22 #define NPROC 8 /* Number of processes we keep track of */
24 #define INC 16 /* Pages to allocate each time */
28 #define TYPEMENU 0x0800
31 /* polymorph function pointers, which do not use compiler type checking */
32 #ifndef GCC_Wstrict_prototypes
33 typedef int jpoly_int();
34 typedef void jpoly_void();
36 /* same content as above, but system header */
40 typedef struct header H;
41 typedef struct buffer B;
42 typedef struct point P;
43 typedef struct options OPTIONS;
44 typedef struct macro MACRO;
45 typedef struct cmd CMD;
46 typedef struct hentry HENTRY;
47 typedef struct hash HASH;
48 typedef struct kmap KMAP;
49 typedef struct kbd KBD;
50 typedef struct key KEY;
51 typedef struct watom WATOM;
52 typedef struct screen SCREEN;
53 typedef struct window W;
54 typedef struct base BASE;
56 typedef struct menu MENU;
57 typedef struct scrn SCRN;
58 typedef struct cap CAP;
60 typedef struct stditem STDITEM;
61 typedef struct query QW;
63 typedef struct irec IREC;
64 typedef struct undo UNDO;
65 typedef struct undorec UNDOREC;
66 typedef struct search SRCH;
67 typedef struct srchrec SRCHREC;
68 typedef struct vpage VPAGE;
69 typedef struct vfile VFILE;
80 LINK(H) link; /* LINK ??? */
88 LINK(P) link; /* ?LINK ??? */
92 unsigned char *ptr; /* ??? */
97 long col; /* current column */
99 int valcol; /* bool: is col valid? */
107 unsigned char *name_regex;
108 unsigned char *contents_regex;
117 unsigned char *context;
126 int highlight; /* Set to enable highlighting */
127 unsigned char *syntax_name; /* Name of syntax to use */
128 struct high_syntax *syntax; /* Syntax for highlighting (load_dfa() from syntax_name happens in setopt()) */
129 unsigned char *map_name; /* Name of character set */
130 struct charmap *charmap; /* Character set */
131 int smarthome; /* Set for smart home key */
132 int indentfirst; /* Smart home goes to indentation point first */
133 int smartbacks; /* Set for smart backspace key */
134 int purify; /* Purify indentation */
135 int picture; /* Picture mode */
136 MACRO *mnew; /* Macro to execute for new files */
137 MACRO *mold; /* Macro to execute for existing files */
138 MACRO *msnew; /* Macro to execute before saving new files */
139 MACRO *msold; /* Macro to execute before saving existing files */
140 int vispace; /* Set to make spaces visible */
141 int hex; /* Hex edit mode */
146 int arg; /* Repeat argument */
147 CMD *cmd; /* Command address */
148 int n; /* Number of steps */
149 int size; /* Malloc size of steps */
150 MACRO **steps; /* Block */
163 const unsigned char *name; /* Command name */
164 const unsigned char *negarg; /* Command to use if arg was negative */
165 jpoly_int *func; /* Function bound to name */
166 MACRO *m; /* Macro bound to name */
167 int flag; /* Execution flags */
168 int arg; /* 0= arg is meaningless, 1= ok */
178 long mod_time; /* Last modification time for file */
184 P *marks[11]; /* Bookmarks */
185 OPTIONS o; /* Options */
186 P *oldcur; /* Last cursor position before orphaning */
187 P *oldtop; /* Last top screen position before orphaning */
188 int rdonly; /* Set for read-only */
189 int internal; /* Set for internal buffers */
190 int scratch; /* Set for scratch buffers */
191 int er; /* Error code when file was loaded */
192 pid_t pid; /* Process id */
193 int out; /* fd to write to process */
198 const unsigned char *name;
210 unsigned char *text; /* help text with attributes */
211 unsigned int lines; /* number of lines */
212 struct help *prev; /* previous help screen */
213 struct help *next; /* nex help screen */
214 unsigned char *name; /* context name for context sensitive help */
219 int k; /* Flag: 0=binding, 1=submap */
221 void *bind; /* What key is bound to */
222 KMAP *submap; /* Sub KMAP address (for prefix keys) */
226 /* A map of keycode to command/sub-map bindings */
228 KEY keys[KEYS]; /* KEYs */
231 /** A keyboard handler **/
233 KMAP *curmap; /* Current keymap */
234 KMAP *topmap; /* Top-level keymap */
235 int seq[16]; /* Current sequence of keys */
236 int x; /* What we're up to */
241 unsigned char *context; /* Context name */
242 void (*disp)(jobject, int); /* Display window */
243 void (*follow)(jobject); /* Display window */
244 int (*abort)(jobject); /* Common user functions */
246 int (*type)(jobject, int);
248 void (*resize)(jobject, int, int); /* window changed size */
249 void (*move)(jobject, int, int); /* window moved */
250 void (*ins)(BW *, B *, long, long, int); /* on line insertions */
251 void (*del)(BW *, B *, long, long, int); /* on line deletions */
252 int what; /* Type of this thing */
256 SCRN *t; /* Screen data on this screen is output to */
258 int wind; /* Number of help lines on this screen */
260 W *topwin; /* Top-most window showing on screen */
261 W *curwin; /* Window cursor is in */
263 int w, h; /* Width and height of this screen */
267 LINK(W) link; /* Linked list of windows in order they
268 appear on the screen */
270 SCREEN *t; /* Screen this thing is on */
272 int x, y, w, h; /* Position and size of window */
273 /* Currently, x = 0, w = width of screen. */
274 /* y == -1 if window is not on screen */
276 int ny, nh; /* Temporary values for wfit */
278 int reqh; /* Requested new height or 0 for same */
279 /* This is an argument for wfit */
281 int fixed; /* If this is zero, use 'hh'. If not, this
282 is a fixed size window and this variable
285 int hh; /* Height window would be on a screen with
286 1000 lines. When the screen size changes
287 this is used to calculate the window's
290 W *win; /* Window this one operates on */
291 W *main; /* Main window of this family */
292 W *orgwin; /* Window where space from this window came */
293 int curx, cury; /* Cursor position within window */
294 KBD *kbd; /* Keyboard handler for this window */
295 WATOM *watom; /* The type of this window */
296 jobject object; /* Object which inherits this */
298 const unsigned char *msgt; /* Message at top of window */
299 const unsigned char *msgb; /* Message at bottom of window */
300 const unsigned char *huh; /* Name of window for context sensitive hlp */
301 int *notify; /* Address of kill notification flag */
304 /* Anything which goes in window.object must start like this: */
322 int top_changed; /* Top changed */
326 W *parent; /* Window we're in */
327 unsigned char **list; /* List of items */
328 int top; /* First item on screen */
329 int cursor; /* Item cursor is on */
330 int width; /* Width of widest item, up to 'w' max */
331 int perline; /* Number of items on each line */
332 int nitems; /* No. items in list */
333 int saved_co; /* Saved #columns of screen */
334 SCREEN *t; /* Screen we're on */
336 jpoly_int *abrt; /* Abort callback function */
337 jpoly_int *func; /* Return callback function */
338 jpoly_int *backs; /* Backspace callback function */
347 /* Each terminal has one of these */
349 CAP *cap; /* Termcap/Terminfo data */
351 int li; /* Screen height */
352 int co; /* Screen width */
354 const unsigned char *ti; /* Initialisation string */
355 const unsigned char *cl; /* Home and clear screen... really an
357 const unsigned char *cd; /* Clear to end of screen */
358 const unsigned char *te; /* Restoration string */
360 int haz; /* Terminal can't print ~s */
361 int os; /* Terminal overstrikes */
362 int eo; /* Can use blank to erase even if os */
363 int ul; /* _ overstrikes */
364 int am; /* Terminal has autowrap, but not magicwrap */
365 int xn; /* Terminal has magicwrap */
367 const unsigned char *so; /* Enter standout (inverse) mode */
368 const unsigned char *se; /* Exit standout mode */
370 const unsigned char *us; /* Enter underline mode */
371 const unsigned char *ue; /* Exit underline mode */
372 const unsigned char *uc; /* Single time underline character */
374 int ms; /* Ok to move when in standout/underline mode */
376 const unsigned char *mb; /* Enter blinking mode */
377 const unsigned char *md; /* Enter bold mode */
378 const unsigned char *mh; /* Enter dim mode */
379 const unsigned char *mr; /* Enter inverse mode */
380 const unsigned char *me; /* Exit above modes */
382 const unsigned char *Sb; /* Set background color */
383 const unsigned char *Sf; /* Set foregrond color */
384 int ut; /* Screen erases with background color */
386 int da, db; /* Extra lines exist above, below */
387 const unsigned char *al, *dl, *AL, *DL; /* Insert/delete lines */
388 const unsigned char *cs; /* Set scrolling region */
389 int rr; /* Set for scrolling region relative addressing */
390 const unsigned char *sf, *SF, *sr, *SR; /* Scroll */
392 const unsigned char *dm, *dc, *DC, *ed; /* Delete characters */
393 const unsigned char *im, *ic, *IC, *ip, *ei; /* Insert characters */
394 int mi; /* Set if ok to move while in insert mode */
396 const unsigned char *bs; /* Move cursor left 1 */
398 const unsigned char *lf; /* Move cursor down 1 */
400 const unsigned char *up; /* Move cursor up 1 */
402 const unsigned char *nd; /* Move cursor right 1 */
404 const unsigned char *ta; /* Move cursor to next tab stop */
406 const unsigned char *bt; /* Move cursor to previous tab stop */
408 int tw; /* Tab width */
410 const unsigned char *ho; /* Home cursor to upper left */
412 const unsigned char *ll; /* Home cursor to lower left */
414 const unsigned char *cr; /* Move cursor to left edge */
416 const unsigned char *RI; /* Move cursor right n */
418 const unsigned char *LE; /* Move cursor left n */
420 const unsigned char *UP; /* Move cursor up n */
422 const unsigned char *DO; /* Move cursor down n */
424 const unsigned char *ch; /* Set cursor column */
426 const unsigned char *cv; /* Set cursor row */
428 const unsigned char *cV; /* Goto beginning of specified line */
430 const unsigned char *cm; /* Set cursor row and column */
433 const unsigned char *ce; /* Clear to end of line */
436 /* Basic abilities */
437 int scroll; /* Set to use scrolling */
438 int insdel; /* Set to use insert/delete within line */
440 /* Current state of terminal */
441 int *scrn; /* Characters on screen */
442 int *attr; /* Attributes on screen */
443 int x, y; /* Current cursor position (-1 for unknown) */
444 int top, bot; /* Current scrolling region */
445 int attrib; /* Current character attributes */
446 int ins; /* Set if we're in insert mode */
448 int *updtab; /* Dirty lines table */
450 int avattr; /* Bits set for available attributes */
451 int *sary; /* Scroll buffer array */
453 int *compose; /* Line compose buffer */
454 int *ofst; /* stuff for magic */
455 struct s_hentry *htab;
456 struct s_hentry *ary;
462 unsigned char *value;
466 unsigned char *tbuf; /* Termcap entry loaded here */
468 struct sortentry *sort; /* Pointers to each capability stored in here */
469 int sortlen; /* Number of capabilities */
471 unsigned char *abuf; /* For terminfo compatible version */
472 unsigned char *abufp;
474 int div; /* tenths of MS per char */
475 int baud; /* Baud rate */
476 const unsigned char *pad; /* Padding string or NULL to use NUL */
477 void (*out) (unsigned char *, unsigned char); /* Character output routine */
478 void *outptr; /* First arg passed to output routine. Second
479 arg is character to write */
480 int dopadding; /* Set if pad characters should be used */
481 const char *paste_on; /* Enable bracketed paste mode */
482 const char *paste_off; /* Disable bracketed paste mode */
487 jpoly_int *pfunc; /* Func which gets called when RTN is hit */
488 jpoly_int *abrt; /* Func which gets called when window is aborted */
489 jpoly_int *tab; /* Func which gets called when TAB is hit */
490 unsigned char *prompt; /* Prompt string */
491 int promptlen; /* Width of prompt string */
492 int promptofst; /* Prompt scroll offset */
493 B *hist; /* History buffer */
494 void *object; /* Object */
502 W *parent; /* Window we're in */
503 jpoly_int *func; /* Func. which gets called when key is hit */
506 unsigned char *prompt; /* Prompt string */
507 int promptlen; /* Width of prompt string */
508 int promptofst; /* Prompt scroll offset */
512 typedef struct mpx MPX;
514 int ackfd; /* Packetizer response descriptor */
515 int kpid; /* Packetizer process id */
516 int pid; /* Client process id */
517 jpoly_void *func; /* Function to call when read occures */
518 void *object; /* First arg to pass to function */
519 jpoly_void *die; /* Function: call when client dies or closes */
525 unsigned char *stalin; /* Status line info */
526 unsigned char *staright;
527 int staon; /* Set if status line was on */
528 long prevline; /* Previous cursor line number */
529 int changed; /* Previous changed value */
530 B *prev_b; /* Previous buffer (we need to update status line on nbuf/pbuf) */
535 int what; /* 0 repeat, >0 append n chars */
536 long start; /* Cursor search position */
537 long disp; /* Original cursor position */
538 int wrap_flag; /* Wrap flag */
542 IREC irecs; /* Linked list of positions */
543 unsigned char *pattern; /* Search pattern string */
544 unsigned char *prompt; /* Prompt (usually same as pattern unless utf-8/byte conversion) */
545 int ofst; /* Offset in pattern past prompt */
546 int dir; /* 0=fwrd, 1=bkwd */
547 int quote; /* Set to quote next char */
555 int changed; /* Status of modified flag before this record */
556 long where; /* Buffer address of this record */
557 long len; /* Length of insert or delete */
558 int del; /* Set if this is a delete */
559 B *big; /* Set to buffer containing a large amount of deleted data */
560 unsigned char *small; /* Set to malloc block containg a small amount of deleted data */
574 LINK(SRCHREC) link; /* Linked list of search & replace locations */
575 int yn; /* Did we replace? */
576 int wrap_flag; /* Did we wrap? */
577 long addr; /* Where we were */
581 unsigned char *pattern; /* Search pattern */
582 unsigned char *replacement; /* Replacement string */
583 int backwards; /* Set if search should go backwards */
584 int ignore; /* Set if we should ignore case */
585 int repeat; /* Set with repeat count (or -1 for no repeat count) */
586 int replace; /* Set if this is search & replace */
587 int rest; /* Set to do remainder of search & replace w/o query */
588 unsigned char *entire; /* Entire matched string */
589 unsigned char *pieces[26]; /* Pieces of the matched string */
590 int flg; /* Set after prompted for first replace */
591 SRCHREC recs; /* Search & replace position history */
592 P *markb, *markk; /* Original marks */
593 P *wrap_p; /* Wrap point */
594 int wrap_flag; /* Set if we've wrapped */
595 int valid; /* Set if original marks are a valid block */
596 long addr; /* Addr of last replacement or -1 for none */
597 int block_restrict; /* Search restricted to marked block */
605 VPAGE *next; /* Next page with same hash value */
606 VFILE *vfile; /* Owner vfile */
607 long addr; /* Address of this page */
608 int count; /* Reference count */
609 int dirty; /* Set if page changed */
610 unsigned char *data; /* The data in the page */
616 LINK(VFILE) link; /* Doubly linked list of vfiles */
617 long size; /* Number of bytes in physical file */
618 long alloc; /* Number of bytes allocated to file */
619 int fd; /* Physical file */
620 int writeable; /* Set if we can write */
621 unsigned char *name; /* File name. 0 if unnamed */
622 int flags; /* Set if this is only a temporary file */
625 unsigned char *vpage1; /* Page address */
626 long addr; /* File address of above page */
629 unsigned char *bufp; /* Buffer pointer */
630 unsigned char *vpage; /* Buffer pointer points in here */
631 int left; /* Space left in bufp */
632 int lv; /* Amount of append space at end of buffer */