aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd-refresh-client.c78
-rw-r--r--key-bindings.c5
-rw-r--r--key-string.c2
-rw-r--r--tmux.134
-rw-r--r--tmux.h4
-rw-r--r--tty.c13
6 files changed, 125 insertions, 11 deletions
diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c
index df1d2135..fab6f7ac 100644
--- a/cmd-refresh-client.c
+++ b/cmd-refresh-client.c
@@ -18,6 +18,8 @@
#include <sys/types.h>
+#include <stdlib.h>
+
#include "tmux.h"
/*
@@ -31,8 +33,8 @@ const struct cmd_entry cmd_refresh_client_entry = {
.name = "refresh-client",
.alias = "refresh",
- .args = { "C:St:", 0, 0 },
- .usage = "[-S] [-C size] " CMD_TARGET_CLIENT_USAGE,
+ .args = { "cC:DLRSt:U", 0, 1 },
+ .usage = "[-DLRSU] [-C size] " CMD_TARGET_CLIENT_USAGE " [adjustment]",
.flags = CMD_AFTERHOOK,
.exec = cmd_refresh_client_exec
@@ -43,23 +45,77 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
struct client *c;
- const char *size;
- u_int w, h;
+ struct tty *tty;
+ struct window *w;
+ const char *size, *errstr;
+ u_int x, y, adjust;
if ((c = cmd_find_client(item, args_get(args, 't'), 0)) == NULL)
return (CMD_RETURN_ERROR);
+ tty = &c->tty;
+
+ if (args_has(args, 'c') ||
+ args_has(args, 'L') ||
+ args_has(args, 'R') ||
+ args_has(args, 'U') ||
+ args_has(args, 'D'))
+ {
+ if (args->argc == 0)
+ adjust = 1;
+ else {
+ adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
+ if (errstr != NULL) {
+ cmdq_error(item, "adjustment %s", errstr);
+ return (CMD_RETURN_ERROR);
+ }
+ }
+
+ if (args_has(args, 'c'))
+ c->pan_window = NULL;
+ else {
+ w = c->session->curw->window;
+ if (c->pan_window != w) {
+ c->pan_window = w;
+ c->pan_ox = tty->oox;
+ c->pan_oy = tty->ooy;
+ }
+ if (args_has(args, 'L')) {
+ if (c->pan_ox > adjust)
+ c->pan_ox -= adjust;
+ else
+ c->pan_ox = 0;
+ } else if (args_has(args, 'R')) {
+ c->pan_ox += adjust;
+ if (c->pan_ox > w->sx - tty->osx)
+ c->pan_ox = w->sx - tty->osx;
+ } else if (args_has(args, 'U')) {
+ if (c->pan_oy > adjust)
+ c->pan_oy -= adjust;
+ else
+ c->pan_oy = 0;
+ } else if (args_has(args, 'D')) {
+ c->pan_oy += adjust;
+ if (c->pan_oy > w->sy - tty->osy)
+ c->pan_oy = w->sy - tty->osy;
+ }
+ }
+ tty_update_client_offset(c);
+ server_redraw_client(c);
+ return (CMD_RETURN_NORMAL);
+ }
if (args_has(args, 'C')) {
if ((size = args_get(args, 'C')) == NULL) {
cmdq_error(item, "missing size");
return (CMD_RETURN_ERROR);
}
- if (sscanf(size, "%u,%u", &w, &h) != 2) {
+ if (sscanf(size, "%u,%u", &x, &y) != 2 &&
+ sscanf(size, "%ux%u", &x, &y)) {
cmdq_error(item, "bad size argument");
return (CMD_RETURN_ERROR);
}
- if (w < PANE_MINIMUM || w > 5000 ||
- h < PANE_MINIMUM || h > 5000) {
+ if (x < WINDOW_MINIMUM || x > WINDOW_MAXIMUM ||
+ y < WINDOW_MINIMUM || y > WINDOW_MAXIMUM) {
cmdq_error(item, "size too small or too big");
return (CMD_RETURN_ERROR);
}
@@ -67,16 +123,18 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item)
cmdq_error(item, "not a control client");
return (CMD_RETURN_ERROR);
}
- tty_set_size(&c->tty, w, h);
+ tty_set_size(&c->tty, x, y);
c->flags |= CLIENT_SIZECHANGED;
recalculate_sizes();
- } else if (args_has(args, 'S')) {
+ return (CMD_RETURN_NORMAL);
+ }
+
+ if (args_has(args, 'S')) {
c->flags |= CLIENT_STATUSFORCE;
server_status_client(c);
} else {
c->flags |= CLIENT_STATUSFORCE;
server_redraw_client(c);
}
-
return (CMD_RETURN_NORMAL);
}
diff --git a/key-bindings.c b/key-bindings.c
index c717f5ae..fbc54fb8 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -258,6 +258,11 @@ key_bindings_init(void)
"bind M-n next-window -a",
"bind M-o rotate-window -D",
"bind M-p previous-window -a",
+ "bind -r S-Up refresh-client -U 10",
+ "bind -r S-Down refresh-client -D 10",
+ "bind -r S-Left refresh-client -L 10",
+ "bind -r S-Right refresh-client -R 10",
+ "bind -r DC refresh-client -c",
"bind -r M-Up resize-pane -U 5",
"bind -r M-Down resize-pane -D 5",
"bind -r M-Left resize-pane -L 5",
diff --git a/key-string.c b/key-string.c
index 45073efd..344881c7 100644
--- a/key-string.c
+++ b/key-string.c
@@ -43,7 +43,9 @@ static const struct {
{ "F11", KEYC_F11 },
{ "F12", KEYC_F12 },
{ "IC", KEYC_IC },
+ { "Insert", KEYC_IC },
{ "DC", KEYC_DC },
+ { "Delete", KEYC_DC },
{ "Home", KEYC_HOME },
{ "End", KEYC_END },
{ "NPage", KEYC_NPAGE },
diff --git a/tmux.1 b/tmux.1
index e240f7ee..08bfdd9e 100644
--- a/tmux.1
+++ b/tmux.1
@@ -930,9 +930,11 @@ is used, the
.Ic update-environment
option will not be applied.
.It Xo Ic refresh-client
-.Op Fl C Ar width,height
+.Op Fl cDLRU
+.Op Fl C Ar XxY
.Op Fl S
.Op Fl t Ar target-client
+.Op Ar adjustment
.Xc
.D1 (alias: Ic refresh )
Refresh the current client if bound to a key, or a single client if one is given
@@ -942,6 +944,36 @@ If
.Fl S
is specified, only update the client's status line.
.Pp
+The
+.Fl U ,
+.Fl D ,
+.Fl L
+.Fl R ,
+and
+.Fl c
+flags allow the visible portion of a window which is larger than the client
+to be changed.
+.Fl U
+moves the visible part up by
+.Ar adjustment
+rows and
+.Fl D
+down,
+.Fl L
+left by
+.Ar adjustment
+columns and
+.Fl R
+right.
+.Fl c
+returns to tracking the cursor automatically.
+If
+.Ar adjustment
+is omitted, 1 is used.
+Note that the visible position is a property of the client not of the
+window, changing the current window in the attached session will reset
+it.
+.Pp
.Fl C
sets the width and height of a control client.
.It Xo Ic rename-session
diff --git a/tmux.h b/tmux.h
index f075215c..4f2848ec 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1421,6 +1421,10 @@ struct client {
int references;
+ void *pan_window;
+ u_int pan_ox;
+ u_int pan_oy;
+
TAILQ_ENTRY(client) entry;
};
TAILQ_HEAD(clients, client);
diff --git a/tty.c b/tty.c
index 9a756d1c..a6cfadf9 100644
--- a/tty.c
+++ b/tty.c
@@ -738,12 +738,24 @@ tty_window_offset1(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy)
*oy = 0;
*sx = w->sx;
*sy = w->sy;
+
+ c->pan_window = NULL;
return (0);
}
*sx = tty->sx;
*sy = tty->sy - lines;
+ if (c->pan_window == w) {
+ if (c->pan_ox + *sx > w->sx)
+ c->pan_ox = w->sx - *sx;
+ *ox = c->pan_ox;
+ if (c->pan_oy + *sy > w->sy)
+ c->pan_oy = w->sy - *sy;
+ *oy = c->pan_oy;
+ return (1);
+ }
+
if (~wp->screen->mode & MODE_CURSOR) {
*ox = 0;
*oy = 0;
@@ -766,6 +778,7 @@ tty_window_offset1(struct tty *tty, u_int *ox, u_int *oy, u_int *sx, u_int *sy)
*oy = cy - *sy / 2;
}
+ c->pan_window = NULL;
return (1);
}