diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-21 18:47:57 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2013-03-21 18:47:57 +0000 |
commit | 50a99673eca0870cbd1e6db8f704007d0ca1e958 (patch) | |
tree | 8f5775ee8ee24220d7dfe89271e6ee87f2e0ebdc /usr.bin/tmux | |
parent | 785456b1f958377ea1167320d0cf3863435d833e (diff) |
Instead of loads of little screen_write_*_on and off functions which
just change mode flags, just have screen_write_mode_set and
screen_write_mode_clear.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/input.c | 39 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 122 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 12 |
3 files changed, 46 insertions, 127 deletions
diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index 594066fdbbe..c35e86a73ae 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.58 2013/01/18 02:16:21 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.59 2013/03/21 18:47:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1033,10 +1033,10 @@ input_esc_dispatch(struct input_ctx *ictx) screen_write_reverseindex(sctx); break; case INPUT_ESC_DECKPAM: - screen_write_kkeypadmode(sctx, 1); + screen_write_mode_set(sctx, MODE_KKEYPAD); break; case INPUT_ESC_DECKPNM: - screen_write_kkeypadmode(sctx, 0); + screen_write_mode_clear(sctx, MODE_KKEYPAD); break; case INPUT_ESC_DECSC: memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell); @@ -1232,7 +1232,7 @@ input_csi_dispatch(struct input_ctx *ictx) case INPUT_CSI_RM: switch (input_get(ictx, 0, 0, -1)) { case 4: /* IRM */ - screen_write_insertmode(&ictx->ctx, 0); + screen_write_mode_clear(&ictx->ctx, MODE_INSERT); break; default: log_debug("%s: unknown '%c'", __func__, ictx->ch); @@ -1242,23 +1242,23 @@ input_csi_dispatch(struct input_ctx *ictx) case INPUT_CSI_RM_PRIVATE: switch (input_get(ictx, 0, 0, -1)) { case 1: /* GATM */ - screen_write_kcursormode(&ictx->ctx, 0); + screen_write_mode_clear(&ictx->ctx, MODE_KCURSOR); break; case 3: /* DECCOLM */ screen_write_cursormove(&ictx->ctx, 0, 0); screen_write_clearscreen(&ictx->ctx); break; case 25: /* TCEM */ - screen_write_cursormode(&ictx->ctx, 0); + screen_write_mode_clear(&ictx->ctx, MODE_CURSOR); break; case 1000: case 1001: case 1002: case 1003: - screen_write_mousemode_off(&ictx->ctx); + screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES); break; case 1005: - screen_write_utf8mousemode(&ictx->ctx, 0); + screen_write_mode_clear(&ictx->ctx, MODE_MOUSE_UTF8); break; case 47: case 1047: @@ -1268,7 +1268,7 @@ input_csi_dispatch(struct input_ctx *ictx) window_pane_alternate_off(wp, &ictx->cell, 1); break; case 2004: - screen_write_bracketpaste(&ictx->ctx, 0); + screen_write_mode_clear(&ictx->ctx, MODE_BRACKETPASTE); break; default: log_debug("%s: unknown '%c'", __func__, ictx->ch); @@ -1286,7 +1286,7 @@ input_csi_dispatch(struct input_ctx *ictx) case INPUT_CSI_SM: switch (input_get(ictx, 0, 0, -1)) { case 4: /* IRM */ - screen_write_insertmode(&ictx->ctx, 1); + screen_write_mode_set(&ictx->ctx, MODE_INSERT); break; default: log_debug("%s: unknown '%c'", __func__, ictx->ch); @@ -1296,28 +1296,29 @@ input_csi_dispatch(struct input_ctx *ictx) case INPUT_CSI_SM_PRIVATE: switch (input_get(ictx, 0, 0, -1)) { case 1: /* GATM */ - screen_write_kcursormode(&ictx->ctx, 1); + screen_write_mode_set(&ictx->ctx, MODE_KCURSOR); break; case 3: /* DECCOLM */ screen_write_cursormove(&ictx->ctx, 0, 0); screen_write_clearscreen(&ictx->ctx); break; case 25: /* TCEM */ - screen_write_cursormode(&ictx->ctx, 1); + screen_write_mode_set(&ictx->ctx, MODE_CURSOR); break; case 1000: - screen_write_mousemode_on( - &ictx->ctx, MODE_MOUSE_STANDARD); + screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES); + screen_write_mode_set(&ictx->ctx, MODE_MOUSE_STANDARD); break; case 1002: - screen_write_mousemode_on( - &ictx->ctx, MODE_MOUSE_BUTTON); + screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES); + screen_write_mode_set(&ictx->ctx, MODE_MOUSE_BUTTON); break; case 1003: - screen_write_mousemode_on(&ictx->ctx, MODE_MOUSE_ANY); + screen_write_mode_clear(&ictx->ctx, ALL_MOUSE_MODES); + screen_write_mode_set(&ictx->ctx, MODE_MOUSE_ANY); break; case 1005: - screen_write_utf8mousemode(&ictx->ctx, 1); + screen_write_mode_set(&ictx->ctx, MODE_MOUSE_UTF8); break; case 47: case 1047: @@ -1327,7 +1328,7 @@ input_csi_dispatch(struct input_ctx *ictx) window_pane_alternate_on(wp, &ictx->cell, 1); break; case 2004: - screen_write_bracketpaste(&ictx->ctx, 1); + screen_write_mode_set(&ictx->ctx, MODE_BRACKETPASTE); break; default: log_debug("%s: unknown '%c'", __func__, ictx->ch); diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index cad889d9156..db9559734c1 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.60 2013/01/18 02:16:21 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.61 2013/03/21 18:47:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -52,14 +52,11 @@ screen_write_stop(unused struct screen_write_ctx *ctx) 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); + struct screen *s = ctx->s; - screen_write_insertmode(ctx, 0); - screen_write_kcursormode(ctx, 0); - screen_write_kkeypadmode(ctx, 0); - screen_write_mousemode_off(ctx); + screen_reset_tabs(s); + screen_write_scrollregion(ctx, 0, screen_size_y(s) - 1); + s->mode &= ~(MODE_INSERT|MODE_KCURSOR|MODE_KKEYPAD|ALL_MOUSE_MODES); screen_write_clearscreen(ctx); screen_write_cursormove(ctx, 0, 0); @@ -454,6 +451,24 @@ screen_write_initctx( memcpy(&ttyctx->last_cell, gc, sizeof ttyctx->last_cell); } +/* Set a mode. */ +void +screen_write_mode_set(struct screen_write_ctx *ctx, int mode) +{ + struct screen *s = ctx->s; + + s->mode |= mode; +} + +/* Clear a mode. */ +void +screen_write_mode_clear(struct screen_write_ctx *ctx, int mode) +{ + struct screen *s = ctx->s; + + s->mode &= ~mode; +} + /* Cursor up by ny. */ void screen_write_cursorup(struct screen_write_ctx *ctx, u_int ny) @@ -805,18 +820,6 @@ screen_write_cursormove(struct screen_write_ctx *ctx, u_int px, u_int py) s->cy = py; } -/* Set cursor mode. */ -void -screen_write_cursormode(struct screen_write_ctx *ctx, int state) -{ - struct screen *s = ctx->s; - - if (state) - s->mode |= MODE_CURSOR; - else - s->mode &= ~MODE_CURSOR; -} - /* Reverse index (up with scroll). */ void screen_write_reverseindex(struct screen_write_ctx *ctx) @@ -856,61 +859,6 @@ screen_write_scrollregion( s->rlower = rlower; } -/* Set insert mode. */ -void -screen_write_insertmode(struct screen_write_ctx *ctx, int state) -{ - struct screen *s = ctx->s; - - if (state) - s->mode |= MODE_INSERT; - else - s->mode &= ~MODE_INSERT; -} - -/* Set UTF-8 mouse mode. */ -void -screen_write_utf8mousemode(struct screen_write_ctx *ctx, int state) -{ - struct screen *s = ctx->s; - - if (state) - s->mode |= MODE_MOUSE_UTF8; - else - s->mode &= ~MODE_MOUSE_UTF8; -} - -/* Set mouse mode off. */ -void -screen_write_mousemode_off(struct screen_write_ctx *ctx) -{ - struct screen *s = ctx->s; - - s->mode &= ~ALL_MOUSE_MODES; -} - -/* Set mouse mode on. */ -void -screen_write_mousemode_on(struct screen_write_ctx *ctx, int mode) -{ - struct screen *s = ctx->s; - - s->mode &= ~ALL_MOUSE_MODES; - s->mode |= mode; -} - -/* Set bracketed paste mode. */ -void -screen_write_bracketpaste(struct screen_write_ctx *ctx, int state) -{ - struct screen *s = ctx->s; - - if (state) - s->mode |= MODE_BRACKETPASTE; - else - s->mode &= ~MODE_BRACKETPASTE; -} - /* Line feed. */ void screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped) @@ -945,30 +893,6 @@ screen_write_carriagereturn(struct screen_write_ctx *ctx) s->cx = 0; } -/* Set keypad cursor keys mode. */ -void -screen_write_kcursormode(struct screen_write_ctx *ctx, int state) -{ - struct screen *s = ctx->s; - - if (state) - s->mode |= MODE_KCURSOR; - else - s->mode &= ~MODE_KCURSOR; -} - -/* Set keypad number keys mode. */ -void -screen_write_kkeypadmode(struct screen_write_ctx *ctx, int state) -{ - struct screen *s = ctx->s; - - if (state) - s->mode |= MODE_KKEYPAD; - else - s->mode &= ~MODE_KKEYPAD; -} - /* Clear to end of screen from cursor. */ void screen_write_clearendofscreen(struct screen_write_ctx *ctx) diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 67f84f7a547..52ed2e5773f 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.382 2013/03/21 18:44:47 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.383 2013/03/21 18:47:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -2016,6 +2016,8 @@ void screen_write_putc( void screen_write_copy(struct screen_write_ctx *, struct screen *, u_int, u_int, u_int, u_int); void screen_write_backspace(struct screen_write_ctx *); +void screen_write_mode_set(struct screen_write_ctx *, int); +void screen_write_mode_clear(struct screen_write_ctx *, int); void screen_write_cursorup(struct screen_write_ctx *, u_int); void screen_write_cursordown(struct screen_write_ctx *, u_int); void screen_write_cursorright(struct screen_write_ctx *, u_int); @@ -2030,18 +2032,11 @@ void screen_write_clearline(struct screen_write_ctx *); void screen_write_clearendofline(struct screen_write_ctx *); void screen_write_clearstartofline(struct screen_write_ctx *); void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int); -void screen_write_cursormode(struct screen_write_ctx *, int); void screen_write_reverseindex(struct screen_write_ctx *); void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int); -void screen_write_insertmode(struct screen_write_ctx *, int); -void screen_write_utf8mousemode(struct screen_write_ctx *, int); -void screen_write_mousemode_on(struct screen_write_ctx *, int); -void screen_write_mousemode_off(struct screen_write_ctx *); void screen_write_linefeed(struct screen_write_ctx *, int); void screen_write_linefeedscreen(struct screen_write_ctx *, int); void screen_write_carriagereturn(struct screen_write_ctx *); -void screen_write_kcursormode(struct screen_write_ctx *, int); -void screen_write_kkeypadmode(struct screen_write_ctx *, int); void screen_write_clearendofscreen(struct screen_write_ctx *); void screen_write_clearstartofscreen(struct screen_write_ctx *); void screen_write_clearscreen(struct screen_write_ctx *); @@ -2049,7 +2044,6 @@ void screen_write_clearhistory(struct screen_write_ctx *); void screen_write_cell(struct screen_write_ctx *, const struct grid_cell *); void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int); void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int); -void screen_write_bracketpaste(struct screen_write_ctx *, int); /* screen-redraw.c */ void screen_redraw_screen(struct client *, int, int); |