=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/status.c,v retrieving revision 1.157 retrieving revision 1.158 diff -c -r1.157 -r1.158 *** src/usr.bin/tmux/status.c 2017/01/05 09:07:16 1.157 --- src/usr.bin/tmux/status.c 2017/01/06 11:57:03 1.158 *************** *** 1,4 **** ! /* $OpenBSD: status.c,v 1.157 2017/01/05 09:07:16 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: status.c,v 1.158 2017/01/06 11:57:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 657,663 **** /* Enable status line prompt. */ void status_prompt_set(struct client *c, const char *msg, const char *input, ! int (*callbackfn)(void *, const char *), void (*freefn)(void *), void *data, int flags) { struct format_tree *ft; --- 657,663 ---- /* Enable status line prompt. */ void status_prompt_set(struct client *c, const char *msg, const char *input, ! int (*callbackfn)(void *, const char *, int), void (*freefn)(void *), void *data, int flags) { struct format_tree *ft; *************** *** 687,693 **** c->prompt_flags = flags; c->prompt_mode = PROMPT_ENTRY; ! c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE); c->flags |= CLIENT_STATUS; free(tmp); --- 687,694 ---- c->prompt_flags = flags; c->prompt_mode = PROMPT_ENTRY; ! if (~flags & PROMPT_INCREMENTAL) ! c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE); c->flags |= CLIENT_STATUS; free(tmp); *************** *** 976,982 **** { struct options *oo = c->session->options; struct paste_buffer *pb; ! char *s, word[64]; const char *histstr, *bufdata, *ws = NULL; u_char ch; size_t size, n, off, idx, bufsize, used; --- 977,983 ---- { struct options *oo = c->session->options; struct paste_buffer *pb; ! char *s, *cp, word[64], prefix = '='; const char *histstr, *bufdata, *ws = NULL; u_char ch; size_t size, n, off, idx, bufsize, used; *************** *** 989,995 **** if (key >= '0' && key <= '9') goto append_key; s = utf8_tocstr(c->prompt_buffer); ! c->prompt_callbackfn(c->prompt_data, s); status_prompt_clear(c); free(s); return (1); --- 990,996 ---- if (key >= '0' && key <= '9') goto append_key; s = utf8_tocstr(c->prompt_buffer); ! c->prompt_callbackfn(c->prompt_data, s, 1); status_prompt_clear(c); free(s); return (1); *************** *** 1013,1040 **** case '\002': /* C-b */ if (c->prompt_index > 0) { c->prompt_index--; ! c->flags |= CLIENT_STATUS; } break; case KEYC_RIGHT: case '\006': /* C-f */ if (c->prompt_index < size) { c->prompt_index++; ! c->flags |= CLIENT_STATUS; } break; case KEYC_HOME: case '\001': /* C-a */ if (c->prompt_index != 0) { c->prompt_index = 0; ! c->flags |= CLIENT_STATUS; } break; case KEYC_END: case '\005': /* C-e */ if (c->prompt_index != size) { c->prompt_index = size; ! c->flags |= CLIENT_STATUS; } break; case '\011': /* Tab */ --- 1014,1041 ---- case '\002': /* C-b */ if (c->prompt_index > 0) { c->prompt_index--; ! break; } break; case KEYC_RIGHT: case '\006': /* C-f */ if (c->prompt_index < size) { c->prompt_index++; ! break; } break; case KEYC_HOME: case '\001': /* C-a */ if (c->prompt_index != 0) { c->prompt_index = 0; ! break; } break; case KEYC_END: case '\005': /* C-e */ if (c->prompt_index != size) { c->prompt_index = size; ! break; } break; case '\011': /* Tab */ *************** *** 1094,1101 **** c->prompt_index = (first - c->prompt_buffer) + strlen(s); free(s); ! c->flags |= CLIENT_STATUS; ! break; case KEYC_BSPACE: case '\010': /* C-h */ if (c->prompt_index != 0) { --- 1095,1101 ---- c->prompt_index = (first - c->prompt_buffer) + strlen(s); free(s); ! goto changed; case KEYC_BSPACE: case '\010': /* C-h */ if (c->prompt_index != 0) { *************** *** 1108,1114 **** sizeof *c->prompt_buffer); c->prompt_index--; } ! c->flags |= CLIENT_STATUS; } break; case KEYC_DC: --- 1108,1114 ---- sizeof *c->prompt_buffer); c->prompt_index--; } ! goto changed; } break; case KEYC_DC: *************** *** 1118,1135 **** c->prompt_buffer + c->prompt_index + 1, (size + 1 - c->prompt_index) * sizeof *c->prompt_buffer); ! c->flags |= CLIENT_STATUS; } break; case '\025': /* C-u */ c->prompt_buffer[0].size = 0; c->prompt_index = 0; ! c->flags |= CLIENT_STATUS; ! break; case '\013': /* C-k */ if (c->prompt_index < size) { c->prompt_buffer[c->prompt_index].size = 0; ! c->flags |= CLIENT_STATUS; } break; case '\027': /* C-w */ --- 1118,1134 ---- c->prompt_buffer + c->prompt_index + 1, (size + 1 - c->prompt_index) * sizeof *c->prompt_buffer); ! goto changed; } break; case '\025': /* C-u */ c->prompt_buffer[0].size = 0; c->prompt_index = 0; ! goto changed; case '\013': /* C-k */ if (c->prompt_index < size) { c->prompt_buffer[c->prompt_index].size = 0; ! goto changed; } break; case '\027': /* C-w */ *************** *** 1161,1168 **** '\0', (c->prompt_index - idx) * sizeof *c->prompt_buffer); c->prompt_index = idx; ! c->flags |= CLIENT_STATUS; ! break; case 'f'|KEYC_ESCAPE: ws = options_get_string(oo, "word-separators"); --- 1160,1166 ---- '\0', (c->prompt_index - idx) * sizeof *c->prompt_buffer); c->prompt_index = idx; ! goto changed; case 'f'|KEYC_ESCAPE: ws = options_get_string(oo, "word-separators"); *************** *** 1185,1192 **** c->prompt_index != 0) c->prompt_index--; ! c->flags |= CLIENT_STATUS; ! break; case 'b'|KEYC_ESCAPE: ws = options_get_string(oo, "word-separators"); --- 1183,1189 ---- c->prompt_index != 0) c->prompt_index--; ! goto changed; case 'b'|KEYC_ESCAPE: ws = options_get_string(oo, "word-separators"); *************** *** 1206,1214 **** break; } } ! ! c->flags |= CLIENT_STATUS; ! break; case KEYC_UP: case '\020': /* C-p */ histstr = status_prompt_up_history(&c->prompt_hindex); --- 1203,1209 ---- break; } } ! goto changed; case KEYC_UP: case '\020': /* C-p */ histstr = status_prompt_up_history(&c->prompt_hindex); *************** *** 1217,1224 **** free(c->prompt_buffer); c->prompt_buffer = utf8_fromcstr(histstr); c->prompt_index = utf8_strlen(c->prompt_buffer); ! c->flags |= CLIENT_STATUS; ! break; case KEYC_DOWN: case '\016': /* C-n */ histstr = status_prompt_down_history(&c->prompt_hindex); --- 1212,1218 ---- free(c->prompt_buffer); c->prompt_buffer = utf8_fromcstr(histstr); c->prompt_index = utf8_strlen(c->prompt_buffer); ! goto changed; case KEYC_DOWN: case '\016': /* C-n */ histstr = status_prompt_down_history(&c->prompt_hindex); *************** *** 1227,1234 **** free(c->prompt_buffer); c->prompt_buffer = utf8_fromcstr(histstr); c->prompt_index = utf8_strlen(c->prompt_buffer); ! c->flags |= CLIENT_STATUS; ! break; case '\031': /* C-y */ if ((pb = paste_get_top(NULL)) == NULL) break; --- 1221,1227 ---- free(c->prompt_buffer); c->prompt_buffer = utf8_fromcstr(histstr); c->prompt_index = utf8_strlen(c->prompt_buffer); ! goto changed; case '\031': /* C-y */ if ((pb = paste_get_top(NULL)) == NULL) break; *************** *** 1259,1267 **** } c->prompt_index += n; } ! ! c->flags |= CLIENT_STATUS; ! break; case '\024': /* C-t */ idx = c->prompt_index; if (idx < size) --- 1252,1258 ---- } c->prompt_index += n; } ! goto changed; case '\024': /* C-t */ idx = c->prompt_index; if (idx < size) *************** *** 1272,1278 **** &c->prompt_buffer[idx - 1]); utf8_copy(&c->prompt_buffer[idx - 1], &tmp); c->prompt_index = idx; ! c->flags |= CLIENT_STATUS; } break; case '\r': --- 1263,1269 ---- &c->prompt_buffer[idx - 1]); utf8_copy(&c->prompt_buffer[idx - 1], &tmp); c->prompt_index = idx; ! goto changed; } break; case '\r': *************** *** 1280,1296 **** s = utf8_tocstr(c->prompt_buffer); if (*s != '\0') status_prompt_add_history(s); ! if (c->prompt_callbackfn(c->prompt_data, s) == 0) status_prompt_clear(c); free(s); break; case '\033': /* Escape */ case '\003': /* C-c */ ! if (c->prompt_callbackfn(c->prompt_data, NULL) == 0) status_prompt_clear(c); break; } append_key: if (key <= 0x1f || key >= KEYC_BASE) return (0); --- 1271,1304 ---- s = utf8_tocstr(c->prompt_buffer); if (*s != '\0') status_prompt_add_history(s); ! if (c->prompt_callbackfn(c->prompt_data, s, 1) == 0) status_prompt_clear(c); free(s); break; case '\033': /* Escape */ case '\003': /* C-c */ ! if (c->prompt_callbackfn(c->prompt_data, NULL, 1) == 0) status_prompt_clear(c); break; + case '\022': /* C-r */ + if (c->prompt_flags & PROMPT_INCREMENTAL) { + prefix = '-'; + goto changed; + } + break; + case '\023': /* C-s */ + if (c->prompt_flags & PROMPT_INCREMENTAL) { + prefix = '+'; + goto changed; + } + break; + default: + goto append_key; } + c->flags |= CLIENT_STATUS; + return (0); + append_key: if (key <= 0x1f || key >= KEYC_BASE) return (0); *************** *** 1317,1328 **** s = utf8_tocstr(c->prompt_buffer); if (strlen(s) != 1) status_prompt_clear(c); ! else if (c->prompt_callbackfn(c->prompt_data, s) == 0) status_prompt_clear(c); free(s); } c->flags |= CLIENT_STATUS; return (0); } --- 1325,1344 ---- s = utf8_tocstr(c->prompt_buffer); if (strlen(s) != 1) status_prompt_clear(c); ! else if (c->prompt_callbackfn(c->prompt_data, s, 1) == 0) status_prompt_clear(c); free(s); } + changed: c->flags |= CLIENT_STATUS; + if (c->prompt_flags & PROMPT_INCREMENTAL) { + s = utf8_tocstr(c->prompt_buffer); + xasprintf(&cp, "%c%s", prefix, s); + c->prompt_callbackfn(c->prompt_data, cp, 0); + free(cp); + free(s); + } return (0); }