The branch, master has been updated via cf2c0237f49f31763b617e011e4fe73c3e710c9a (commit) from 3d9fd1c7f2724b887ec6d2ea07edf3bf70385d75 (commit)
- Log ----------------------------------------------------------------- commit cf2c0237f49f31763b617e011e4fe73c3e710c9a Author: Nicholas Marriott <nicholas.marri...@gmail.com> Commit: Nicholas Marriott <nicholas.marri...@gmail.com> 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. --- input.c | 37 +++++++++-------- screen-write.c | 120 ++++++++++--------------------------------------------- tmux.h | 10 +---- 3 files changed, 43 insertions(+), 124 deletions(-) diff --git a/input.c b/input.c index 3b8d76b..8846c1c 100644 --- a/input.c +++ b/input.c @@ -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/screen-write.c b/screen-write.c index 04d2b38..87e8493 100644 --- a/screen-write.c +++ b/screen-write.c @@ -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/tmux.h b/tmux.h index f5dc0f7..e10fb62 100644 --- a/tmux.h +++ b/tmux.h @@ -2012,6 +2012,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); @@ -2026,18 +2028,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 *); @@ -2045,7 +2040,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); ----------------------------------------------------------------------- Summary of changes: input.c | 37 +++++++++-------- screen-write.c | 120 ++++++++++--------------------------------------------- tmux.h | 10 +---- 3 files changed, 43 insertions(+), 124 deletions(-) hooks/post-receive -- tmux ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ tmux-cvs mailing list tmux-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-cvs