Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 118 lines (104 sloc) 4.588 kB
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
1 /* draw.h */
2 /* Copyright 1995 by Steve Kirkendall */
3
4
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
5 /* Attributes of characters currently shown on the screen. Note that the new
6 * image stores 1-byte font codes; the DRAWATTR struct is only used for the
7 * old image. This is because the new image needs some extra information
8 * (especially the GUI's numbers for the colors) which isn't stored in DRAWATTR.
9 * Also, any temporary font codes (created via colortmp()) are still allocated
10 * while the new image is being used, but could be freed by the time the old
11 * image is used.
12 */
13 typedef struct
14 {
15 unsigned short bits; /* attribute bits of a font code */
16 unsigned char fg_rgb[3]; /* foreground color */
17 unsigned char bg_rgb[3]; /* background color */
18 } DRAWATTR;
19
20 /* This macro returns a font's attributes. It is clever enough to convert
21 * "selected" font codes 0x80-0xff into real font codes with the COLOR_SEL
22 * attribute bit set.
23 */
24 #define drawfontbits(f) (colorinfo[0x7f & (f)].da.bits | ((0x80 & (f)) ? COLOR_SEL : 0))
25
26 /* This macro compares new attributes to old attributes, at a given index.
27 * This is non-trivial since they're stored differently. It also compares
28 * the character. Return 0 if same, else non-0.
29 */
30 #define drawnochange(di,i) ((di)->newchar[i] == (di)->curchar[i] \
31 && drawfontbits((di)->newfont[i]) == (di)->curattr[i].bits \
32 && !memcmp(&colorinfo[0x7f & (int)(di)->newfont[i]].da.fg_rgb, \
33 &(di)->curattr[i].fg_rgb, 6))
34
35 /* Return TRUE if current attributes match the default font */
36 #define drawdeffont(di,i) !memcmp(&colorinfo[0].da, \
37 &(di)->curattr[i], sizeof(DRAWATTR))
38
39 /* Return TRUE if the current attributes at two locations are the same */
40 #define drawspan(di,i,j) !memcmp(&(di)->curattr[i], \
41 &(di)->curattr[j], sizeof(DRAWATTR))
42
43 /* information about a row of the screen */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
44 typedef struct
45 {
46 long lineoffset; /* which line this row is for */
47 int insrows;
48 int shiftright;
49 int inschars;
50 } DRAWROW;
51
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
52 /* information about a line that's drawn on the screen. Note that this is
53 * different from rows; rows are screen-oriented, while lines are defined by
54 * the buffer and the display mode.
55 */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
56 typedef struct
57 {
58 long start; /* offset from start of buffer to start of line */
59 int width; /* width of the line */
60 int startrow;/* where it appears on the screen */
61 } DRAWLINE;
62
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
63 /* possible states of a window, affecting the way it is updated */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
64 typedef enum
65 {
66 DRAW_VISUAL, /* visual, no message or status msg */
67 DRAW_VMSG, /* visual, non-status message */
68 DRAW_OPENEDIT, /* open, editing a line */
69 DRAW_OPENOUTPUT /* open, after outputing a message */
70 } DRAWSTATE;
71
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
72 /* affects efficiency of screen updates. The DRAW_CENTER value also affects
73 * the way the new image is generated.
74 */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
75 typedef enum
76 {
77 DRAW_NORMAL, /* optimizable, refreshable, cursor on screen */
78 DRAW_CHANGED, /* non-optimizable, refreshable, cursor on screen */
79 DRAW_CENTER, /* non-optimizable, refreshable, cursor in top half */
80 DRAW_SCRATCH /* non-optimizable, non-refreshable, cursor on screen */
81 } DRAWLOGIC;
82
83
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
84 /* This collects all of the information that the "draw.c" module requires to
85 * update a window's image efficiently.
86 */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
87 typedef struct
88 {
89 DRAWSTATE drawstate; /* drawing state */
90 DRAWROW *newrow; /* info about new rows */
91 DRAWLINE *newline; /* info about new lines */
92 DRAWLINE *curline; /* info about current lines */
93 CHAR *newchar; /* characters of new image */
94 char *newfont; /* fonts of new image */
95 CHAR *curchar; /* characters of current image */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
96 DRAWATTR *curattr; /* font info of current image */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
97 long *offsets; /* buffer offsets of each individual cell */
97d8998 @mbert Import Elvis 2.1_4 (written by Steve Kirkendall)
authored
98 MARK topmark; /* first line drawn */
99 MARK bottommark; /* line after last drawn */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
100 BUFFER curbuf; /* current buffer */
101 long curnbytes; /* size of buffer when current image drawn */
102 long curchgs; /* buffer's "changes" counter when image drawn */
103 int rows, columns; /* dimensions of screen */
104 int cursrow, curscol;/* position of cursor */
105 int skipped; /* number of columns skipped from first line */
106 int nlines; /* number of lines */
107 DRAWLOGIC logic; /* ignore current image? */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
108 ELVBOOL newmsg; /* does msg row contain anything important? */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
109 MARK openline; /* current line (open mode only) */
110 CHAR *openimage; /* image of current line, '\0'-terminated */
111 long opencursor; /* where cursor is within line */
112 long opencnt; /* width of line in openimage */
113 int opencell; /* tty simulator's cursor position */
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
114 ELVBOOL tmpmsg; /* blank out the status line, unless newmsg */
115 char cursface; /* text face of cursor, in visual mode only */
cf92e3b @mbert Import Elvis 2.0 (written by Steve Kirkendall)
authored
116 } DRAWINFO;
9f1c6f0 @mbert Import Elvis 2.2_0 (written by Steve Kirkendall)
authored
117
Something went wrong with that request. Please try again.