=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/input.c,v retrieving revision 1.189 retrieving revision 1.190 diff -c -r1.189 -r1.190 *** src/usr.bin/tmux/input.c 2021/06/10 07:24:10 1.189 --- src/usr.bin/tmux/input.c 2021/08/11 20:49:55 1.190 *************** *** 1,4 **** ! /* $OpenBSD: input.c,v 1.189 2021/06/10 07:24:10 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: input.c,v 1.190 2021/08/11 20:49:55 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 77,82 **** --- 77,83 ---- struct window_pane *wp; struct bufferevent *event; struct screen_write_ctx ctx; + struct colour_palette *palette; struct input_cell cell; *************** *** 797,809 **** /* Initialise input parser. */ struct input_ctx * ! input_init(struct window_pane *wp, struct bufferevent *bev) { struct input_ctx *ictx; ictx = xcalloc(1, sizeof *ictx); ictx->wp = wp; ictx->event = bev; ictx->input_space = INPUT_BUF_START; ictx->input_buf = xmalloc(INPUT_BUF_START); --- 798,812 ---- /* Initialise input parser. */ struct input_ctx * ! input_init(struct window_pane *wp, struct bufferevent *bev, ! struct colour_palette *palette) { struct input_ctx *ictx; ictx = xcalloc(1, sizeof *ictx); ictx->wp = wp; ictx->event = bev; + ictx->palette = palette; ictx->input_space = INPUT_BUF_START; ictx->input_buf = xmalloc(INPUT_BUF_START); *************** *** 1252,1258 **** input_esc_dispatch(struct input_ctx *ictx) { struct screen_write_ctx *sctx = &ictx->ctx; - struct window_pane *wp = ictx->wp; struct screen *s = sctx->s; struct input_table_entry *entry; --- 1255,1260 ---- *************** *** 1269,1278 **** switch (entry->type) { case INPUT_ESC_RIS: ! if (wp != NULL) ! window_pane_reset_palette(wp); input_reset_cell(ictx); screen_write_reset(sctx); break; case INPUT_ESC_IND: screen_write_linefeed(sctx, 0, ictx->cell.cell.bg); --- 1271,1280 ---- switch (entry->type) { case INPUT_ESC_RIS: ! colour_palette_clear(ictx->palette); input_reset_cell(ictx); screen_write_reset(sctx); + screen_write_fullredraw(sctx); break; case INPUT_ESC_IND: screen_write_linefeed(sctx, 0, ictx->cell.cell.bg); *************** *** 1874,1884 **** case 0: case 2: screen_pop_title(sctx->s); ! if (wp != NULL) { ! notify_pane("pane-title-changed", wp); ! server_redraw_window_borders(wp->window); ! server_status_window(wp->window); ! } break; } break; --- 1876,1886 ---- case 0: case 2: screen_pop_title(sctx->s); ! if (wp == NULL) ! break; ! notify_pane("pane-title-changed", wp); ! server_redraw_window_borders(wp->window); ! server_status_window(wp->window); break; } break; *************** *** 2498,2535 **** static void input_osc_4(struct input_ctx *ictx, const char *p) { ! struct window_pane *wp = ictx->wp; ! char *copy, *s, *next = NULL; ! long idx; ! int c; - if (wp == NULL) - return; - copy = s = xstrdup(p); while (s != NULL && *s != '\0') { idx = strtol(s, &next, 10); ! if (*next++ != ';') ! goto bad; ! if (idx < 0 || idx >= 0x100) ! goto bad; s = strsep(&next, ";"); if ((c = input_osc_parse_colour(s)) == -1) { s = next; continue; } ! ! window_pane_set_palette(wp, idx, c); s = next; } ! free(copy); - return; - - bad: - log_debug("bad OSC 4: %s", p); - free(copy); } /* Handle the OSC 10 sequence for setting and querying foreground colour. */ --- 2500,2535 ---- static void input_osc_4(struct input_ctx *ictx, const char *p) { ! char *copy, *s, *next = NULL; ! long idx; ! int c, bad = 0, redraw = 0; copy = s = xstrdup(p); while (s != NULL && *s != '\0') { idx = strtol(s, &next, 10); ! if (*next++ != ';') { ! bad = 1; ! break; ! } ! if (idx < 0 || idx >= 256) { ! bad = 1; ! break; ! } s = strsep(&next, ";"); if ((c = input_osc_parse_colour(s)) == -1) { s = next; continue; } ! if (colour_palette_set(ictx->palette, idx, c)) ! redraw = 1; s = next; } ! if (bad) ! log_debug("bad OSC 4: %s", p); ! if (redraw) ! screen_write_fullredraw(&ictx->ctx); free(copy); } /* Handle the OSC 10 sequence for setting and querying foreground colour. */ *************** *** 2540,2563 **** struct grid_cell defaults; int c; - if (wp == NULL) - return; - if (strcmp(p, "?") == 0) { ! tty_default_colours(&defaults, wp); ! input_osc_colour_reply(ictx, 10, defaults.fg); return; } ! if ((c = input_osc_parse_colour(p)) == -1) ! goto bad; ! wp->fg = c; ! wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED); ! ! return; ! ! bad: ! log_debug("bad OSC 10: %s", p); } /* Handle the OSC 110 sequence for resetting background colour. */ --- 2540,2561 ---- struct grid_cell defaults; int c; if (strcmp(p, "?") == 0) { ! if (wp != NULL) { ! tty_default_colours(&defaults, wp); ! input_osc_colour_reply(ictx, 10, defaults.fg); ! } return; } ! if ((c = input_osc_parse_colour(p)) == -1) { ! log_debug("bad OSC 10: %s", p); ! return; ! } ! ictx->palette->fg = c; ! if (wp != NULL) ! wp->flags |= PANE_STYLECHANGED; ! screen_write_fullredraw(&ictx->ctx); } /* Handle the OSC 110 sequence for resetting background colour. */ *************** *** 2566,2579 **** { struct window_pane *wp = ictx->wp; - if (wp == NULL) - return; - if (*p != '\0') return; ! ! wp->fg = 8; ! wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED); } /* Handle the OSC 11 sequence for setting and querying background colour. */ --- 2564,2575 ---- { struct window_pane *wp = ictx->wp; if (*p != '\0') return; ! ictx->palette->fg = 8; ! if (wp != NULL) ! wp->flags |= PANE_STYLECHANGED; ! screen_write_fullredraw(&ictx->ctx); } /* Handle the OSC 11 sequence for setting and querying background colour. */ *************** *** 2584,2607 **** struct grid_cell defaults; int c; - if (wp == NULL) - return; - if (strcmp(p, "?") == 0) { ! tty_default_colours(&defaults, wp); ! input_osc_colour_reply(ictx, 11, defaults.bg); return; } ! if ((c = input_osc_parse_colour(p)) == -1) ! goto bad; ! wp->bg = c; ! wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED); ! ! return; ! ! bad: ! log_debug("bad OSC 11: %s", p); } /* Handle the OSC 111 sequence for resetting background colour. */ --- 2580,2601 ---- struct grid_cell defaults; int c; if (strcmp(p, "?") == 0) { ! if (wp != NULL) { ! tty_default_colours(&defaults, wp); ! input_osc_colour_reply(ictx, 11, defaults.bg); ! } return; } ! if ((c = input_osc_parse_colour(p)) == -1) { ! log_debug("bad OSC 11: %s", p); ! return; ! } ! ictx->palette->bg = c; ! if (wp != NULL) ! wp->flags |= PANE_STYLECHANGED; ! screen_write_fullredraw(&ictx->ctx); } /* Handle the OSC 111 sequence for resetting background colour. */ *************** *** 2610,2623 **** { struct window_pane *wp = ictx->wp; - if (wp == NULL) - return; - if (*p != '\0') return; ! ! wp->bg = 8; ! wp->flags |= (PANE_REDRAW|PANE_STYLECHANGED); } /* Handle the OSC 52 sequence for setting the clipboard. */ --- 2604,2615 ---- { struct window_pane *wp = ictx->wp; if (*p != '\0') return; ! ictx->palette->bg = 8; ! if (wp != NULL) ! wp->flags |= PANE_STYLECHANGED; ! screen_write_fullredraw(&ictx->ctx); } /* Handle the OSC 52 sequence for setting the clipboard. */ *************** *** 2692,2725 **** static void input_osc_104(struct input_ctx *ictx, const char *p) { ! struct window_pane *wp = ictx->wp; ! char *copy, *s; ! long idx; - if (wp == NULL) - return; - if (*p == '\0') { ! window_pane_reset_palette(wp); return; } copy = s = xstrdup(p); while (*s != '\0') { idx = strtol(s, &s, 10); ! if (*s != '\0' && *s != ';') ! goto bad; ! if (idx < 0 || idx >= 0x100) ! goto bad; ! ! window_pane_unset_palette(wp, idx); if (*s == ';') s++; } ! free(copy); ! return; ! ! bad: ! log_debug("bad OSC 104: %s", p); free(copy); } --- 2684,2718 ---- static void input_osc_104(struct input_ctx *ictx, const char *p) { ! char *copy, *s; ! long idx; ! int bad = 0, redraw = 0; if (*p == '\0') { ! colour_palette_clear(ictx->palette); ! screen_write_fullredraw(&ictx->ctx); return; } copy = s = xstrdup(p); while (*s != '\0') { idx = strtol(s, &s, 10); ! if (*s != '\0' && *s != ';') { ! bad = 1; ! break; ! } ! if (idx < 0 || idx >= 256) { ! bad = 1; ! break; ! } ! if (colour_palette_set(ictx->palette, idx, -1)) ! redraw = 1; if (*s == ';') s++; } ! if (bad) ! log_debug("bad OSC 104: %s", p); ! if (redraw) ! screen_write_fullredraw(&ictx->ctx); free(copy); }