summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-12-16 22:05:36 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-12-16 22:05:36 +0000
commitcd6f2473c8e7811810fbcb57031b24cbf518bcb9 (patch)
treecd6cc31fc6903d25253677d5782deba29e7bd4f9
parent09f39036ebf547330ea5091c446620612687e39f (diff)
send-keys -R should reset the input parser to ground state (so it can be
used to escape from, for example, printf '\033]2;').
-rw-r--r--usr.bin/tmux/cmd-send-keys.c4
-rw-r--r--usr.bin/tmux/input.c46
-rw-r--r--usr.bin/tmux/tmux.h4
3 files changed, 28 insertions, 26 deletions
diff --git a/usr.bin/tmux/cmd-send-keys.c b/usr.bin/tmux/cmd-send-keys.c
index a79d8e1c047..adc59f0cdfb 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.26 2015/12/14 00:31:54 nicm Exp $ */
+/* $OpenBSD: cmd-send-keys.c,v 1.27 2015/12/16 22:05:35 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -86,7 +86,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_q *cmdq)
}
if (args_has(args, 'R'))
- input_reset(wp);
+ input_reset(wp, 1);
for (i = 0; i < args->argc; i++) {
literal = args_has(args, 'l');
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c
index e5521c885d8..896e8147a7e 100644
--- a/usr.bin/tmux/input.c
+++ b/usr.bin/tmux/input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: input.c,v 1.96 2015/11/23 23:47:57 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.97 2015/12/16 22:05:35 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -762,24 +762,12 @@ input_init(struct window_pane *wp)
ictx = wp->ictx = xcalloc(1, sizeof *ictx);
- input_reset_cell(ictx);
-
- *ictx->interm_buf = '\0';
- ictx->interm_len = 0;
-
- *ictx->param_buf = '\0';
- ictx->param_len = 0;
-
ictx->input_space = INPUT_BUF_START;
ictx->input_buf = xmalloc(INPUT_BUF_START);
- *ictx->input_buf = '\0';
- ictx->input_len = 0;
-
- ictx->state = &input_state_ground;
- ictx->flags = 0;
-
ictx->since_ground = evbuffer_new();
+
+ input_reset(wp, 0);
}
/* Destroy input parser. */
@@ -797,18 +785,32 @@ input_free(struct window_pane *wp)
/* Reset input state and clear screen. */
void
-input_reset(struct window_pane *wp)
+input_reset(struct window_pane *wp, int clear)
{
struct input_ctx *ictx = wp->ictx;
input_reset_cell(ictx);
- 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);
+ if (clear) {
+ 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);
+ }
+
+ *ictx->interm_buf = '\0';
+ ictx->interm_len = 0;
+
+ *ictx->param_buf = '\0';
+ ictx->param_len = 0;
+
+ *ictx->input_buf = '\0';
+ ictx->input_len = 0;
+
+ ictx->state = &input_state_ground;
+ ictx->flags = 0;
}
/* Return pending data. */
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 6927db42dfa..753e68baf44 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.613 2015/12/16 21:50:37 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.614 2015/12/16 22:05:35 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1937,7 +1937,7 @@ void recalculate_sizes(void);
/* input.c */
void input_init(struct window_pane *);
void input_free(struct window_pane *);
-void input_reset(struct window_pane *);
+void input_reset(struct window_pane *, int);
struct evbuffer *input_pending(struct window_pane *);
void input_parse(struct window_pane *);