Home | History | Annotate | Download | only in dist

Lines Matching defs:ictx

63 	struct input_ctx		*ictx;
769 const struct input_ctx *ictx = key;
772 if (ictx->ch != entry->ch)
773 return (ictx->ch - entry->ch);
774 return (strcmp((const char *)ictx->interm_buf, entry->interm));
779 input_stop_utf8(struct input_ctx *ictx)
781 struct screen_write_ctx *sctx = &ictx->ctx;
784 if (ictx->utf8started) {
785 utf8_copy(&ictx->cell.cell.data, &rc);
786 screen_write_collect_add(sctx, &ictx->cell.cell);
788 ictx->utf8started = 0;
798 struct input_ctx *ictx = arg;
800 log_debug("%s: %s expired" , __func__, ictx->state->name);
801 input_reset(ictx, 0);
806 input_start_ground_timer(struct input_ctx *ictx)
810 event_del(&ictx->ground_timer);
811 event_add(&ictx->ground_timer, &tv);
816 input_reset_cell(struct input_ctx *ictx)
818 memcpy(&ictx->cell.cell, &grid_default_cell, sizeof ictx->cell.cell);
819 ictx->cell.set = 0;
820 ictx->cell.g0set = ictx->cell.g1set = 0;
822 memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
823 ictx->old_cx = 0;
824 ictx->old_cy = 0;
829 input_save_state(struct input_ctx *ictx)
831 struct screen_write_ctx *sctx = &ictx->ctx;
834 memcpy(&ictx->old_cell, &ictx->cell, sizeof ictx->old_cell);
835 ictx->old_cx = s->cx;
836 ictx->old_cy = s->cy;
837 ictx->old_mode = s->mode;
842 input_restore_state(struct input_ctx *ictx)
844 struct screen_write_ctx *sctx = &ictx->ctx;
846 memcpy(&ictx->cell, &ictx->old_cell, sizeof ictx->cell);
847 if (ictx->old_mode & MODE_ORIGIN)
851 screen_write_cursormove(sctx, ictx->old_cx, ictx->old_cy, 0);
859 struct input_ctx *ictx;
861 ictx = xcalloc(1, sizeof *ictx);
862 ictx->wp = wp;
863 ictx->event = bev;
864 ictx->palette = palette;
866 ictx->input_space = INPUT_BUF_START;
867 ictx->input_buf = xmalloc(INPUT_BUF_START);
869 ictx->since_ground = evbuffer_new();
870 if (ictx->since_ground == NULL)
872 evtimer_set(&ictx->ground_timer, input_ground_timer_callback, ictx);
874 TAILQ_INIT(&ictx->requests);
875 evtimer_set(&ictx->request_timer, input_request_timer_callback, ictx);
877 input_reset(ictx, 0);
878 return (ictx);
883 input_free(struct input_ctx *ictx)
888 for (i = 0; i < ictx->param_list_len; i++) {
889 if (ictx->param_list[i].type == INPUT_STRING)
890 free(ictx->param_list[i].str);
893 TAILQ_FOREACH_SAFE(ir, &ictx->requests, entry, ir1)
895 event_del(&ictx->request_timer);
897 free(ictx->input_buf);
898 evbuffer_free(ictx->since_ground);
899 event_del(&ictx->ground_timer);
901 free(ictx);
906 input_reset(struct input_ctx *ictx, int clear)
908 struct screen_write_ctx *sctx = &ictx->ctx;
909 struct window_pane *wp = ictx->wp;
911 input_reset_cell(ictx);
922 input_clear(ictx);
924 ictx->state = &input_state_ground;
925 ictx->flags = 0;
930 input_pending(struct input_ctx *ictx)
932 return (ictx->since_ground);
937 input_set_state(struct input_ctx *ictx, const struct input_transition *itr)
939 if (ictx->state->exit != NULL)
940 ictx->state->exit(ictx);
941 ictx->state = itr->state;
942 if (ictx->state->enter != NULL)
943 ictx->state->enter(ictx);
948 input_parse(struct input_ctx *ictx, u_char *buf, size_t len)
950 struct screen_write_ctx *sctx = &ictx->ctx;
957 ictx->ch = buf[off++];
960 if (ictx->state != state ||
962 ictx->ch < itr->first ||
963 ictx->ch > itr->last) {
964 itr = ictx->state->transitions;
966 if (ictx->ch >= itr->first &&
967 ictx->ch <= itr->last)
976 state = ictx->state;
992 if (itr->handler != NULL && itr->handler(ictx) != 0)
997 input_set_state(ictx, itr);
1000 if (ictx->state != &input_state_ground)
1001 evbuffer_add(ictx->since_ground, &ictx->ch, 1);
1021 struct input_ctx *ictx = wp->ictx;
1022 struct screen_write_ctx *sctx = &ictx->ctx;
1041 ictx->state->name, len, (int)len, buf);
1043 input_parse(ictx, buf, len);
1049 input_parse_screen(struct input_ctx *ictx, struct screen *s,
1052 struct screen_write_ctx *sctx = &ictx->ctx;
1058 input_parse(ictx, buf, len);
1064 input_split(struct input_ctx *ictx)
1071 for (i = 0; i < ictx->param_list_len; i++) {
1072 if (ictx->param_list[i].type == INPUT_STRING)
1073 free(ictx->param_list[i].str);
1075 ictx->param_list_len = 0;
1077 if (ictx->param_len == 0)
1079 ip = &ictx->param_list[0];
1081 ptr = (char *)ictx->param_buf;
1096 ip = &ictx->param_list[++ictx->param_list_len];
1097 if (ictx->param_list_len == nitems(ictx->param_list))
1101 for (i = 0; i < ictx->param_list_len; i++) {
1102 ip = &ictx->param_list[i];
1116 input_get(struct input_ctx *ictx, u_int validx, int minval, int defval)
1121 if (validx >= ictx->param_list_len)
1123 ip = &ictx->param_list[validx];
1136 input_send_reply(struct input_ctx *ictx, const char *reply)
1138 struct bufferevent *bev = ictx->event;
1148 input_reply(struct input_ctx *ictx, int add, const char *fmt, ...)
1158 if (add && !TAILQ_EMPTY(&ictx->requests)) {
1159 ir = input_make_request(ictx, INPUT_REQUEST_QUEUE);
1162 input_send_reply(ictx, reply);
1169 input_clear(struct input_ctx *ictx)
1171 event_del(&ictx->ground_timer);
1173 *ictx->interm_buf = '\0';
1174 ictx->interm_len = 0;
1176 *ictx->param_buf = '\0';
1177 ictx->param_len = 0;
1179 *ictx->input_buf = '\0';
1180 ictx->input_len = 0;
1182 ictx->input_end = INPUT_END_ST;
1184 ictx->flags &= ~INPUT_DISCARD;
1189 input_ground(struct input_ctx *ictx)
1191 event_del(&ictx->ground_timer);
1192 evbuffer_drain(ictx->since_ground, EVBUFFER_LENGTH(ictx->since_ground));
1194 if (ictx->input_space > INPUT_BUF_START) {
1195 ictx->input_space = INPUT_BUF_START;
1196 ictx->input_buf = xrealloc(ictx->input_buf, INPUT_BUF_START);
1202 ictx)
1204 struct screen_write_ctx *sctx = &ictx->ctx;
1207 input_stop_utf8(ictx); /* can't be valid UTF-8 */
1209 set = ictx->cell.set == 0 ? ictx->cell.g0set : ictx->cell.g1set;
1211 ictx->cell.cell.attr |= GRID_ATTR_CHARSET;
1213 ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;
1214 utf8_set(&ictx->cell.cell.data, ictx->ch);
1215 screen_write_collect_add(sctx, &ictx->cell.cell);
1217 utf8_copy(&ictx->last, &ictx->cell.cell.data);
1218 ictx->flags |= INPUT_LAST;
1220 ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;
1227 input_intermediate(struct input_ctx *ictx)
1229 if (ictx->interm_len == (sizeof ictx->interm_buf) - 1)
1230 ictx->flags |= INPUT_DISCARD;
1232 ictx->interm_buf[ictx->interm_len++] = ictx->ch;
1233 ictx->interm_buf[ictx->interm_len] = '\0';
1241 input_parameter(struct input_ctx *ictx)
1243 if (ictx->param_len == (sizeof ictx->param_buf) - 1)
1244 ictx->flags |= INPUT_DISCARD;
1246 ictx->param_buf[ictx->param_len++] = ictx->ch;
1247 ictx->param_buf[ictx->param_len] = '\0';
1255 input_input(struct input_ctx *ictx)
1259 available = ictx->input_space;
1260 while (ictx->input_len + 1 >= available) {
1263 ictx->flags |= INPUT_DISCARD;
1266 ictx->input_buf = xrealloc(ictx->input_buf, available);
1267 ictx->input_space = available;
1269 ictx->input_buf[ictx->input_len++] = ictx->ch;
1270 ictx->input_buf[ictx->input_len] = '\0';
1277 input_c0_dispatch(struct input_ctx *ictx)
1279 struct screen_write_ctx *sctx = &ictx->ctx;
1280 struct window_pane *wp = ictx->wp;
1287 input_stop_utf8(ictx); /* can't be valid UTF-8 */
1289 log_debug("%s: '%c'", __func__, ictx->ch);
1291 switch (ictx->ch) {
1335 screen_write_linefeed(sctx, 0, ictx->cell.cell.bg);
1343 ictx->cell.set = 1;
1346 ictx->cell.set = 0;
1349 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1353 ictx->flags &= ~INPUT_LAST;
1359 input_esc_dispatch(struct input_ctx *ictx)
1361 struct screen_write_ctx *sctx = &ictx->ctx;
1365 if (ictx->flags & INPUT_DISCARD)
1367 log_debug("%s: '%c', %s", __func__, ictx->ch, ictx->interm_buf);
1369 entry = bsearch(ictx, input_esc_table, nitems(input_esc_table),
1372 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1378 colour_palette_clear(ictx->palette);
1379 input_reset_cell(ictx);
1384 screen_write_linefeed(sctx, 0, ictx->cell.cell.bg);
1388 screen_write_linefeed(sctx, 0, ictx->cell.cell.bg);
1395 screen_write_reverseindex(sctx, ictx->cell.cell.bg);
1404 input_save_state(ictx);
1407 input_restore_state(ictx);
1413 ictx->cell.g0set = 1;
1416 ictx->cell.g0set = 0;
1419 ictx->cell.g1set = 1;
1422 ictx->cell.g1set = 0;
1429 ictx->flags &= ~INPUT_LAST;
1435 input_csi_dispatch(struct input_ctx *ictx)
1437 struct screen_write_ctx *sctx = &ictx->ctx;
1442 u_int cx, bg = ictx->cell.cell.bg;
1444 if (ictx->flags & INPUT_DISCARD)
1447 log_debug("%s: '%c' \"%s\" \"%s\"", __func__, ictx->ch,
1448 ictx->interm_buf, ictx->param_buf);
1450 if (input_split(ictx) != 0)
1453 entry = bsearch(ictx, input_csi_table, nitems(input_csi_table),
1456 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1466 n = input_get(ictx, 0, 1, 1);
1477 n = input_get(ictx, 0, 1, 1);
1482 n = input_get(ictx, 0, 1, 1);
1487 n = input_get(ictx, 0, 1, 1);
1492 n = input_get(ictx, 0, 1, 1);
1493 m = input_get(ictx, 1, 1, 1);
1498 n = input_get(ictx, 0, 0, 0);
1501 m = input_get(ictx, 1, 0, 0);
1517 n = input_get(ictx, 0, 0, 0);
1531 input_csi_dispatch_winops(ictx);
1534 n = input_get(ictx, 0, 1, 1);
1539 n = input_get(ictx, 0, 1, 1);
1546 n = input_get(ictx, 0, 1, 1);
1553 switch (input_get(ictx, 0, 0, 0)) {
1558 input_reply(ictx, 1, "\033[?1;2;4c");
1560 input_reply(ictx, 1, "\033[?1;2c");
1564 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1569 switch (input_get(ictx, 0, 0, 0)) {
1573 input_reply(ictx, 1, "\033[>84;0;0c");
1576 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1581 n = input_get(ictx, 0, 1, 1);
1586 n = input_get(ictx, 0, 1, 1);
1591 n = input_get(ictx, 0, 1, 1);
1592 m = input_get(ictx, 1, 1, screen_size_y(s));
1597 n = input_get(ictx, 0, 1, 1);
1602 switch (input_get(ictx, 0, 0, 0)) {
1604 input_report_current_theme(ictx);
1609 switch (input_get(ictx, 0, 0, 0)) {
1615 if (ictx->wp != NULL)
1616 oo = ictx->wp->options;
1624 input_reply(ictx, 1, "\033[?12;%d$y", n);
1628 input_reply(ictx, 1, "\033[?2004;%d$y", n);
1632 input_reply(ictx, 1, "\033[?1004;%d$y", n);
1636 input_reply(ictx, 1, "\033[?1006;%d$y", n);
1639 input_reply(ictx, 1, "\033[?2031;2$y");
1644 switch (input_get(ictx, 0, 0, 0)) {
1648 input_reply(ictx, 1, "\033[0n");
1651 input_reply(ictx, 1, "\033[%u;%uR", s->cy + 1,
1655 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1660 switch (input_get(ictx, 0, 0, 0)) {
1673 if (input_get(ictx, 1, 0, 0) == 0) {
1682 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1687 switch (input_get(ictx, 0, 0, 0)) {
1700 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1705 n = input_get(ictx, 0, 1, 1);
1710 n = input_get(ictx, 0, 1, 1);
1715 n = input_get(ictx, 0, 1, 1);
1720 n = input_get(ictx, 0, 1, 1);
1728 if (~ictx->flags & INPUT_LAST)
1731 set = ictx->cell.set == 0 ? ictx->cell.g0set : ictx->cell.g1set;
1733 ictx->cell.cell.attr |= GRID_ATTR_CHARSET;
1735 ictx->cell.cell.attr &= ~GRID_ATTR_CHARSET;
1736 utf8_copy(&ictx->cell.cell.data, &ictx->last);
1738 screen_write_collect_add(sctx, &ictx->cell.cell);
1741 input_restore_state(ictx);
1744 input_csi_dispatch_rm(ictx);
1747 input_csi_dispatch_rm_private(ictx);
1750 input_save_state(ictx);
1753 input_csi_dispatch_sgr(ictx);
1756 input_csi_dispatch_sm(ictx);
1759 input_csi_dispatch_sm_private(ictx);
1762 input_csi_dispatch_sm_graphics(ictx);
1765 n = input_get(ictx, 0, 1, 1);
1770 n = input_get(ictx, 0, 1, 1);
1775 switch (input_get(ictx, 0, 0, 0)) {
1786 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1791 n = input_get(ictx, 0, 1, 1);
1796 n = input_get(ictx, 0, 0, 0);
1806 n = input_get(ictx, 0, 0, 0);
1808 input_reply(ictx, 1, "\033P>|tmux %s\033\\",
1815 ictx->flags &= ~INPUT_LAST;
1821 input_csi_dispatch_rm(struct input_ctx *ictx)
1823 struct screen_write_ctx *sctx = &ictx->ctx;
1826 for (i = 0; i < ictx->param_list_len; i++) {
1827 switch (input_get(ictx, i, 0, -1)) {
1837 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1845 input_csi_dispatch_rm_private(struct input_ctx *ictx)
1847 struct screen_write_ctx *sctx = &ictx->ctx;
1848 struct grid_cell *gc = &ictx->cell.cell;
1851 for (i = 0; i < ictx->param_list_len; i++) {
1852 switch (input_get(ictx, i, 0, -1)) {
1905 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1913 input_csi_dispatch_sm(struct input_ctx *ictx)
1915 struct screen_write_ctx *sctx = &ictx->ctx;
1918 for (i = 0; i < ictx->param_list_len; i++) {
1919 switch (input_get(ictx, i, 0, -1)) {
1929 log_debug("%s: unknown '%c'", __func__, ictx->ch);
1937 input_csi_dispatch_sm_private(struct input_ctx *ictx)
1939 struct screen_write_ctx *sctx = &ictx->ctx;
1940 struct grid_cell *gc = &ictx->cell.cell;
1943 for (i = 0; i < ictx->param_list_len; i++) {
1944 switch (input_get(ictx, i, 0, -1)) {
1952 screen_write_clearscreen(sctx, ictx->cell.cell.bg);
2003 log_debug("%s: unknown '%c'", __func__, ictx->ch);
2011 input_csi_dispatch_sm_graphics(__unused struct input_ctx *ictx)
2016 if (ictx->param_list_len > 3)
2018 n = input_get(ictx, 0, 0, 0);
2019 m = input_get(ictx, 1, 0, 0);
2020 o = input_get(ictx, 2, 0, 0);
2023 input_reply(ictx, 1, "\033[?%d;0;%uS", n,
2026 input_reply(ictx, 1, "\033[?%d;3;%dS", n, o);
2032 input_csi_dispatch_winops(struct input_ctx *ictx)
2034 struct screen_write_ctx *sctx = &ictx->ctx;
2036 struct window_pane *wp = ictx->wp;
2045 while ((n = input_get(ictx, m, 0, -1)) != -1) {
2062 if (input_get(ictx, m, 0, -1) == -1)
2068 if (input_get(ictx, m, 0, -1) == -1)
2074 input_reply(ictx, 1, "\033[4;%u;%ut", y * w->ypixel,
2080 input_reply(ictx, 1, "\033[5;%u;%ut", y * w->ypixel,
2086 input_reply(ictx, 1, "\033[6;%u;%ut", w->ypixel,
2090 input_reply(ictx, 1, "\033[8;%u;%ut", y, x);
2093 input_reply(ictx, 1, "\033[9;%u;%ut", y, x);
2097 switch (input_get(ictx, m, 0, -1)) {
2108 switch (input_get(ictx, m, 0, -1)) {
2123 log_debug("%s: unknown '%c'", __func__, ictx->ch);
2132 input_csi_dispatch_sgr_256_do(struct input_ctx *ictx, int fgbg, int c)
2134 struct grid_cell *gc = &ictx->cell.cell;
2154 input_csi_dispatch_sgr_256(struct input_ctx *ictx, int fgbg, u_int *i)
2158 c = input_get(ictx, (*i) + 1, 0, -1);
2159 if (input_csi_dispatch_sgr_256_do(ictx, fgbg, c))
2165 input_csi_dispatch_sgr_rgb_do(struct input_ctx *ictx, int fgbg, int r, int g,
2168 struct grid_cell *gc = &ictx->cell.cell;
2188 input_csi_dispatch_sgr_rgb(struct input_ctx *ictx, int fgbg, u_int *i)
2192 r = input_get(ictx, (*i) + 1, 0, -1);
2193 g = input_get(ictx, (*i) + 2, 0, -1);
2194 b = input_get(ictx, (*i) + 3, 0, -1);
2195 if (input_csi_dispatch_sgr_rgb_do(ictx, fgbg, r, g, b))
2201 input_csi_dispatch_sgr_colon(struct input_ctx *ictx, u_int i)
2203 struct grid_cell *gc = &ictx->cell.cell;
2204 char *s = ictx->param_list[i].str, *copy, *ptr, *out;
2276 input_csi_dispatch_sgr_rgb_do(ictx, p[0], p[i], p[i + 1],
2282 input_csi_dispatch_sgr_256_do(ictx, p[0], p[2]);
2289 input_csi_dispatch_sgr(struct input_ctx *ictx)
2291 struct grid_cell *gc = &ictx->cell.cell;
2295 if (ictx->param_list_len == 0) {
2300 for (i = 0; i < ictx->param_list_len; i++) {
2301 if (ictx->param_list[i].type == INPUT_STRING) {
2302 input_csi_dispatch_sgr_colon(ictx, i);
2305 n = input_get(ictx, i, 0, 0);
2311 switch (input_get(ictx, i, 0, -1)) {
2313 input_csi_dispatch_sgr_rgb(ictx, n, &i);
2316 input_csi_dispatch_sgr_256(ictx, n, &i);
2440 input_end_bel(struct input_ctx *ictx)
2444 ictx->input_end = INPUT_END_BEL;
2451 input_enter_dcs(struct input_ctx *ictx)
2455 input_clear(ictx);
2456 input_start_ground_timer(ictx);
2457 ictx->flags &= ~INPUT_LAST;
2462 input_handle_decrqss(struct input_ctx *ictx)
2464 struct window_pane *wp = ictx->wp;
2466 struct screen_write_ctx *sctx = &ictx->ctx;
2467 u_char *buf = ictx->input_buf;
2468 size_t len = ictx->input_len;
2517 input_reply(ictx, 1, "\033P1$r q%d q\033\\", ps);
2522 input_reply(ictx, 1, "\033P0$r\033\\");
2528 input_dcs_dispatch(struct input_ctx *ictx)
2530 struct window_pane *wp = ictx->wp;
2532 struct screen_write_ctx *sctx = &ictx->ctx;
2533 char *buf = (char *)ictx->input_buf;
2534 size_t len = ictx->input_len;
2548 if (ictx->flags & INPUT_DISCARD) {
2555 if (buf[0] == 'q' && ictx->interm_len == 0) {
2556 if (input_split(ictx) != 0)
2558 p2 = input_get(ictx, 1, 0, 0);
2563 screen_write_sixelimage(sctx, si, ictx->cell.cell.bg);
2568 if (ictx->interm_len == 1 && ictx->interm_buf[0] == '$') {
2571 return (input_handle_decrqss(ictx));
2595 input_enter_osc(struct input_ctx *ictx)
2599 input_clear(ictx);
2600 input_start_ground_timer(ictx);
2601 ictx->flags &= ~INPUT_LAST;
2606 input_exit_osc(struct input_ctx *ictx)
2608 struct screen_write_ctx *sctx = &ictx->ctx;
2609 struct window_pane *wp = ictx->wp;
2610 char *p = (char *)ictx->input_buf;
2613 if (ictx->flags & INPUT_DISCARD)
2615 if (ictx->input_len < 1 || *p < '0' || *p > '9')
2619 ictx->input_end == INPUT_END_ST ? "ST" : "BEL");
2641 input_osc_4(ictx, p);
2653 input_osc_8(ictx, p);
2656 input_osc_10(ictx, p);
2659 input_osc_11(ictx, p);
2662 input_osc_12(ictx, p);
2665 input_osc_52(ictx, p);
2668 input_osc_104(ictx, p);
2671 input_osc_110(ictx, p);
2674 input_osc_111(ictx, p);
2677 input_osc_112(ictx, p);
2680 input_osc_133(ictx, p);
2690 input_enter_apc(struct input_ctx *ictx)
2694 input_clear(ictx);
2695 input_start_ground_timer(ictx);
2696 ictx->flags &= ~INPUT_LAST;
2701 input_exit_apc(struct input_ctx *ictx)
2703 struct screen_write_ctx *sctx = &ictx->ctx;
2704 struct window_pane *wp = ictx->wp;
2705 ictx->input_buf;
2707 if (ictx->flags & INPUT_DISCARD)
2722 input_enter_rename(struct input_ctx *ictx)
2726 input_clear(ictx);
2727 input_start_ground_timer(ictx);
2728 ictx->flags &= ~INPUT_LAST;
2733 input_exit_rename(struct input_ctx *ictx)
2735 struct window_pane *wp = ictx->wp;
2738 char *p = (char *)ictx->input_buf;
2742 if (ictx->flags & INPUT_DISCARD)
2744 if (!options_get_number(ictx->wp->options, "allow-rename"))
2752 if (ictx->input_len == 0) {
2760 window_set_name(w, ictx->input_buf);
2768 input_top_bit_set(struct input_ctx *ictx)
2770 struct screen_write_ctx *sctx = &ictx->ctx;
2771 struct utf8_data *ud = &ictx->utf8data;
2773 ictx->flags &= ~INPUT_LAST;
2775 if (!ictx->utf8started) {
2776 ictx->utf8started = 1;
2777 if (utf8_open(ud, ictx->ch) != UTF8_MORE)
2778 input_stop_utf8(ictx);
2782 switch (utf8_append(ud, ictx->ch)) {
2786 input_stop_utf8(ictx);
2791 ictx->utf8started = 0;
2796 utf8_copy(&ictx->cell.cell.data, ud);
2797 screen_write_collect_add(sctx, &ictx->cell.cell);
2799 utf8_copy(&ictx->last, &ictx->cell.cell.data);
2800 ictx->flags |= INPUT_LAST;
2807 input_osc_colour_reply(struct input_ctx *ictx, int add, u_int n, int idx, int c,
2825 input_reply(ictx, add,
2829 input_reply(ictx, add,
2837 input_osc_4(struct input_ctx *ictx, const char *p)
2842 struct colour_palette *palette = ictx->palette;
2860 input_osc_colour_reply(ictx, 1, 4, idx, c,
2861 ictx->input_end);
2865 input_add_request(ictx, INPUT_REQUEST_PALETTE, idx);
2880 screen_write_fullredraw(&ictx->ctx);
2886 input_osc_8(struct input_ctx *ictx, const char *p)
2888 struct hyperlinks *hl = ictx->ctx.s->hyperlinks;
2889 struct grid_cell *gc = &ictx->cell.cell;
2928 input_osc_10(struct input_ctx *ictx, const char *p)
2930 struct window_pane *wp = ictx->wp;
2945 input_osc_colour_reply(ictx, 1, 10, 0, c, ictx->input_end);
2953 if (ictx->palette != NULL) {
2954 ictx->palette->fg = c;
2957 screen_write_fullredraw(&ictx->ctx);
2963 input_osc_110(struct input_ctx *ictx, const char *p)
2965 struct window_pane *wp = ictx->wp;
2969 if (ictx->palette != NULL) {
2970 ictx->palette->fg = 8;
2973 screen_write_fullredraw(&ictx->ctx);
2979 input_osc_11(struct input_ctx *ictx, const char *p)
2981 struct window_pane *wp = ictx->wp;
2988 input_osc_colour_reply(ictx, 1, 11, 0, c, ictx->input_end);
2996 if (ictx->palette != NULL) {
2997 ictx->palette->bg = c;
3000 screen_write_fullredraw(&ictx->ctx);
3006 input_osc_111(struct input_ctx *ictx, const char *p)
3008 struct window_pane *wp = ictx->wp;
3012 if (ictx->palette != NULL) {
3013 ictx->palette->bg = 8;
3016 screen_write_fullredraw(&ictx->ctx);
3022 input_osc_12(struct input_ctx *ictx, const char *p)
3024 struct window_pane *wp = ictx->wp;
3029 c = ictx->ctx.s->ccolour;
3031 c = ictx->ctx.s->default_ccolour;
3032 input_osc_colour_reply(ictx, 1, 12, 0, c, ictx->input_end);
3041 screen_set_cursor_colour(ictx->ctx.s, c);
3046 input_osc_112(struct input_ctx *ictx, const char *p)
3049 screen_set_cursor_colour(ictx->ctx.s, -1);
3054 input_osc_133(struct input_ctx *ictx, const char *p)
3056 struct grid *gd = ictx->ctx.s->grid;
3057 u_int line = ictx->ctx.s->cy + gd->hsize;
3076 input_osc_52(struct input_ctx *ictx, const char *p)
3078 struct window_pane *wp = ictx->wp;
3112 if (ictx->input_end == INPUT_END_BEL)
3113 input_reply_clipboard(ictx->event, buf, len, "\007");
3115 input_reply_clipboard(ictx->event, buf, len, "\033\\");
3139 input_osc_104(struct input_ctx *ictx, const char *p)
3146 colour_palette_clear(ictx->palette);
3147 screen_write_fullredraw(&ictx->ctx);
3162 if (colour_palette_set(ictx->palette, idx, -1))
3170 screen_write_fullredraw(&ictx->ctx);
3211 struct input_ctx *ictx = arg;
3215 TAILQ_FOREACH_SAFE(ir, &ictx->requests, entry, ir1) {
3219 input_send_reply(ir->ictx, ir->data);
3222 if (ictx->request_count != 0)
3223 input_start_request_timer(ictx);
3228 input_start_request_timer(struct input_ctx *ictx)
3232 event_del(&ictx->request_timer);
3233 event_add(&ictx->request_timer, &tv);
3238 input_make_request(struct input_ctx *ictx, enum input_request_type type)
3244 ir->ictx = ictx;
3247 if (++ictx->request_count == 1)
3248 input_start_request_timer(ictx);
3249 TAILQ_INSERT_TAIL(&ictx->requests, ir, entry);
3258 struct input_ctx *ictx = ir->ictx;
3263 ictx->request_count--;
3264 TAILQ_REMOVE(&ictx->requests, ir, entry);
3272 input_add_request(struct input_ctx *ictx, enum input_request_type type, int idx)
3274 struct window_pane *wp = ictx->wp;
3299 ir = input_make_request(ictx, type);
3302 ir->end = ictx->input_end;
3335 TAILQ_FOREACH_SAFE(ir, &found->ictx->requests, entry, ir1) {
3339 input_send_reply(ir->ictx, ir->data);
3341 input_osc_colour_reply(ir->ictx, 0, 4, pd->idx, pd->c, ir->end);
3360 input_report_current_theme(struct input_ctx *ictx)
3362 switch (window_pane_get_theme(ictx->wp)) {
3364 input_reply(ictx, 0, "\033[?997;1n");
3367 input_reply(ictx, 0, "\033[?997;2n");