diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-01-21 08:10:22 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2012-01-21 08:10:22 +0000 |
commit | 2c270a6b49e26f28ddc759b14df2b9f7e88b17a2 (patch) | |
tree | 82d00eb9e4ccffb26c3b9a1c1717701bccb6509b | |
parent | 5c81cd094f9ea00dd2f34fab981bad3010df1427 (diff) |
Add a -R flag to send-keys to reset the terminal. Written ages ago and
Suggested by someone, I forget who.
-rw-r--r-- | usr.bin/tmux/cmd-send-keys.c | 24 | ||||
-rw-r--r-- | usr.bin/tmux/input.c | 14 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 20 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 |
5 files changed, 50 insertions, 19 deletions
diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c index 6e114b0be8a..128b8f64c78 100644 --- a/usr.bin/tmux/cmd-send-keys.c +++ b/usr.bin/tmux/cmd-send-keys.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-send-keys.c,v 1.9 2011/01/04 00:42:47 nicm Exp $ */ +/* $OpenBSD: cmd-send-keys.c,v 1.10 2012/01/21 08:10:21 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -19,6 +19,7 @@ #include <sys/types.h> #include <stdlib.h> +#include <string.h> #include "tmux.h" @@ -30,8 +31,8 @@ int cmd_send_keys_exec(struct cmd *, struct cmd_ctx *); const struct cmd_entry cmd_send_keys_entry = { "send-keys", "send", - "t:", 0, -1, - "[-t target-pane] key ...", + "Rt:", 0, -1, + "[-R] [-t target-pane] key ...", 0, NULL, NULL, @@ -44,12 +45,29 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx) struct args *args = self->args; struct window_pane *wp; struct session *s; + struct input_ctx *ictx; const char *str; int i, key; if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL) return (-1); + if (args_has(args, 'R')) { + ictx = &wp->ictx; + + memcpy(&ictx->cell, &grid_default_cell, sizeof ictx->cell); + memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell); + ictx->old_cx = 0; + ictx->old_cy = 0; + + if (wp->mode == NULL) + screen_write_start(&ictx->ctx, wp, &wp->base); + else + screen_write_start(&ictx->ctx, NULL, &wp->base); + screen_write_reset(&ictx->ctx); + screen_write_stop(&ictx->ctx); + } + for (i = 0; i < args->argc; i++) { str = args->argv[i]; diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index 351b84b94c1..afc16d5099d 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.44 2012/01/20 19:15:40 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.45 2012/01/21 08:10:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -978,17 +978,7 @@ input_esc_dispatch(struct input_ctx *ictx) ictx->old_cx = 0; ictx->old_cy = 0; - screen_reset_tabs(sctx->s); - - screen_write_scrollregion(sctx, 0, screen_size_y(sctx->s) - 1); - - screen_write_insertmode(sctx, 0); - screen_write_kcursormode(sctx, 0); - screen_write_kkeypadmode(sctx, 0); - screen_write_mousemode_off(sctx); - - screen_write_clearscreen(sctx); - screen_write_cursormove(sctx, 0, 0); + screen_write_reset(sctx->s); break; case INPUT_ESC_IND: screen_write_linefeed(sctx, 0); diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index f56c7460ac7..d6de7dce1e0 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.51 2011/10/23 10:16:14 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.52 2012/01/21 08:10:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -46,6 +46,24 @@ screen_write_stop(unused struct screen_write_ctx *ctx) { } + +/* Reset screen state. */ +void +screen_write_reset(struct screen_write_ctx *ctx) +{ + screen_reset_tabs(ctx->s); + + screen_write_scrollregion(ctx, 0, screen_size_y(ctx->s) - 1); + + screen_write_insertmode(ctx, 0); + screen_write_kcursormode(ctx, 0); + screen_write_kkeypadmode(ctx, 0); + screen_write_mousemode_off(ctx); + + screen_write_clearscreen(ctx); + screen_write_cursormove(ctx, 0, 0); +} + /* Write character. */ void screen_write_putc( diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 3ebd4bcba1f..f29772af8cc 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.264 2012/01/20 19:51:28 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.265 2012/01/21 08:10:21 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" @@ -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: January 20 2012 $ +.Dd $Mdocdate: January 21 2012 $ .Dt TMUX 1 .Os .Sh NAME @@ -1634,6 +1634,7 @@ are listed; this may be one of: or .Em emacs-copy . .It Xo Ic send-keys +.Fl R .Op Fl t Ar target-pane .Ar key Ar ... .Xc @@ -1648,6 +1649,9 @@ or ) to send; if the string is not recognised as a key, it is sent as a series of characters. All arguments are sent sequentially from first to last. +The +.Fl R +flag causes the terminal state to be reset. .It Ic send-prefix Op Fl t Ar target-pane Send the prefix key to a window as if it was pressed. If multiple prefix keys are configured, only the first is sent. diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 27015ebb93c..b4e2bd4b309 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.303 2012/01/20 19:54:07 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.304 2012/01/21 08:10:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1832,6 +1832,7 @@ char *grid_view_string_cells(struct grid *, u_int, u_int, u_int); void screen_write_start( struct screen_write_ctx *, struct window_pane *, struct screen *); void screen_write_stop(struct screen_write_ctx *); +void screen_write_reset(struct screen_write_ctx *); size_t printflike2 screen_write_cstrlen(int, const char *, ...); void printflike5 screen_write_cnputs(struct screen_write_ctx *, ssize_t, struct grid_cell *, int, const char *, ...); |