saved_cursor_[xy] formats as a side-effect).
-/* $OpenBSD: cmd-capture-pane.c,v 1.31 2015/03/31 17:45:10 nicm Exp $ */
+/* $OpenBSD: cmd-capture-pane.c,v 1.32 2015/05/08 16:18:04 nicm Exp $ */
/*
* Copyright (c) 2009 Jonathan Alvarado <radobobo@users.sourceforge.net>
cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
size_t *len)
{
- char *buf, *line, tmp[5];
- size_t linelen;
- u_int i;
+ struct evbuffer *pending;
+ char *buf, *line, tmp[5];
+ size_t linelen;
+ u_int i;
- if (wp->ictx.since_ground == NULL)
+ pending = input_pending(wp);
+ if (pending == NULL)
return (xstrdup(""));
- line = EVBUFFER_DATA(wp->ictx.since_ground);
- linelen = EVBUFFER_LENGTH(wp->ictx.since_ground);
+ line = EVBUFFER_DATA(pending);
+ linelen = EVBUFFER_LENGTH(pending);
buf = xstrdup("");
if (args_has(args, 'C')) {
-/* $OpenBSD: cmd-send-keys.c,v 1.19 2015/04/19 21:34:21 nicm Exp $ */
+/* $OpenBSD: cmd-send-keys.c,v 1.20 2015/05/08 16:18:04 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
struct mouse_event *m = &cmdq->item->mouse;
struct window_pane *wp;
struct session *s;
- struct input_ctx *ictx;
const u_char *str;
int i, key;
return (CMD_RETURN_NORMAL);
}
- 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);
- }
+ if (args_has(args, 'R'))
+ input_reset(wp);
for (i = 0; i < args->argc; i++) {
str = args->argv[i];
-/* $OpenBSD: format.c,v 1.64 2015/05/06 08:35:39 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.65 2015/05/08 16:18:04 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicm@users.sourceforge.net>
format_add(ft, "cursor_y", "%u", wp->base.cy);
format_add(ft, "scroll_region_upper", "%u", wp->base.rupper);
format_add(ft, "scroll_region_lower", "%u", wp->base.rlower);
- format_add(ft, "saved_cursor_x", "%u", wp->ictx.old_cx);
- format_add(ft, "saved_cursor_y", "%u", wp->ictx.old_cy);
format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0);
format_add(ft, "alternate_saved_x", "%u", wp->saved_cx);
-/* $OpenBSD: input.c,v 1.73 2015/03/31 17:45:10 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.74 2015/05/08 16:18:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
* be passed to the underlying teminal(s).
*/
+/* Input parser cell. */
+struct input_cell {
+ struct grid_cell cell;
+ int set;
+ int g0set; /* 1 if ACS */
+ int g1set; /* 1 if ACS */
+};
+
+/* Input parser context. */
+struct input_ctx {
+ struct window_pane *wp;
+ struct screen_write_ctx ctx;
+
+ struct input_cell cell;
+
+ struct input_cell old_cell;
+ u_int old_cx;
+ u_int old_cy;
+
+ u_char interm_buf[4];
+ size_t interm_len;
+
+ u_char param_buf[64];
+ size_t param_len;
+
+#define INPUT_BUF_START 32
+#define INPUT_BUF_LIMIT 1048576
+ u_char *input_buf;
+ size_t input_len;
+ size_t input_space;
+
+ int param_list[24]; /* -1 not present */
+ u_int param_list_len;
+
+ struct utf8_data utf8data;
+
+ int ch;
+ int flags;
+#define INPUT_DISCARD 0x1
+
+ const struct input_state *state;
+
+ /*
+ * All input received since we were last in the ground state. Sent to
+ * control clients on connection.
+ */
+ struct evbuffer *since_ground;
+};
+
/* Helper functions. */
struct input_transition;
int input_split(struct input_ctx *);
void
input_init(struct window_pane *wp)
{
- struct input_ctx *ictx = &wp->ictx;
+ struct input_ctx *ictx;
+
+ ictx = wp->ictx = xcalloc(1, sizeof *ictx);
input_reset_cell(ictx);
void
input_free(struct window_pane *wp)
{
- if (wp == NULL)
- return;
+ struct input_ctx *ictx = wp->ictx;
- free(wp->ictx.input_buf);
- evbuffer_free(wp->ictx.since_ground);
+ free(ictx->input_buf);
+ evbuffer_free(ictx->since_ground);
+
+ free (ictx);
+ wp->ictx = NULL;
+}
+
+/* Reset input state and clear screen. */
+void
+input_reset(struct window_pane *wp)
+{
+ struct input_ctx *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);
+}
+
+/* Return pending data. */
+struct evbuffer *
+input_pending(struct window_pane *wp)
+{
+ return (wp->ictx->since_ground);
}
/* Change input state. */
void
input_set_state(struct window_pane *wp, const struct input_transition *itr)
{
- struct input_ctx *ictx = &wp->ictx;
+ struct input_ctx *ictx = wp->ictx;
if (ictx->state->exit != NULL)
ictx->state->exit(ictx);
void
input_parse(struct window_pane *wp)
{
- struct input_ctx *ictx = &wp->ictx;
+ struct input_ctx *ictx = wp->ictx;
const struct input_transition *itr;
struct evbuffer *evb = wp->event->input;
u_char *buf;
-.\" $OpenBSD: tmux.1,v 1.426 2015/05/06 08:35:39 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.427 2015/05/08 16:18:04 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\"
.\" 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: May 6 2015 $
+.Dd $Mdocdate: May 8 2015 $
.Dt TMUX 1
.Os
.Sh NAME
.It Li "pane_top" Ta "" Ta "Top of pane"
.It Li "pane_tty" Ta "" Ta "Pseudo terminal of pane"
.It Li "pane_width" Ta "" Ta "Width of pane"
-.It Li "saved_cursor_x" Ta "" Ta "Saved cursor X in pane"
-.It Li "saved_cursor_y" Ta "" Ta "Saved cursor Y in pane"
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
-/* $OpenBSD: tmux.h,v 1.506 2015/05/07 08:08:54 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.507 2015/05/08 16:18:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
#define screen_hsize(s) ((s)->grid->hsize)
#define screen_hlimit(s) ((s)->grid->hlimit)
-/* Input parser cell. */
-struct input_cell {
- struct grid_cell cell;
- int set;
- int g0set; /* 1 if ACS */
- int g1set; /* 1 if ACS */
-};
-
-/* Input parser context. */
-struct input_ctx {
- struct window_pane *wp;
- struct screen_write_ctx ctx;
-
- struct input_cell cell;
-
- struct input_cell old_cell;
- u_int old_cx;
- u_int old_cy;
-
- u_char interm_buf[4];
- size_t interm_len;
-
- u_char param_buf[64];
- size_t param_len;
-
-#define INPUT_BUF_START 32
-#define INPUT_BUF_LIMIT 1048576
- u_char *input_buf;
- size_t input_len;
- size_t input_space;
-
- int param_list[24]; /* -1 not present */
- u_int param_list_len;
-
- struct utf8_data utf8data;
-
- int ch;
- int flags;
-#define INPUT_DISCARD 0x1
-
- const struct input_state *state;
-
- /*
- * All input received since we were last in the ground state. Sent to
- * control clients on connection.
- */
- struct evbuffer *since_ground;
-};
-
/*
* Window mode. Windows can be in several modes and this is used to call the
* right function to handle input and output.
};
/* Child window structure. */
+struct input_ctx;
struct window_pane {
u_int id;
u_int active_point;
int fd;
struct bufferevent *event;
- struct input_ctx ictx;
+ struct input_ctx *ictx;
struct grid_cell colgc;
/* input.c */
void input_init(struct window_pane *);
void input_free(struct window_pane *);
+void input_reset(struct window_pane *);
+struct evbuffer *input_pending(struct window_pane *);
void input_parse(struct window_pane *);
/* input-key.c */