summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm>2022-09-09 11:02:23 +0000
committernicm <nicm>2022-09-09 11:02:23 +0000
commitf03c3ca6c36cd52ae5ec4ae8cd4fa137cf79aaf3 (patch)
tree061aac267ccd51ff1ed628279bd672ba4e105dcc
parent68dc9af9ac1a8ea332c82fd510b01c46602fa03a (diff)
Add message-line option to control where message and prompt go, from
Varun Kumar E in GitHub issue 3324.
-rw-r--r--options-table.c13
-rw-r--r--status.c37
-rw-r--r--tmux.14
3 files changed, 44 insertions, 10 deletions
diff --git a/options-table.c b/options-table.c
index 377835bb..6fc5a96f 100644
--- a/options-table.c
+++ b/options-table.c
@@ -42,6 +42,9 @@ static const char *options_table_clock_mode_style_list[] = {
static const char *options_table_status_list[] = {
"off", "on", "2", "3", "4", "5", NULL
};
+static const char *options_table_message_line_list[] = {
+ "0", "1", "2", "3", "4", NULL
+};
static const char *options_table_status_keys_list[] = {
"emacs", "vi", NULL
};
@@ -542,13 +545,21 @@ const struct options_table_entry options_table[] = {
"'mode-keys' is set to 'vi'."
},
+ { .name = "message-line",
+ .type = OPTIONS_TABLE_CHOICE,
+ .scope = OPTIONS_TABLE_SESSION,
+ .choices = options_table_message_line_list,
+ .default_num = 0,
+ .text = "Position (line) of messages and the command prompt."
+ },
+
{ .name = "message-style",
.type = OPTIONS_TABLE_STRING,
.scope = OPTIONS_TABLE_SESSION,
.default_str = "bg=yellow,fg=black",
.flags = OPTIONS_TABLE_IS_STYLE,
.separator = ",",
- .text = "Style of the command prompt."
+ .text = "Style of messages and the command prompt."
},
{ .name = "mouse",
diff --git a/status.c b/status.c
index 929276d2..baf6ed2b 100644
--- a/status.c
+++ b/status.c
@@ -263,6 +263,17 @@ status_line_size(struct client *c)
return (s->statuslines);
}
+/* Get the prompt line number for client's session. 1 means at the bottom. */
+static u_int
+status_prompt_line_at(struct client *c)
+{
+ struct session *s = c->session;
+
+ if (c->flags & (CLIENT_STATUSOFF|CLIENT_CONTROL))
+ return (1);
+ return (options_get_number(s->options, "status-prompt-line"));
+}
+
/* Get window at window list position. */
struct style_range *
status_get_range(struct client *c, u_int x, u_int y)
@@ -533,7 +544,7 @@ status_message_redraw(struct client *c)
struct session *s = c->session;
struct screen old_screen;
size_t len;
- u_int lines, offset;
+ u_int lines, offset, messageline;
struct grid_cell gc;
struct format_tree *ft;
@@ -546,6 +557,10 @@ status_message_redraw(struct client *c)
lines = 1;
screen_init(sl->active, c->tty.sx, lines, 0);
+ messageline = status_prompt_line_at(c);
+ if (messageline > lines - 1)
+ messageline = lines - 1;
+
len = screen_write_strlen("%s", c->message_string);
if (len > c->tty.sx)
len = c->tty.sx;
@@ -555,11 +570,11 @@ status_message_redraw(struct client *c)
format_free(ft);
screen_write_start(&ctx, sl->active);
- screen_write_fast_copy(&ctx, &sl->screen, 0, 0, c->tty.sx, lines - 1);
- screen_write_cursormove(&ctx, 0, lines - 1, 0);
+ screen_write_fast_copy(&ctx, &sl->screen, 0, 0, c->tty.sx, lines);
+ screen_write_cursormove(&ctx, 0, messageline, 0);
for (offset = 0; offset < c->tty.sx; offset++)
screen_write_putc(&ctx, &gc, ' ');
- screen_write_cursormove(&ctx, 0, lines - 1, 0);
+ screen_write_cursormove(&ctx, 0, messageline, 0);
if (c->message_ignore_styles)
screen_write_nputs(&ctx, len, &gc, "%s", c->message_string);
else
@@ -695,7 +710,7 @@ status_prompt_redraw(struct client *c)
struct session *s = c->session;
struct screen old_screen;
u_int i, lines, offset, left, start, width;
- u_int pcursor, pwidth;
+ u_int pcursor, pwidth, promptline;
struct grid_cell gc, cursorgc;
struct format_tree *ft;
@@ -708,6 +723,10 @@ status_prompt_redraw(struct client *c)
lines = 1;
screen_init(sl->active, c->tty.sx, lines, 0);
+ promptline = status_prompt_line_at(c);
+ if (promptline > lines - 1)
+ promptline = lines - 1;
+
ft = format_create_defaults(NULL, c, NULL, NULL, NULL);
if (c->prompt_mode == PROMPT_COMMAND)
style_apply(&gc, s->options, "message-command-style", ft);
@@ -723,13 +742,13 @@ status_prompt_redraw(struct client *c)
start = c->tty.sx;
screen_write_start(&ctx, sl->active);
- screen_write_fast_copy(&ctx, &sl->screen, 0, 0, c->tty.sx, lines - 1);
- screen_write_cursormove(&ctx, 0, lines - 1, 0);
+ screen_write_fast_copy(&ctx, &sl->screen, 0, 0, c->tty.sx, lines);
+ screen_write_cursormove(&ctx, 0, promptline, 0);
for (offset = 0; offset < c->tty.sx; offset++)
screen_write_putc(&ctx, &gc, ' ');
- screen_write_cursormove(&ctx, 0, lines - 1, 0);
+ screen_write_cursormove(&ctx, 0, promptline, 0);
format_draw(&ctx, &gc, start, c->prompt_string, NULL, 0);
- screen_write_cursormove(&ctx, start, lines - 1, 0);
+ screen_write_cursormove(&ctx, start, promptline, 0);
left = c->tty.sx - start;
if (left == 0)
diff --git a/tmux.1 b/tmux.1
index bf72cc0c..485b5d3a 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3873,6 +3873,10 @@ For how to specify
see the
.Sx STYLES
section.
+.It Xo Ic message-line
+.Op Ic 0 | 1 | 2 | 3 | 4
+.Xc
+Set line on which status line messages and the command prompt are shown.
.It Ic message-style Ar style
Set status line message style.
This is used for messages and for the command prompt.