9
#define SPACEWIDTH (spacewidth[FIXED_FONT])
11
typedef struct sline_t {
12
int dirtybeg, dirtyend; /* [) protocol; -1,-1 for non-dirty */
13
int isclear; /* TRUE if text is all blank */
14
char *text; /* pointer to array of stat_wid chars */
15
int *attr; /* pointer to array of stat_wid ints */
18
/*static int stat_xpos, stat_ypos;*/ /* in pixels */
19
static int stat_realwid, stat_realhgt; /* in pixels */
20
static int stat_wid, stat_hgt; /* in chars */
21
static sline *linelist; /* array of stat_hgt slines */
23
static int linesused; /* z-machine's idea of the status line size */
24
static int maxlinesused; /* lines currently visible -- reset only by hitting return. */
25
static int curlines; /* actual window size */
27
static int cursorx, cursory;
28
static int cursorattr;
30
static int dotactive; /* is there an insertion mark? */
31
static int dotdrawn; /* is the insertion mark currently drawn? */
32
static int dotdrawnx, dotdrawny;
33
static XPoint polydot[3];
36
static void resizewindow(int lines);
37
static void clearlines(int beg, int end);
38
static void flipdot();
40
static void resizewindow();
41
static void clearlines();
42
static void flipdot();
46
void xstat_init(int cols, int rows, int xpos, int ypos)
48
void xstat_init(cols, rows, xpos, ypos)
62
stat_realwid = cols * SPACEWIDTH;
63
stat_realhgt = rows * lineheight;
77
linelist = (sline *)malloc(sizeof(sline) * stat_hgt);
79
for (ix=0; ix<stat_hgt; ix++) {
80
linelist[ix].text = (char *)malloc(sizeof(char) * stat_wid);
81
linelist[ix].attr = (int *)malloc(sizeof(int) * stat_wid);
82
linelist[ix].isclear = FALSE;
91
cursorattr = FIXED_FONT;
94
/* export to ZIP code */
103
void xstat_newgeometry(int newx, int newy, int newwid, int newhgt)
105
void xstat_newgeometry(newx, newy, newwid, newhgt)
112
stat_realwid = newwid;
113
stat_realhgt = newhgt;
125
for (ix=0; ix<stat_hgt; ix++) {
126
curline = (&linelist[ix]);
127
if (!curline->isclear) {
128
curline->dirtybeg = 0;
129
curline->dirtyend = stat_wid;
138
void xstat_insert(int ch)
140
void xstat_insert(ch)
146
if (cursory<0 || cursory>=stat_hgt || cursorx<0 || cursorx>=stat_wid)
149
if (cursory+1 > linesused) {
150
xstat_set_window_size(cursory+1);
153
curline = (&linelist[cursory]);
154
if (curline->text[cursorx] != (char)ch || curline->attr[cursorx] != cursorattr) {
155
curline->text[cursorx] = (char)ch;
156
curline->attr[cursorx] = cursorattr;
157
curline->isclear = FALSE;
158
if (curline->dirtybeg == (-1) || cursorx < curline->dirtybeg)
159
curline->dirtybeg = cursorx;
160
if (curline->dirtyend == (-1) || cursorx+1 > curline->dirtyend)
161
curline->dirtyend = cursorx+1;
165
if (cursorx == stat_wid) {
182
void xstat_getpos(int *row, int *col)
184
void xstat_getpos(row, col)
194
void xstat_setpos(int row, int col)
196
void xstat_setpos(row, col)
206
void xstat_setattr(int attr)
208
void xstat_setattr(attr)
212
cursorattr = attr | FIXED_FONT;
216
void xstat_set_window_size(int lines)
218
void xstat_set_window_size(lines)
223
if (lines > maxlinesused)
224
maxlinesused = lines;
228
void xstat_set_dot_active(int visible)
230
void xstat_set_dot_active(visible)
248
/* clear to blankness */
250
void xstat_clear_window()
252
void xstat_clear_window()
255
clearlines(0, stat_hgt);
258
maxlinesused = linesused; /* because anything below the status window has been cleared */
262
static void clearlines(int beg, int end)
264
static void clearlines(beg, end)
274
for (ix=beg; ix<end; ix++) {
275
if (!linelist[ix].isclear) {
276
linelist[ix].isclear = TRUE;
277
linelist[ix].dirtybeg = 0;
278
linelist[ix].dirtyend = stat_wid;
279
for (cx=linelist[ix].text, jx=stat_wid; jx; cx++, jx--)
281
for (ax=linelist[ix].attr, jx=stat_wid; jx; ax++, jx--)
287
/* redraw the dirty stuff */
295
int beg, end, pos, px;
305
newsize = maxlinesused;
306
if (prefs.autoclear && newsize != curlines) {
307
clearlines(newsize, stat_hgt);
310
for (ix=0; ix<stat_hgt; ix++) {
311
curline = (&linelist[ix]);
312
if (curline->dirtybeg == (-1))
314
beg = curline->dirtybeg;
315
end = curline->dirtyend;
318
attr = curline->attr[pos];
319
for (px=pos; px<end && curline->attr[px]==attr; px++);
320
if (attr==BLANKATTR) {
321
XClearArea(xiodpy, xioswin, pos*SPACEWIDTH, ix*lineheight, (px-pos)*SPACEWIDTH, lineheight, FALSE);
323
else if (attr & REVERSE) {
324
XFillRectangle(xiodpy, xioswin, gcsfont[attr], pos*SPACEWIDTH, ix*lineheight, (px-pos)*SPACEWIDTH, lineheight);
325
XDrawString(xiodpy, xioswin, gcsnegfont[attr], pos*SPACEWIDTH, ix*lineheight+lineheightoff, curline->text+pos, (px-pos));
328
XClearArea(xiodpy, xioswin, pos*SPACEWIDTH, ix*lineheight, (px-pos)*SPACEWIDTH, lineheight, FALSE);
329
XDrawString(xiodpy, xioswin, gcsfont[attr], pos*SPACEWIDTH, ix*lineheight+lineheightoff, curline->text+pos, (px-pos));
333
curline->dirtybeg = (-1);
334
curline->dirtyend = (-1);
338
dotdrawnx = cursorx * SPACEWIDTH;
339
dotdrawny = cursory * lineheight + lineheightoff;
344
if (prefs.autoresize && newsize != curlines) {
345
resizewindow(newsize);
349
/* reset the window size to linesused (if max==FALSE) or temporarily to stat_hgt (if max==TRUE) */
351
void xstat_reset_window_size(int op)
353
void xstat_reset_window_size(op)
360
clearlines(linesused, stat_hgt);
364
else if (op==op_Zoom)
366
else if (op==op_Shrink)
372
if (prefs.autoclear && newsize != curlines) {
373
clearlines(newsize, stat_hgt);
375
if (prefs.autoresize && newsize != curlines) {
376
resizewindow(newsize);
378
maxlinesused = newsize;
382
static void resizewindow(int lines)
384
static void resizewindow(lines)
394
newheight = curlines*lineheight;
398
if (!prefs.resizeupward) {
399
szhints.flags = USSize;
400
szhints.width = stat_wid*SPACEWIDTH;
401
szhints.height = newheight;
402
XResizeWindow(xiodpy, xioswin, szhints.width, szhints.height);
403
XSetNormalHints(xiodpy, xioswin, &szhints);
406
XTranslateCoordinates(xiodpy, xioswin, RootWindow(xiodpy, xioscn), 0, 0, &xp, &yp, &child);
407
yp -= (newheight - stat_realhgt);
409
szhints.flags = PMinSize|PResizeInc|USPosition|USSize;
410
szhints.width = stat_wid*SPACEWIDTH;
411
szhints.height = newheight;
414
szhints.width_inc = spacewidth[FIXED_FONT];
415
szhints.height_inc = lineheight;
416
szhints.min_width = 1 * szhints.width_inc;
417
szhints.min_height = 1 * szhints.height_inc;
418
XMoveResizeWindow(xiodpy, xioswin, xp, yp, szhints.width, szhints.height);
419
XSetNormalHints(xiodpy, xioswin, &szhints);
424
static void flipdot()
426
static void flipdot()
429
polydot[0].x = dotdrawnx;
430
polydot[0].y = dotdrawny;
431
XFillPolygon(xiodpy, xioswin, gcsflip, polydot, 3, Convex, CoordModePrevious);