summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2022-03-16 17:00:18 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2022-03-16 17:00:18 +0000
commite56c9e28c319bd905c079725f1475ae2a7f98fcd (patch)
treeae451f63c899a0b6a69ef4c0c6b4f2f7008274aa
parentf8c18dd0f846b2dd4e285608bfcceb4e76e20ea4 (diff)
Add an option to set the character used for unused areas of the
terminal, GitHub issue 3110.
-rw-r--r--usr.bin/tmux/options-table.c9
-rw-r--r--usr.bin/tmux/options.c8
-rw-r--r--usr.bin/tmux/screen-redraw.c15
-rw-r--r--usr.bin/tmux/tmux.17
-rw-r--r--usr.bin/tmux/tmux.h68
-rw-r--r--usr.bin/tmux/window.c21
6 files changed, 85 insertions, 43 deletions
diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c
index e73e2ab66d4..224e097652f 100644
--- a/usr.bin/tmux/options-table.c
+++ b/usr.bin/tmux/options-table.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options-table.c,v 1.159 2022/03/08 18:31:46 nicm Exp $ */
+/* $OpenBSD: options-table.c,v 1.160 2022/03/16 17:00:17 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -882,6 +882,13 @@ const struct options_table_entry options_table[] = {
.text = "Style of the marked line in copy mode."
},
+ { .name = "fill-character",
+ .type = OPTIONS_TABLE_STRING,
+ .scope = OPTIONS_TABLE_WINDOW,
+ .default_str = "",
+ .text = "Character used to fill unused parts of window."
+ },
+
{ .name = "main-pane-height",
.type = OPTIONS_TABLE_STRING,
.scope = OPTIONS_TABLE_WINDOW,
diff --git a/usr.bin/tmux/options.c b/usr.bin/tmux/options.c
index 7fcf6c34ab2..f9716babf74 100644
--- a/usr.bin/tmux/options.c
+++ b/usr.bin/tmux/options.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: options.c,v 1.67 2021/11/03 13:37:17 nicm Exp $ */
+/* $OpenBSD: options.c,v 1.68 2022/03/16 17:00:17 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1108,6 +1108,8 @@ options_push_changes(const char *name)
struct window_pane *wp;
int c;
+ log_debug("%s: %s", __func__, name);
+
if (strcmp(name, "automatic-rename") == 0) {
RB_FOREACH(w, windows, &windows) {
if (w->active == NULL)
@@ -1130,6 +1132,10 @@ options_push_changes(const char *name)
&wp->screen->default_mode);
}
}
+ if (strcmp(name, "fill-character") == 0) {
+ RB_FOREACH(w, windows, &windows)
+ window_set_fill_character(w);
+ }
if (strcmp(name, "key-table") == 0) {
TAILQ_FOREACH(loop, &clients, entry)
server_client_set_key_table(loop, NULL);
diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c
index afe8de9022d..710762b0e06 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.94 2022/02/04 11:57:22 nicm Exp $ */
+/* $OpenBSD: screen-redraw.c,v 1.95 2022/03/16 17:00:17 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -47,11 +47,16 @@ enum screen_redraw_border_type {
/* Get cell border character. */
static void
-screen_redraw_border_set(struct window_pane *wp, enum pane_lines pane_lines,
- int cell_type, struct grid_cell *gc)
+screen_redraw_border_set(struct window *w, struct window_pane *wp,
+ enum pane_lines pane_lines, int cell_type, struct grid_cell *gc)
{
u_int idx;
+ if (cell_type == CELL_OUTSIDE && w->fill_character != NULL) {
+ utf8_copy(&gc->data, &w->fill_character[0]);
+ return;
+ }
+
switch (pane_lines) {
case PANE_LINES_NUMBER:
if (cell_type == CELL_OUTSIDE) {
@@ -409,7 +414,7 @@ screen_redraw_make_pane_status(struct client *c, struct window_pane *wp,
else
py = wp->yoff + wp->sy;
cell_type = screen_redraw_type_of_cell(c, px, py, pane_status);
- screen_redraw_border_set(wp, pane_lines, cell_type, &gc);
+ screen_redraw_border_set(w, wp, pane_lines, cell_type, &gc);
screen_write_cell(&ctx, &gc);
}
gc.attr &= ~GRID_ATTR_CHARSET;
@@ -690,7 +695,7 @@ screen_redraw_draw_borders_cell(struct screen_redraw_ctx *ctx, u_int i, u_int j)
screen_redraw_check_is(x, y, pane_status, marked_pane.wp))
gc.attr ^= GRID_ATTR_REVERSE;
}
- screen_redraw_border_set(wp, ctx->pane_lines, cell_type, &gc);
+ screen_redraw_border_set(w, wp, ctx->pane_lines, cell_type, &gc);
if (cell_type == CELL_TOPBOTTOM &&
(c->flags & CLIENT_UTF8) &&
diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1
index 6e180a69146..9702443b297 100644
--- a/usr.bin/tmux/tmux.1
+++ b/usr.bin/tmux/tmux.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: tmux.1,v 1.882 2022/03/08 18:31:46 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.883 2022/03/16 17:00:17 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
@@ -14,7 +14,7 @@
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 8 2022 $
+.Dd $Mdocdate: March 16 2022 $
.Dt TMUX 1
.Os
.Sh NAME
@@ -4114,6 +4114,9 @@ Set clock colour.
.Xc
Set clock hour format.
.Pp
+.It Ic fill-character Ar character
+Set the character used to fill areas of the terminal unused by a window.
+.Pp
.It Ic main-pane-height Ar height
.It Ic main-pane-width Ar width
Set the width or height of the main (left or top) pane in the
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index ccdb6188086..be87e87d8e4 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1164 2022/03/08 18:31:47 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1165 2022/03/16 17:00:17 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1069,40 +1069,41 @@ RB_HEAD(window_pane_tree, window_pane);
/* Window structure. */
struct window {
- u_int id;
- void *latest;
+ u_int id;
+ void *latest;
- char *name;
- struct event name_event;
- struct timeval name_time;
+ char *name;
+ struct event name_event;
+ struct timeval name_time;
- struct event alerts_timer;
- struct event offset_timer;
+ struct event alerts_timer;
+ struct event offset_timer;
- struct timeval activity_time;
+ struct timeval activity_time;
- struct window_pane *active;
- struct window_pane *last;
- struct window_panes panes;
+ struct window_pane *active;
+ struct window_pane *last;
+ struct window_panes panes;
- int lastlayout;
- struct layout_cell *layout_root;
- struct layout_cell *saved_layout_root;
- char *old_layout;
+ int lastlayout;
+ struct layout_cell *layout_root;
+ struct layout_cell *saved_layout_root;
+ char *old_layout;
- u_int sx;
- u_int sy;
- u_int manual_sx;
- u_int manual_sy;
- u_int xpixel;
- u_int ypixel;
+ u_int sx;
+ u_int sy;
+ u_int manual_sx;
+ u_int manual_sy;
+ u_int xpixel;
+ u_int ypixel;
- u_int new_sx;
- u_int new_sy;
- u_int new_xpixel;
- u_int new_ypixel;
+ u_int new_sx;
+ u_int new_sy;
+ u_int new_xpixel;
+ u_int new_ypixel;
- int flags;
+ struct utf8_data *fill_character;
+ int flags;
#define WINDOW_BELL 0x1
#define WINDOW_ACTIVITY 0x2
#define WINDOW_SILENCE 0x4
@@ -1111,15 +1112,15 @@ struct window {
#define WINDOW_RESIZE 0x20
#define WINDOW_ALERTFLAGS (WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_SILENCE)
- int alerts_queued;
- TAILQ_ENTRY(window) alerts_entry;
+ int alerts_queued;
+ TAILQ_ENTRY(window) alerts_entry;
- struct options *options;
+ struct options *options;
- u_int references;
- TAILQ_HEAD(, winlink) winlinks;
+ u_int references;
+ TAILQ_HEAD(, winlink) winlinks;
- RB_ENTRY(window) entry;
+ RB_ENTRY(window) entry;
};
RB_HEAD(windows, window);
@@ -2976,6 +2977,7 @@ void *window_pane_get_new_data(struct window_pane *,
struct window_pane_offset *, size_t *);
void window_pane_update_used_data(struct window_pane *,
struct window_pane_offset *, size_t);
+void window_set_fill_character(struct window *);
/* layout.c */
u_int layout_count_cells(struct layout_cell *);
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index e495b0abe38..4aba6e0b3ef 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.278 2022/02/03 07:38:17 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.279 2022/03/16 17:00:17 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -331,6 +331,7 @@ window_create(u_int sx, u_int sy, u_int xpixel, u_int ypixel)
w->id = next_window_id++;
RB_INSERT(windows, &windows, w);
+ window_set_fill_character(w);
window_update_activity(w);
log_debug("%s: @%u create %ux%u (%ux%u)", __func__, w->id, sx, sy,
@@ -362,6 +363,7 @@ window_destroy(struct window *w)
event_del(&w->offset_timer);
options_free(w->options);
+ free(w->fill_character);
free(w->name);
free(w);
@@ -1589,3 +1591,20 @@ window_pane_update_used_data(struct window_pane *wp,
size = EVBUFFER_LENGTH(wp->event->input) - used;
wpo->used += size;
}
+
+void
+window_set_fill_character(struct window *w)
+{
+ const char *value;
+ struct utf8_data *ud;
+
+ free(w->fill_character);
+ w->fill_character = NULL;
+
+ value = options_get_string(w->options, "fill-character");
+ if (*value != '\0' && utf8_isvalid(value)) {
+ ud = utf8_fromcstr(value);
+ if (ud != NULL && ud[0].width == 1)
+ w->fill_character = ud;
+ }
+}