summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/screen-redraw.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-03-18 20:53:34 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-03-18 20:53:34 +0000
commit3bb806a0239745a111db415452d29361b93fed90 (patch)
tree3a29d073f53ee163ee5311948668199e2d401937 /usr.bin/tmux/screen-redraw.c
parent895342f95f7da02f950bdba0f9a4f44e504e00ad (diff)
Extend the #[] style syntax and use that together with previous format
changes to allow the status line to be entirely configured with a single option. Now that it is possible to configure their content, enable the existing code that lets the status line be multiple lines in height. The status option can now take a value of 2, 3, 4 or 5 (as well as the previous on or off) to configure more than one line. The new status-format array option configures the format of each line, the default just references the existing status-* options, although some of the more obscure status options may be eliminated in time. Additions to the #[] syntax are: "align" to specify alignment (left, centre, right), "list" for the window list and "range" to configure ranges of text for the mouse bindings. The "align" keyword can also be used to specify alignment of entries in tree mode and the pane status lines.
Diffstat (limited to 'usr.bin/tmux/screen-redraw.c')
-rw-r--r--usr.bin/tmux/screen-redraw.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c
index c7bc2a0be95..5f4047fa95d 100644
--- a/usr.bin/tmux/screen-redraw.c
+++ b/usr.bin/tmux/screen-redraw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-redraw.c,v 1.58 2019/03/16 19:12:13 nicm Exp $ */
+/* $OpenBSD: screen-redraw.c,v 1.59 2019/03/18 20:53:33 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -274,8 +274,8 @@ screen_redraw_make_pane_status(struct client *c, struct window *w,
struct grid_cell gc;
const char *fmt;
struct format_tree *ft;
- char *out;
- size_t outlen;
+ char *expanded;
+ u_int width, i;
struct screen_write_ctx ctx;
struct screen old;
@@ -289,27 +289,27 @@ screen_redraw_make_pane_status(struct client *c, struct window *w,
ft = format_create(c, NULL, FORMAT_PANE|wp->id, 0);
format_defaults(ft, c, NULL, NULL, wp);
+ expanded = format_expand_time(ft, fmt);
+ wp->status_size = width = wp->sx - 4;
+
memcpy(&old, &wp->status_screen, sizeof old);
- screen_init(&wp->status_screen, wp->sx, 1, 0);
+ screen_init(&wp->status_screen, width, 1, 0);
wp->status_screen.mode = 0;
- out = format_expand(ft, fmt);
- outlen = screen_write_cstrlen("%s", out);
- if (outlen > wp->sx - 4)
- outlen = wp->sx - 4;
- screen_resize(&wp->status_screen, outlen, 1, 0);
-
screen_write_start(&ctx, NULL, &wp->status_screen);
+
+ gc.attr |= GRID_ATTR_CHARSET;
+ for (i = 0; i < width; i++)
+ screen_write_putc(&ctx, &gc, 'q');
+ gc.attr &= ~GRID_ATTR_CHARSET;
+
screen_write_cursormove(&ctx, 0, 0, 0);
- screen_write_clearline(&ctx, 8);
- screen_write_cnputs(&ctx, outlen, &gc, "%s", out);
+ format_draw(&ctx, &gc, width, expanded, NULL);
screen_write_stop(&ctx);
- free(out);
+ free(expanded);
format_free(ft);
- wp->status_size = outlen;
-
if (grid_compare(wp->status_screen.grid, old.grid) == 0) {
screen_free(&old);
return (0);