1 /*
2  *	device-independent TTY interface for JOE
3  *	Copyright
4  *		(C) 1992 Joseph H. Allen
5  *
6  *	This file is part of JOE (Joe's Own Editor)
7  */
8 #ifndef _JOE_SCRN_H
9 #define _JOE_SCRN_H 1
10 
11 #ifdef EXTERN
12 __IDSTRING(rcsid_scrn_h, "$MirOS: contrib/code/jupp/scrn.h,v 1.12 2018/01/08 00:56:27 tg Exp $");
13 #endif
14 
15 #include "tty.h"		/* ttputc() */
16 
17 extern int skiptop;
18 
19 /* SCRN *nopen(void);
20  *
21  * Open the screen (sets TTY mode so that screen may be used immediatly after
22  * the 'nopen').
23  */
24 SCRN *nopen(CAP *cap);
25 
26 /* void nresize(SCRN *t,int w,int h);
27  *
28  * Change size of screen.  For example, call this when you find out that
29  * the Xterm changed size.
30  */
31 void nresize(SCRN *t, int w, int h);
32 
33 /* void nredraw(SCRN *t);
34  *
35  * Invalidate all state variables for the terminal.  This way, everything gets
36  * redrawn.
37  */
38 void nredraw(SCRN *t);
39 
40 void npartial(SCRN *t);
41 void nescape(SCRN *t);
42 void nreturn(SCRN *t);
43 
44 /* void nclose(SCRN *t);
45  *
46  * Close the screen and restore TTY to initial state.
47  *
48  * if 'flg' is set, tclose doesn't mess with the signals.
49  */
50 void nclose(SCRN *t);
51 
52 /* int cpos(SCRN *t,int x,int y);
53  *
54  * Set cursor position
55  */
56 int cpos(register SCRN *t, register int x, register int y);
57 
58 /* int attr(SCRN *t,int a);
59  *
60  * Set attributes
61  */
62 int set_attr(SCRN *t, int c);
63 
64 /* Encode character as utf8 */
65 void utf8_putc(int c);
66 
67 /* void outatr(SCRN *t,int *scrn,int *attr,int x,int y,int c,int a);
68  *
69  * Output a character at the given screen cooridinate.  The cursor position
70  * after this function is executed is indeterminate.
71  */
72 
73 /* Character attribute bits */
74 
75 #define INVERSE		 256
76 #define UNDERLINE	 512
77 #define BOLD		1024
78 #define BLINK		2048
79 #define DIM		4096
80 #define AT_MASK		(INVERSE+UNDERLINE+BOLD+BLINK+DIM)
81 
82 #define BG_SHIFT 13
83 #define BG_VALUE (7<<BG_SHIFT)
84 #define BG_NOT_DEFAULT (8<<BG_SHIFT)
85 #define BG_MASK (15<<BG_SHIFT)
86 
87 #define BG_DEFAULT (0<<BG_SHIFT) /* default */
88 #define BG_BLACK (8<<BG_SHIFT)
89 #define BG_RED (9<<BG_SHIFT)
90 #define BG_GREEN (10<<BG_SHIFT)
91 #define BG_YELLOW (11<<BG_SHIFT)
92 #define BG_BLUE (12<<BG_SHIFT)
93 #define BG_MAGENTA (13<<BG_SHIFT)
94 #define BG_CYAN (14<<BG_SHIFT)
95 #define BG_WHITE (15<<BG_SHIFT)
96 
97 #define FG_SHIFT 17
98 #define FG_VALUE (7<<FG_SHIFT)
99 #define FG_NOT_DEFAULT (8<<FG_SHIFT)
100 #define FG_MASK (15<<FG_SHIFT)
101 
102 #define FG_DEFAULT (0<<FG_SHIFT)
103 #define FG_WHITE (8<<FG_SHIFT) /* default */
104 #define FG_CYAN (9<<FG_SHIFT)
105 #define FG_MAGENTA (10<<FG_SHIFT)
106 #define FG_BLUE (11<<FG_SHIFT)
107 #define FG_YELLOW (12<<FG_SHIFT)
108 #define FG_GREEN (13<<FG_SHIFT)
109 #define FG_RED (14<<FG_SHIFT)
110 #define FG_BLACK (15<<FG_SHIFT)
111 
112 #define HAS_COMBINING 0x200000
113 
114 void outatr(struct charmap *map,SCRN *t,int *scrn,int *attrf,int xx,int yy,int c,int a);
115 void outatr_help(SCRN *, int *, int *, int, int, int, int);
116 
117 /* int eraeol(SCRN *t,int x,int y);
118  *
119  * Erase from screen coordinate to end of line.
120  */
121 int eraeol(SCRN *t, int x, int y);
122 
123 /* void nscrlup(SCRN *t,int top,int bot,int amnt);
124  *
125  * Buffered scroll request.  Request that some lines up.  'top' and 'bot'
126  * indicate which lines to scroll.  'bot' is the last line to scroll + 1.
127  * 'amnt' is distance in lines to scroll.
128  */
129 void nscrlup(SCRN *t, int top, int bot, int amnt);
130 
131 /* void nscrldn(SCRN *t,int top,int bot,int amnt);
132  *
133  * Buffered scroll request.  Scroll some lines down.  'top' and 'bot'
134  * indicate which lines to scroll.  'bot' is the last line to scroll + 1.
135  * 'amnt' is distance in lines to scroll.
136  */
137 void nscrldn(SCRN *t, int top, int bot, int amnt);
138 
139 /* void nscroll(SCRN *t);
140  *
141  * Execute buffered scroll requests
142  */
143 void nscroll(SCRN *t);
144 
145 /* void magic(SCRN *t,int y,int *cur,int *new);
146  *
147  * Figure out and execute line shifting
148  */
149 void magic(SCRN *t, int y, int *cs, int *ca, int *s, int *a,int placex);
150 
151 int clrins(SCRN *t);
152 
153 int meta_color(unsigned char *s);
154 
155 /* Generate a field */
156 void genfield(SCRN *t,int *scrn,int *attr,int x,int y,int ofst,unsigned char *s,int len,int atr,int width,int flg,int *fmt);
157 
158 /* Column width of a string takes into account utf-8) */
159 int txtwidth(unsigned char *s,int len);
160 
161 /* Generate a field: formatted */
162 void genfmt(SCRN *t, int x, int y, int ofst, const unsigned char *s, int flg);
163 
164 /* Column width of formatted string */
165 int fmtlen(const unsigned char *s);
166 
167 /* Offset within formatted string of particular column */
168 int fmtpos(unsigned char *s, int goal);
169 
170 #endif
171