Annotation of src/usr.bin/tmux/screen-redraw.c, Revision 1.39
1.39 ! nicm 1: /* $OpenBSD: screen-redraw.c,v 1.38 2016/10/09 16:24:34 nicm Exp $ */
1.1 nicm 2:
3: /*
1.35 nicm 4: * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
1.1 nicm 5: *
6: * Permission to use, copy, modify, and distribute this software for any
7: * purpose with or without fee is hereby granted, provided that the above
8: * copyright notice and this permission notice appear in all copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14: * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15: * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16: * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17: */
18:
19: #include <sys/types.h>
20:
21: #include <string.h>
22:
23: #include "tmux.h"
24:
1.39 ! nicm 25: static int screen_redraw_cell_border1(struct window_pane *, u_int, u_int);
! 26: static int screen_redraw_cell_border(struct client *, u_int, u_int);
! 27: static int screen_redraw_check_cell(struct client *, u_int, u_int, int,
! 28: struct window_pane **);
! 29: static int screen_redraw_check_is(u_int, u_int, int, int, struct window *,
! 30: struct window_pane *, struct window_pane *);
! 31:
! 32: static int screen_redraw_make_pane_status(struct client *, struct window *,
! 33: struct window_pane *);
! 34: static void screen_redraw_draw_pane_status(struct client *, int);
! 35:
! 36: static void screen_redraw_draw_borders(struct client *, int, int, u_int);
! 37: static void screen_redraw_draw_panes(struct client *, u_int);
! 38: static void screen_redraw_draw_status(struct client *, u_int);
! 39: static void screen_redraw_draw_number(struct client *, struct window_pane *,
! 40: u_int);
1.1 nicm 41:
1.6 nicm 42: #define CELL_INSIDE 0
1.7 nicm 43: #define CELL_LEFTRIGHT 1
44: #define CELL_TOPBOTTOM 2
45: #define CELL_TOPLEFT 3
46: #define CELL_TOPRIGHT 4
47: #define CELL_BOTTOMLEFT 5
48: #define CELL_BOTTOMRIGHT 6
49: #define CELL_TOPJOIN 7
50: #define CELL_BOTTOMJOIN 8
51: #define CELL_LEFTJOIN 9
52: #define CELL_RIGHTJOIN 10
53: #define CELL_JOIN 11
54: #define CELL_OUTSIDE 12
1.6 nicm 55:
1.17 nicm 56: #define CELL_BORDERS " xqlkmjwvtun~"
57:
1.36 nicm 58: #define CELL_STATUS_OFF 0
59: #define CELL_STATUS_TOP 1
60: #define CELL_STATUS_BOTTOM 2
61:
1.15 nicm 62: /* Check if cell is on the border of a particular pane. */
1.39 ! nicm 63: static int
1.15 nicm 64: screen_redraw_cell_border1(struct window_pane *wp, u_int px, u_int py)
65: {
66: /* Inside pane. */
67: if (px >= wp->xoff && px < wp->xoff + wp->sx &&
68: py >= wp->yoff && py < wp->yoff + wp->sy)
69: return (0);
70:
71: /* Left/right borders. */
72: if ((wp->yoff == 0 || py >= wp->yoff - 1) && py <= wp->yoff + wp->sy) {
73: if (wp->xoff != 0 && px == wp->xoff - 1)
74: return (1);
75: if (px == wp->xoff + wp->sx)
1.36 nicm 76: return (2);
1.15 nicm 77: }
78:
79: /* Top/bottom borders. */
80: if ((wp->xoff == 0 || px >= wp->xoff - 1) && px <= wp->xoff + wp->sx) {
81: if (wp->yoff != 0 && py == wp->yoff - 1)
1.36 nicm 82: return (3);
1.15 nicm 83: if (py == wp->yoff + wp->sy)
1.36 nicm 84: return (4);
1.15 nicm 85: }
86:
87: /* Outside pane. */
88: return (-1);
89: }
90:
1.7 nicm 91: /* Check if a cell is on the pane border. */
1.39 ! nicm 92: static int
1.7 nicm 93: screen_redraw_cell_border(struct client *c, u_int px, u_int py)
1.1 nicm 94: {
95: struct window *w = c->session->curw->window;
96: struct window_pane *wp;
1.15 nicm 97: int retval;
1.1 nicm 98:
1.7 nicm 99: /* Check all the panes. */
1.1 nicm 100: TAILQ_FOREACH(wp, &w->panes, entry) {
1.3 nicm 101: if (!window_pane_visible(wp))
102: continue;
1.15 nicm 103: if ((retval = screen_redraw_cell_border1(wp, px, py)) != -1)
1.36 nicm 104: return (!!retval);
1.7 nicm 105: }
106:
107: return (0);
108: }
109:
110: /* Check if cell inside a pane. */
1.39 ! nicm 111: static int
1.36 nicm 112: screen_redraw_check_cell(struct client *c, u_int px, u_int py, int pane_status,
1.24 nicm 113: struct window_pane **wpp)
1.7 nicm 114: {
115: struct window *w = c->session->curw->window;
116: struct window_pane *wp;
117: int borders;
1.36 nicm 118: u_int right, line;
1.7 nicm 119:
1.39 ! nicm 120: *wpp = NULL;
! 121:
1.7 nicm 122: if (px > w->sx || py > w->sy)
123: return (CELL_OUTSIDE);
124:
1.36 nicm 125: if (pane_status != CELL_STATUS_OFF) {
126: TAILQ_FOREACH(wp, &w->panes, entry) {
127: if (!window_pane_visible(wp))
128: continue;
129:
130: if (pane_status == CELL_STATUS_TOP)
131: line = wp->yoff - 1;
132: else
133: line = wp->yoff + wp->sy;
134: right = wp->xoff + 2 + wp->status_size - 1;
135:
136: if (py == line && px >= wp->xoff + 2 && px <= right)
137: return (CELL_INSIDE);
138: }
139: }
140:
1.7 nicm 141: TAILQ_FOREACH(wp, &w->panes, entry) {
142: if (!window_pane_visible(wp))
143: continue;
1.24 nicm 144: *wpp = wp;
1.7 nicm 145:
146: /* If outside the pane and its border, skip it. */
147: if ((wp->xoff != 0 && px < wp->xoff - 1) ||
148: px > wp->xoff + wp->sx ||
149: (wp->yoff != 0 && py < wp->yoff - 1) ||
150: py > wp->yoff + wp->sy)
151: continue;
152:
153: /* If definitely inside, return so. */
154: if (!screen_redraw_cell_border(c, px, py))
155: return (CELL_INSIDE);
156:
1.14 nicm 157: /*
1.7 nicm 158: * Construct a bitmask of whether the cells to the left (bit
159: * 4), right, top, and bottom (bit 1) of this cell are borders.
160: */
161: borders = 0;
162: if (px == 0 || screen_redraw_cell_border(c, px - 1, py))
163: borders |= 8;
164: if (px <= w->sx && screen_redraw_cell_border(c, px + 1, py))
165: borders |= 4;
1.36 nicm 166: if (pane_status == CELL_STATUS_TOP) {
167: if (py != 0 && screen_redraw_cell_border(c, px, py - 1))
168: borders |= 2;
169: } else {
170: if (py == 0 || screen_redraw_cell_border(c, px, py - 1))
171: borders |= 2;
172: }
1.7 nicm 173: if (py <= w->sy && screen_redraw_cell_border(c, px, py + 1))
174: borders |= 1;
175:
1.14 nicm 176: /*
1.7 nicm 177: * Figure out what kind of border this cell is. Only one bit
178: * set doesn't make sense (can't have a border cell with no
179: * others connected).
180: */
181: switch (borders) {
182: case 15: /* 1111, left right top bottom */
183: return (CELL_JOIN);
184: case 14: /* 1110, left right top */
185: return (CELL_BOTTOMJOIN);
186: case 13: /* 1101, left right bottom */
187: return (CELL_TOPJOIN);
188: case 12: /* 1100, left right */
189: return (CELL_TOPBOTTOM);
190: case 11: /* 1011, left top bottom */
191: return (CELL_RIGHTJOIN);
192: case 10: /* 1010, left top */
193: return (CELL_BOTTOMRIGHT);
194: case 9: /* 1001, left bottom */
195: return (CELL_TOPRIGHT);
196: case 7: /* 0111, right top bottom */
197: return (CELL_LEFTJOIN);
198: case 6: /* 0110, right top */
199: return (CELL_BOTTOMLEFT);
200: case 5: /* 0101, right bottom */
201: return (CELL_TOPLEFT);
202: case 3: /* 0011, top bottom */
203: return (CELL_LEFTRIGHT);
1.1 nicm 204: }
205: }
206:
1.6 nicm 207: return (CELL_OUTSIDE);
1.1 nicm 208: }
209:
1.32 nicm 210: /* Check if the border of a particular pane. */
1.39 ! nicm 211: static int
1.36 nicm 212: screen_redraw_check_is(u_int px, u_int py, int type, int pane_status,
213: struct window *w, struct window_pane *wantwp, struct window_pane *wp)
1.24 nicm 214: {
1.36 nicm 215: int border;
216:
1.24 nicm 217: /* Is this off the active pane border? */
1.36 nicm 218: border = screen_redraw_cell_border1(wantwp, px, py);
219: if (border == 0 || border == -1)
220: return (0);
221: if (pane_status == CELL_STATUS_TOP && border == 4)
222: return (0);
223: if (pane_status == CELL_STATUS_BOTTOM && border == 3)
1.24 nicm 224: return (0);
225:
226: /* If there are more than two panes, that's enough. */
227: if (window_count_panes(w) != 2)
228: return (1);
229:
230: /* Else if the cell is not a border cell, forget it. */
231: if (wp == NULL || (type == CELL_OUTSIDE || type == CELL_INSIDE))
232: return (1);
233:
1.36 nicm 234: /* With status lines mark the entire line. */
235: if (pane_status != CELL_STATUS_OFF)
236: return (1);
237:
1.24 nicm 238: /* Check if the pane covers the whole width. */
239: if (wp->xoff == 0 && wp->sx == w->sx) {
240: /* This can either be the top pane or the bottom pane. */
241: if (wp->yoff == 0) { /* top pane */
1.32 nicm 242: if (wp == wantwp)
1.24 nicm 243: return (px <= wp->sx / 2);
244: return (px > wp->sx / 2);
245: }
246: return (0);
247: }
248:
249: /* Check if the pane covers the whole height. */
250: if (wp->yoff == 0 && wp->sy == w->sy) {
251: /* This can either be the left pane or the right pane. */
252: if (wp->xoff == 0) { /* left pane */
1.32 nicm 253: if (wp == wantwp)
1.24 nicm 254: return (py <= wp->sy / 2);
255: return (py > wp->sy / 2);
256: }
257: return (0);
258: }
259:
1.36 nicm 260: return (1);
261: }
262:
263: /* Update pane status. */
1.39 ! nicm 264: static int
1.36 nicm 265: screen_redraw_make_pane_status(struct client *c, struct window *w,
266: struct window_pane *wp)
267: {
268: struct grid_cell gc;
269: const char *fmt;
270: struct format_tree *ft;
271: char *out;
272: size_t outlen, old_size = wp->status_size;
273: struct screen_write_ctx ctx;
274:
275: if (wp == w->active)
276: style_apply(&gc, w->options, "pane-active-border-style");
277: else
278: style_apply(&gc, w->options, "pane-border-style");
279:
280: fmt = options_get_string(w->options, "pane-border-format");
281:
282: ft = format_create(NULL, 0);
283: format_defaults(ft, c, NULL, NULL, wp);
284:
285: screen_free(&wp->status_screen);
286: screen_init(&wp->status_screen, wp->sx, 1, 0);
287: wp->status_screen.mode = 0;
288:
289: out = format_expand(ft, fmt);
290: outlen = screen_write_cstrlen("%s", out);
291: if (outlen > wp->sx - 4)
292: outlen = wp->sx - 4;
293: screen_resize(&wp->status_screen, outlen, 1, 0);
294:
295: screen_write_start(&ctx, NULL, &wp->status_screen);
296: screen_write_cursormove(&ctx, 0, 0);
297: screen_write_clearline(&ctx);
298: screen_write_cnputs(&ctx, outlen, &gc, "%s", out);
299: screen_write_stop(&ctx);
300:
301: format_free(ft);
302:
303: wp->status_size = outlen;
304: return (wp->status_size != old_size);
305: }
306:
307: /* Draw pane status. */
1.39 ! nicm 308: static void
1.36 nicm 309: screen_redraw_draw_pane_status(struct client *c, int pane_status)
310: {
311: struct window *w = c->session->curw->window;
312: struct options *oo = c->session->options;
313: struct tty *tty = &c->tty;
314: struct window_pane *wp;
315: int spos;
316: u_int yoff;
317:
318: spos = options_get_number(oo, "status-position");
319: TAILQ_FOREACH(wp, &w->panes, entry) {
320: if (pane_status == CELL_STATUS_TOP)
321: yoff = wp->yoff - 1;
322: else
323: yoff = wp->yoff + wp->sy;
324: if (spos == 0)
325: yoff += 1;
326:
327: tty_draw_line(tty, NULL, &wp->status_screen, 0, wp->xoff + 2,
328: yoff);
329: }
330: tty_cursor(tty, 0, 0);
1.24 nicm 331: }
332:
1.38 nicm 333: /* Update status line and change flags if unchanged. */
334: void
335: screen_redraw_update(struct client *c)
336: {
337: struct window *w = c->session->curw->window;
338: struct window_pane *wp;
339: struct options *wo = w->options;
340: int redraw;
341:
342: if (c->message_string != NULL)
343: redraw = status_message_redraw(c);
344: else if (c->prompt_string != NULL)
345: redraw = status_prompt_redraw(c);
346: else
347: redraw = status_redraw(c);
348: if (!redraw)
349: c->flags &= ~CLIENT_STATUS;
350:
351: if (options_get_number(wo, "pane-border-status") != CELL_STATUS_OFF) {
352: redraw = 0;
353: TAILQ_FOREACH(wp, &w->panes, entry) {
354: if (screen_redraw_make_pane_status(c, w, wp))
355: redraw = 1;
356: }
357: if (redraw)
358: c->flags |= CLIENT_BORDERS;
359: }
360: }
361:
1.4 nicm 362: /* Redraw entire screen. */
1.1 nicm 363: void
1.26 nicm 364: screen_redraw_screen(struct client *c, int draw_panes, int draw_status,
365: int draw_borders)
1.1 nicm 366: {
1.36 nicm 367: struct options *oo = c->session->options;
368: struct tty *tty = &c->tty;
369: struct window *w = c->session->curw->window;
1.38 nicm 370: struct options *wo = w->options;
1.36 nicm 371: u_int top;
372: int status, pane_status, spos;
1.18 nicm 373:
374: /* Suspended clients should not be updated. */
375: if (c->flags & CLIENT_SUSPENDED)
376: return;
1.1 nicm 377:
378: /* Get status line, er, status. */
1.21 nicm 379: spos = options_get_number(oo, "status-position");
1.4 nicm 380: if (c->message_string != NULL || c->prompt_string != NULL)
381: status = 1;
382: else
1.21 nicm 383: status = options_get_number(oo, "status");
384: top = 0;
385: if (status && spos == 0)
386: top = 1;
1.26 nicm 387: if (!status)
388: draw_status = 0;
389:
1.36 nicm 390: /* Draw the elements. */
1.38 nicm 391: if (draw_borders) {
392: pane_status = options_get_number(wo, "pane-border-status");
1.36 nicm 393: screen_redraw_draw_borders(c, status, pane_status, top);
1.38 nicm 394: if (pane_status != CELL_STATUS_OFF)
395: screen_redraw_draw_pane_status(c, pane_status);
396: }
1.26 nicm 397: if (draw_panes)
398: screen_redraw_draw_panes(c, top);
399: if (draw_status)
400: screen_redraw_draw_status(c, top);
401: tty_reset(tty);
402: }
1.4 nicm 403:
1.26 nicm 404: /* Draw a single pane. */
405: void
406: screen_redraw_pane(struct client *c, struct window_pane *wp)
407: {
408: u_int i, yoff;
409:
410: if (!window_pane_visible(wp))
1.4 nicm 411: return;
1.1 nicm 412:
1.26 nicm 413: yoff = wp->yoff;
414: if (status_at_line(c) == 0)
415: yoff++;
416:
417: for (i = 0; i < wp->sy; i++)
1.30 nicm 418: tty_draw_pane(&c->tty, wp, i, wp->xoff, yoff);
1.26 nicm 419: tty_reset(&c->tty);
420: }
421:
422: /* Draw the borders. */
1.39 ! nicm 423: static void
1.36 nicm 424: screen_redraw_draw_borders(struct client *c, int status, int pane_status,
425: u_int top)
1.26 nicm 426: {
1.32 nicm 427: struct session *s = c->session;
428: struct window *w = s->curw->window;
1.33 nicm 429: struct options *oo = w->options;
1.26 nicm 430: struct tty *tty = &c->tty;
431: struct window_pane *wp;
1.32 nicm 432: struct grid_cell m_active_gc, active_gc, m_other_gc, other_gc;
433: struct grid_cell msg_gc;
1.28 nicm 434: u_int i, j, type, msgx = 0, msgy = 0;
1.32 nicm 435: int active, small, flags;
1.28 nicm 436: char msg[256];
437: const char *tmp;
438: size_t msglen = 0;
439:
440: small = (tty->sy - status + top > w->sy) || (tty->sx > w->sx);
441: if (small) {
442: flags = w->flags & (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT);
443: if (flags == (WINDOW_FORCEWIDTH|WINDOW_FORCEHEIGHT))
444: tmp = "force-width, force-height";
445: else if (flags == WINDOW_FORCEWIDTH)
446: tmp = "force-width";
447: else if (flags == WINDOW_FORCEHEIGHT)
448: tmp = "force-height";
449: else
450: tmp = "a smaller client";
451: xsnprintf(msg, sizeof msg, "(size %ux%u from %s)",
452: w->sx, w->sy, tmp);
453: msglen = strlen(msg);
454:
455: if (tty->sy - 1 - status + top > w->sy && tty->sx >= msglen) {
456: msgx = tty->sx - msglen;
457: msgy = tty->sy - 1 - status + top;
458: } else if (tty->sx - w->sx > msglen) {
459: msgx = tty->sx - msglen;
460: msgy = tty->sy - 1 - status + top;
461: } else
462: small = 0;
463: }
1.26 nicm 464:
1.25 nicm 465: style_apply(&other_gc, oo, "pane-border-style");
466: style_apply(&active_gc, oo, "pane-active-border-style");
1.26 nicm 467: active_gc.attr = other_gc.attr = GRID_ATTR_CHARSET;
1.15 nicm 468:
1.32 nicm 469: memcpy(&m_other_gc, &other_gc, sizeof m_other_gc);
470: m_other_gc.attr ^= GRID_ATTR_REVERSE;
471: memcpy(&m_active_gc, &active_gc, sizeof m_active_gc);
472: m_active_gc.attr ^= GRID_ATTR_REVERSE;
473:
1.1 nicm 474: for (j = 0; j < tty->sy - status; j++) {
475: for (i = 0; i < tty->sx; i++) {
1.36 nicm 476: type = screen_redraw_check_cell(c, i, j, pane_status,
477: &wp);
1.15 nicm 478: if (type == CELL_INSIDE)
479: continue;
1.32 nicm 480: if (type == CELL_OUTSIDE && small &&
481: i > msgx && j == msgy)
1.28 nicm 482: continue;
1.36 nicm 483: active = screen_redraw_check_is(i, j, type, pane_status,
484: w, w->active, wp);
1.34 nicm 485: if (server_is_marked(s, s->curw, marked_pane.wp) &&
1.36 nicm 486: screen_redraw_check_is(i, j, type, pane_status, w,
1.34 nicm 487: marked_pane.wp, wp)) {
1.32 nicm 488: if (active)
489: tty_attributes(tty, &m_active_gc, NULL);
490: else
491: tty_attributes(tty, &m_other_gc, NULL);
492: } else if (active)
1.30 nicm 493: tty_attributes(tty, &active_gc, NULL);
1.15 nicm 494: else
1.30 nicm 495: tty_attributes(tty, &other_gc, NULL);
1.21 nicm 496: tty_cursor(tty, i, top + j);
1.17 nicm 497: tty_putc(tty, CELL_BORDERS[type]);
1.1 nicm 498: }
1.28 nicm 499: }
500:
501: if (small) {
502: memcpy(&msg_gc, &grid_default_cell, sizeof msg_gc);
1.30 nicm 503: tty_attributes(tty, &msg_gc, NULL);
1.28 nicm 504: tty_cursor(tty, msgx, msgy);
505: tty_puts(tty, msg);
1.1 nicm 506: }
1.26 nicm 507: }
1.1 nicm 508:
1.26 nicm 509: /* Draw the panes. */
1.39 ! nicm 510: static void
1.26 nicm 511: screen_redraw_draw_panes(struct client *c, u_int top)
512: {
513: struct window *w = c->session->curw->window;
514: struct tty *tty = &c->tty;
515: struct window_pane *wp;
516: u_int i;
1.15 nicm 517:
1.1 nicm 518: TAILQ_FOREACH(wp, &w->panes, entry) {
1.3 nicm 519: if (!window_pane_visible(wp))
1.1 nicm 520: continue;
1.26 nicm 521: for (i = 0; i < wp->sy; i++)
1.30 nicm 522: tty_draw_pane(tty, wp, i, wp->xoff, top + wp->yoff);
1.10 nicm 523: if (c->flags & CLIENT_IDENTIFY)
1.31 nicm 524: screen_redraw_draw_number(c, wp, top);
1.1 nicm 525: }
526: }
527:
1.26 nicm 528: /* Draw the status line. */
1.39 ! nicm 529: static void
1.26 nicm 530: screen_redraw_draw_status(struct client *c, u_int top)
1.1 nicm 531: {
1.26 nicm 532: struct tty *tty = &c->tty;
1.23 nicm 533:
1.26 nicm 534: if (top)
1.30 nicm 535: tty_draw_line(tty, NULL, &c->status, 0, 0, 0);
1.26 nicm 536: else
1.30 nicm 537: tty_draw_line(tty, NULL, &c->status, 0, 0, tty->sy - 1);
1.10 nicm 538: }
539:
540: /* Draw number on a pane. */
1.39 ! nicm 541: static void
1.31 nicm 542: screen_redraw_draw_number(struct client *c, struct window_pane *wp, u_int top)
1.10 nicm 543: {
544: struct tty *tty = &c->tty;
545: struct session *s = c->session;
1.33 nicm 546: struct options *oo = s->options;
1.16 nicm 547: struct window *w = wp->window;
1.10 nicm 548: struct grid_cell gc;
1.12 nicm 549: u_int idx, px, py, i, j, xoff, yoff;
1.16 nicm 550: int colour, active_colour;
1.10 nicm 551: char buf[16], *ptr;
552: size_t len;
553:
1.19 nicm 554: if (window_pane_index(wp, &idx) != 0)
555: fatalx("index not found");
1.10 nicm 556: len = xsnprintf(buf, sizeof buf, "%u", idx);
557:
558: if (wp->sx < len)
559: return;
1.16 nicm 560: colour = options_get_number(oo, "display-panes-colour");
561: active_colour = options_get_number(oo, "display-panes-active-colour");
1.10 nicm 562:
1.12 nicm 563: px = wp->sx / 2; py = wp->sy / 2;
564: xoff = wp->xoff; yoff = wp->yoff;
1.31 nicm 565:
566: if (top)
567: yoff++;
1.12 nicm 568:
1.10 nicm 569: if (wp->sx < len * 6 || wp->sy < 5) {
1.12 nicm 570: tty_cursor(tty, xoff + px - len / 2, yoff + py);
1.20 nicm 571: goto draw_text;
1.10 nicm 572: }
1.14 nicm 573:
1.10 nicm 574: px -= len * 3;
575: py -= 2;
576:
1.25 nicm 577: memcpy(&gc, &grid_default_cell, sizeof gc);
1.16 nicm 578: if (w->active == wp)
1.37 nicm 579: gc.bg = active_colour;
1.16 nicm 580: else
1.37 nicm 581: gc.bg = colour;
1.30 nicm 582: tty_attributes(tty, &gc, wp);
1.10 nicm 583: for (ptr = buf; *ptr != '\0'; ptr++) {
584: if (*ptr < '0' || *ptr > '9')
585: continue;
586: idx = *ptr - '0';
1.14 nicm 587:
1.10 nicm 588: for (j = 0; j < 5; j++) {
589: for (i = px; i < px + 5; i++) {
1.12 nicm 590: tty_cursor(tty, xoff + i, yoff + py + j);
1.27 nicm 591: if (window_clock_table[idx][j][i - px])
1.11 nicm 592: tty_putc(tty, ' ');
1.10 nicm 593: }
594: }
595: px += 6;
596: }
1.20 nicm 597:
598: len = xsnprintf(buf, sizeof buf, "%ux%u", wp->sx, wp->sy);
599: if (wp->sx < len || wp->sy < 6)
600: return;
601: tty_cursor(tty, xoff + wp->sx - len, yoff);
602:
603: draw_text:
1.25 nicm 604: memcpy(&gc, &grid_default_cell, sizeof gc);
1.20 nicm 605: if (w->active == wp)
1.37 nicm 606: gc.fg = active_colour;
1.20 nicm 607: else
1.37 nicm 608: gc.fg = colour;
1.30 nicm 609: tty_attributes(tty, &gc, wp);
1.20 nicm 610: tty_puts(tty, buf);
611:
612: tty_cursor(tty, 0, 0);
1.1 nicm 613: }