[523079]: joe / scrn.h  Maximize  Restore  History

Download this file

364 lines (295 with data), 10.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
/*
* Device independant tty interface for JOE
* Copyright
* (C) 1992 Joseph H. Allen
*
* This file is part of JOE (Joe's Own Editor)
*/
#ifndef _JOE_SCRN_H
#define _JOE_SCRN_H 1
struct hentry {
int next;
int loc;
};
/* Each terminal has one of these: terminal capability database */
#ifdef __MSDOS__
struct scrn {
int li; /* Height of screen */
int co; /* Width of screen */
short *scrn; /* Buffer */
int scroll;
int insdel;
int *updtab; /* Lines which need to be updated */
HIGHLIGHT_STATE *syntax;
int *compose;
int *sary;
};
#else
struct scrn {
CAP *cap; /* Termcap/Terminfo data */
int li; /* Screen height */
int co; /* Screen width */
unsigned char *ti; /* Initialization string */
unsigned char *cl; /* Home and clear screen... really an
init. string */
unsigned char *cd; /* Clear to end of screen */
unsigned char *te; /* Restoration string */
int haz; /* Terminal can't print ~s */
int os; /* Terminal overstrikes */
int eo; /* Can use blank to erase even if os */
int ul; /* _ overstrikes */
int am; /* Terminal has autowrap, but not magicwrap */
int xn; /* Terminal has magicwrap */
unsigned char *so; /* Enter standout (inverse) mode */
unsigned char *se; /* Exit standout mode */
unsigned char *us; /* Enter underline mode */
unsigned char *ue; /* Exit underline mode */
unsigned char *uc; /* Single time underline character */
int ms; /* Ok to move when in standout/underline mode */
unsigned char *mb; /* Enter blinking mode */
unsigned char *md; /* Enter bold mode */
unsigned char *mh; /* Enter dim mode */
unsigned char *mr; /* Enter inverse mode */
unsigned char *me; /* Exit above modes */
unsigned char *Sb; /* Set background color */
unsigned char *Sf; /* Set foregrond color */
int Co; /* No. of colors */
int ut; /* Screen erases with background color */
int da, db; /* Extra lines exist above, below */
unsigned char *al, *dl, *AL, *DL; /* Insert/delete lines */
unsigned char *cs; /* Set scrolling region */
int rr; /* Set for scrolling region relative addressing */
unsigned char *sf, *SF, *sr, *SR; /* Scroll */
unsigned char *dm, *dc, *DC, *ed; /* Delete characters */
unsigned char *im, *ic, *IC, *ip, *ei; /* Insert characters */
int mi; /* Set if ok to move while in insert mode */
unsigned char *bs; /* Move cursor left 1 */
int cbs;
unsigned char *lf; /* Move cursor down 1 */
int clf;
unsigned char *up; /* Move cursor up 1 */
int cup;
unsigned char *nd; /* Move cursor right 1 */
unsigned char *ta; /* Move cursor to next tab stop */
int cta;
unsigned char *bt; /* Move cursor to previous tab stop */
int cbt;
int tw; /* Tab width */
unsigned char *ho; /* Home cursor to upper left */
int cho;
unsigned char *ll; /* Home cursor to lower left */
int cll;
unsigned char *cr; /* Move cursor to left edge */
int ccr;
unsigned char *RI; /* Move cursor right n */
int cRI;
unsigned char *LE; /* Move cursor left n */
int cLE;
unsigned char *UP; /* Move cursor up n */
int cUP;
unsigned char *DO; /* Move cursor down n */
int cDO;
unsigned char *ch; /* Set cursor column */
int cch;
unsigned char *cv; /* Set cursor row */
int ccv;
unsigned char *cV; /* Goto beginning of specified line */
int ccV;
unsigned char *cm; /* Set cursor row and column */
int ccm;
unsigned char *ce; /* Clear to end of line */
int cce;
int assume_256; /* Assume terminal has 256 color mode, but use
regular mode for standard colors just in case */
/* Basic abilities */
int scroll; /* Set to use scrolling */
int insdel; /* Set to use insert/delete within line */
/* Current state of terminal */
int *scrn; /* Characters on screen */
int *attr; /* Attributes on screen */
int x, y; /* Current cursor position (-1 for unknown) */
int top, bot; /* Current scrolling region */
int attrib; /* Current character attributes */
int ins; /* Set if we're in insert mode */
int *updtab; /* Dirty lines table */
int avattr; /* Bits set for available attributes */
int *sary; /* Scroll buffer array */
int *compose; /* Line compose buffer */
int *ofst; /* stuff for magic */
struct hentry *htab;
struct hentry *ary;
};
#endif
extern int skiptop;
/* SCRN *nopen(void);
*
* Open the screen (sets TTY mode so that screen may be used immediatly after
* the 'nopen').
*/
SCRN *nopen PARAMS((CAP *cap));
/* void nresize(SCRN *t,int w,int h);
*
* Change size of screen. For example, call this when you find out that
* the Xterm changed size.
*/
void nresize PARAMS((SCRN *t, int w, int h));
/* void nredraw(SCRN *t);
*
* Invalidate all state variables for the terminal. This way, everything gets
* redrawn.
*/
void nredraw PARAMS((SCRN *t));
void npartial PARAMS((SCRN *t));
void nescape PARAMS((SCRN *t));
void nreturn PARAMS((SCRN *t));
/* void nclose(SCRN *t);
*
* Close the screen and restore TTY to initial state.
*
* if 'flg' is set, tclose doesn't mess with the signals.
*/
void nclose PARAMS((SCRN *t));
/* int cpos(SCRN *t,int x,int y);
*
* Set cursor position
*/
int cpos PARAMS((register SCRN *t, register int x, register int y));
/* int attr(SCRN *t,int a);
*
* Set attributes
*/
int set_attr PARAMS((SCRN *t, int c));
/* Encode character as utf8 */
void utf8_putc PARAMS((int c));
/* void outatr(SCRN *t,int *scrn,int *attr,int x,int y,int c,int a);
*
* Output a character at the given screen cooridinate. The cursor position
* after this function is executed is indeterminate.
*/
/* Character attribute bits */
#ifdef __MSDOS__
#define INVERSE 1
#define UNDERLINE 2
#define BOLD 4
#define BLINK 8
#define DIM 16
extern unsigned atab[];
#define outatr(t,scrn,attr,x,y,c,a) do { \
(t); \
(x); \
(y); \
*(scrn) = ((unsigned)(c) | atab[a]); \
} while(0)
#else
#define INVERSE 256
#define UNDERLINE 512
#define BOLD 1024
#define BLINK 2048
#define DIM 4096
#define AT_MASK (INVERSE+UNDERLINE+BOLD+BLINK+DIM)
#define BG_SHIFT 13
#define BG_VALUE (255<<BG_SHIFT)
#define BG_NOT_DEFAULT (256<<BG_SHIFT)
#define BG_MASK (511<<BG_SHIFT)
#define BG_DEFAULT (0<<BG_SHIFT)
/* #define BG_COLOR(color) (BG_NOT_DEFAULT^(color)<<BG_SHIFT) */
#define BG_COLOR(color) (color)
#define BG_BLACK (BG_NOT_DEFAULT|(0<<BG_SHIFT))
#define BG_RED (BG_NOT_DEFAULT|(1<<BG_SHIFT))
#define BG_GREEN (BG_NOT_DEFAULT|(2<<BG_SHIFT))
#define BG_YELLOW (BG_NOT_DEFAULT|(3<<BG_SHIFT))
#define BG_BLUE (BG_NOT_DEFAULT|(4<<BG_SHIFT))
#define BG_MAGENTA (BG_NOT_DEFAULT|(5<<BG_SHIFT))
#define BG_CYAN (BG_NOT_DEFAULT|(6<<BG_SHIFT))
#define BG_WHITE (BG_NOT_DEFAULT|(7<<BG_SHIFT))
#define BG_BBLACK (BG_NOT_DEFAULT|(8<<BG_SHIFT))
#define BG_BRED (BG_NOT_DEFAULT|(9<<BG_SHIFT))
#define BG_BGREEN (BG_NOT_DEFAULT|(10<<BG_SHIFT))
#define BG_BYELLOW (BG_NOT_DEFAULT|(11<<BG_SHIFT))
#define BG_BBLUE (BG_NOT_DEFAULT|(12<<BG_SHIFT))
#define BG_BMAGENTA (BG_NOT_DEFAULT|(13<<BG_SHIFT))
#define BG_BCYAN (BG_NOT_DEFAULT|(14<<BG_SHIFT))
#define BG_BWHITE (BG_NOT_DEFAULT|(15<<BG_SHIFT))
#define FG_SHIFT 22
#define FG_VALUE (255<<FG_SHIFT)
#define FG_NOT_DEFAULT (256<<FG_SHIFT)
#define FG_MASK (511<<FG_SHIFT)
#define FG_DEFAULT (0<<FG_SHIFT)
#define FG_BWHITE (FG_NOT_DEFAULT|(15<<FG_SHIFT))
#define FG_BCYAN (FG_NOT_DEFAULT|(14<<FG_SHIFT))
#define FG_BMAGENTA (FG_NOT_DEFAULT|(13<<FG_SHIFT))
#define FG_BBLUE (FG_NOT_DEFAULT|(12<<FG_SHIFT))
#define FG_BYELLOW (FG_NOT_DEFAULT|(11<<FG_SHIFT))
#define FG_BGREEN (FG_NOT_DEFAULT|(10<<FG_SHIFT))
#define FG_BRED (FG_NOT_DEFAULT|(9<<FG_SHIFT))
#define FG_BBLACK (FG_NOT_DEFAULT|(8<<FG_SHIFT))
#define FG_WHITE (FG_NOT_DEFAULT|(7<<FG_SHIFT))
#define FG_CYAN (FG_NOT_DEFAULT|(6<<FG_SHIFT))
#define FG_MAGENTA (FG_NOT_DEFAULT|(5<<FG_SHIFT))
#define FG_BLUE (FG_NOT_DEFAULT|(4<<FG_SHIFT))
#define FG_YELLOW (FG_NOT_DEFAULT|(3<<FG_SHIFT))
#define FG_GREEN (FG_NOT_DEFAULT|(2<<FG_SHIFT))
#define FG_RED (FG_NOT_DEFAULT|(1<<FG_SHIFT))
#define FG_BLACK (FG_NOT_DEFAULT|(0<<FG_SHIFT))
void outatr PARAMS((struct charmap *map,SCRN *t,int *scrn,int *attrf,int xx,int yy,int c,int a));
#endif
/*
* translate character and its attribute into something printable
*/
void xlat PARAMS((int *attr, unsigned char *c));
void xlat_utf_ctrl PARAMS((int *attr, unsigned char *c));
/* int eraeol(SCRN *t,int x,int y);
*
* Erase from screen coordinate to end of line.
*/
int eraeol PARAMS((SCRN *t, int x, int y, int atr));
/* void nscrlup(SCRN *t,int top,int bot,int amnt);
*
* Buffered scroll request. Request that some lines up. 'top' and 'bot'
* indicate which lines to scroll. 'bot' is the last line to scroll + 1.
* 'amnt' is distance in lines to scroll.
*/
void nscrlup PARAMS((SCRN *t, int top, int bot, int amnt));
/* void nscrldn(SCRN *t,int top,int bot,int amnt);
*
* Buffered scroll request. Scroll some lines down. 'top' and 'bot'
* indicate which lines to scroll. 'bot' is the last line to scroll + 1.
* 'amnt' is distance in lines to scroll.
*/
void nscrldn PARAMS((SCRN *t, int top, int bot, int amnt));
/* void nscroll(SCRN *t);
*
* Execute buffered scroll requests
*/
void nscroll PARAMS((SCRN *t, int atr));
/* void magic(SCRN *t,int y,int *cur,int *new);
*
* Figure out and execute line shifting
*/
void magic PARAMS((SCRN *t, int y, int *cs, int *ca, int *s, int *a,int placex));
int clrins PARAMS((SCRN *t));
int meta_color PARAMS((unsigned char *s));
/* Return width of a string */
int joe_wcswidth(struct charmap *map, unsigned char *s, int len);
/* Calculate no. lines needed to fit a string within a given width: used to break up
* prompts into multiple lines in qw.c */
int break_height(struct charmap *map, unsigned char **src, int *src_len, int wid, int n);
/* Generate a field */
void genfield PARAMS((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));
/* Column width of a string takes into account utf-8) */
int txtwidth PARAMS((struct charmap *map,unsigned char *s,int len));
int txtwidth1 PARAMS((struct charmap *map, int tabwidth, unsigned char *s, int len));
void unesc_genfmt(unsigned char *d, unsigned char *s, int len, int max);
/* Generate a field: formatted */
void genfmt PARAMS((SCRN *t, int x, int y, int ofst, unsigned char *s, int atr, int flg));
/* Column width of formatted string */
int fmtlen PARAMS((unsigned char *s));
/* Offset within formatted string of particular column */
int fmtpos PARAMS((unsigned char *s, int goal));
extern int bg_text;
extern int columns;
extern int notite;
extern int usetabs;
extern int assume_color;
extern int assume_256color;
#endif

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks