diff options
author | 2020-03-19 13:32:49 +0000 | |
---|---|---|
committer | 2020-03-19 13:32:49 +0000 | |
commit | d215c8e32f6eb1d4a48f6f959dae54e5d619957c (patch) | |
tree | cb79d379f93316dd4074d60b2bbd3410b335eabb | |
parent | Various fixes to copying with select-word and select-line, including (diff) | |
download | wireguard-openbsd-d215c8e32f6eb1d4a48f6f959dae54e5d619957c.tar.xz wireguard-openbsd-d215c8e32f6eb1d4a48f6f959dae54e5d619957c.zip |
Add C position for terminal centre with display-menu -x and -y.
-rw-r--r-- | usr.bin/tmux/cmd-display-menu.c | 9 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 5 |
2 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/tmux/cmd-display-menu.c b/usr.bin/tmux/cmd-display-menu.c index 57d39c48b4b..d22a15e73dc 100644 --- a/usr.bin/tmux/cmd-display-menu.c +++ b/usr.bin/tmux/cmd-display-menu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-display-menu.c,v 1.5 2020/03/18 09:13:49 nicm Exp $ */ +/* $OpenBSD: cmd-display-menu.c,v 1.6 2020/03/19 13:32:49 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -60,6 +60,8 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, *px = 0; else if (strcmp(xp, "R") == 0) *px = c->tty.sx - 1; + else if (strcmp(xp, "C") == 0) + *px = (c->tty.sx - 1) / 2 - w / 2; else if (strcmp(xp, "P") == 0) { tty_window_offset(&c->tty, &ox, &oy, &sx, &sy); if (wp->xoff >= ox) @@ -94,6 +96,8 @@ cmd_display_menu_get_position(struct client *c, struct cmdq_item *item, yp = args_get(args, 'y'); if (yp == NULL) *py = 0; + else if (strcmp(yp, "C") == 0) + *py = (c->tty.sy - 1) / 2 + h / 2; else if (strcmp(yp, "P") == 0) { tty_window_offset(&c->tty, &ox, &oy, &sx, &sy); if (wp->yoff + wp->sy >= oy) @@ -132,7 +136,7 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) struct menu_item menu_item; const char *key; char *title, *name; - int flags, i; + int flags = 0, i; u_int px, py; if ((c = cmd_find_client(item, args_get(args, 'c'), 0)) == NULL) @@ -180,7 +184,6 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) cmd_display_menu_get_position(c, item, args, &px, &py, menu->width + 4, menu->count + 2); - flags = 0; if (!item->shared->mouse.valid) flags |= MENU_NOMOUSE; if (menu_display(menu, flags, item, px, py, c, fs, NULL, NULL) != 0) diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 6a4b469ce69..94b3c9b87db 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.718 2020/03/12 13:48:33 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.719 2020/03/19 13:32:49 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 12 2020 $ +.Dd $Mdocdate: March 19 2020 $ .Dt TMUX 1 .Os .Sh NAME @@ -4918,6 +4918,7 @@ give the position of the menu. Both may be a row or column number, or one of the following special values: .Bl -column "XXXXX" "XXXX" -offset indent .It Sy "Value" Ta Sy "Flag" Ta Sy "Meaning" +.It Li "C" Ta "Both" Ta "The centre of the terminal" .It Li "R" Ta Fl x Ta "The right side of the terminal" .It Li "P" Ta "Both" Ta "The bottom left of the pane" .It Li "M" Ta "Both" Ta "The mouse position" |