Remove unused variable in run_prompt_command()
[tig.git] / src / prompt.c
blob0d32dca13034fee40b42ca3be6f7835060af00d4
1 /* Copyright (c) 2006-2014 Jonas Fonseca <jonas.fonseca@gmail.com>
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU General Public License as
5 * published by the Free Software Foundation; either version 2 of
6 * the License, or (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
14 #include "tig/tig.h"
15 #include "tig/view.h"
16 #include "tig/draw.h"
17 #include "tig/display.h"
18 #include "tig/options.h"
19 #include "tig/prompt.h"
20 #include "tig/pager.h"
21 #include "tig/types.h"
23 #ifdef HAVE_READLINE
24 #include <readline/readline.h>
25 #include <readline/history.h>
26 #endif /* HAVE_READLINE */
28 static char *
29 prompt_input(const char *prompt, struct input *input)
31 enum input_status status = INPUT_OK;
32 unsigned char chars_length[SIZEOF_STR];
33 struct key key;
34 size_t promptlen = strlen(prompt);
35 int pos = 0, chars = 0;
37 input->buf[pos] = 0;
39 while (status == INPUT_OK || status == INPUT_SKIP) {
41 update_status("%s%.*s", prompt, pos, input->buf);
43 if (get_input(pos + promptlen, &key, FALSE) == OK) {
44 int len = strlen(key.data.bytes);
46 if (pos + len >= sizeof(input->buf)) {
47 report("Input string too long");
48 return NULL;
51 string_ncopy_do(input->buf + pos, sizeof(input->buf) - pos, key.data.bytes, len);
52 pos += len;
53 chars_length[chars++] = len;
54 status = input->handler(input, &key);
55 if (status != INPUT_OK) {
56 pos -= len;
57 chars--;
58 } else {
59 int changed_pos = strlen(input->buf);
61 if (changed_pos != pos) {
62 pos = changed_pos;
63 chars_length[chars - 1] = changed_pos - (pos - len);
66 } else {
67 status = input->handler(input, &key);
68 if (status == INPUT_DELETE) {
69 int len = chars_length[--chars];
71 pos -= len;
72 status = INPUT_OK;
73 } else {
74 int changed_pos = strlen(input->buf);
76 if (changed_pos != pos) {
77 pos = changed_pos;
78 chars_length[chars++] = changed_pos - pos;
82 input->buf[pos] = 0;
85 report_clear();
87 if (status == INPUT_CANCEL)
88 return NULL;
90 input->buf[pos++] = 0;
92 return input->buf;
95 static enum input_status
96 prompt_default_handler(struct input *input, struct key *key)
98 if (key->modifiers.multibytes)
99 return INPUT_SKIP;
101 switch (key->data.value) {
102 case KEY_RETURN:
103 case KEY_ENTER:
104 case '\n':
105 return *input->buf ? INPUT_STOP : INPUT_CANCEL;
107 case KEY_BACKSPACE:
108 return *input->buf ? INPUT_DELETE : INPUT_CANCEL;
110 case KEY_ESC:
111 return INPUT_CANCEL;
113 default:
114 return INPUT_SKIP;
118 static enum input_status
119 prompt_yesno_handler(struct input *input, struct key *key)
121 unsigned long c = key_to_unicode(key);
123 if (c == 'y' || c == 'Y')
124 return INPUT_STOP;
125 if (c == 'n' || c == 'N')
126 return INPUT_CANCEL;
127 return prompt_default_handler(input, key);
130 bool
131 prompt_yesno(const char *prompt)
133 char prompt2[SIZEOF_STR];
134 struct input input = { prompt_yesno_handler, NULL };
136 if (!string_format(prompt2, "%s [Yy/Nn]", prompt))
137 return FALSE;
139 return !!prompt_input(prompt2, &input);
142 struct incremental_input {
143 struct input input;
144 input_handler handler;
145 bool edit_mode;
148 static enum input_status
149 read_prompt_handler(struct input *input, struct key *key)
151 struct incremental_input *incremental = (struct incremental_input *) input;
153 if (incremental->edit_mode && !key->modifiers.multibytes)
154 return prompt_default_handler(input, key);
156 if (!unicode_width(key_to_unicode(key), 8))
157 return INPUT_SKIP;
159 if (!incremental->handler)
160 return INPUT_OK;
162 return incremental->handler(input, key);
165 char *
166 read_prompt_incremental(const char *prompt, bool edit_mode, input_handler handler, void *data)
168 static struct incremental_input incremental = { { read_prompt_handler } };
170 incremental.input.data = data;
171 incremental.handler = handler;
172 incremental.edit_mode = edit_mode;
174 return prompt_input(prompt, (struct input *) &incremental);
177 #ifdef HAVE_READLINE
178 static void
179 readline_display(void)
181 update_status("%s%s", rl_display_prompt, rl_line_buffer);
182 wrefresh(status_win);
185 static char *
186 readline_variable_generator(const char *text, int state)
188 static const char *vars[] = {
189 #define FORMAT_VAR(name, ifempty, initval) "%(" #name ")"
190 ARGV_ENV_INFO(FORMAT_VAR),
191 #undef FORMAT_VAR
192 NULL
195 static int index, len;
196 const char *name;
197 char *variable = NULL; /* No match */
199 /* If it is a new word to complete, initialize */
200 if (!state) {
201 index = 0;
202 len = strlen(text);
205 /* Return the next name which partially matches */
206 while ((name = vars[index])) {
207 index++;
209 /* Complete or format a variable */
210 if (strncmp(name, text, len) == 0) {
211 if (strlen(name) > len)
212 variable = strdup(name);
213 else
214 variable = argv_format_arg(&argv_env, text);
215 break;
219 return variable;
222 static char *
223 readline_action_generator(const char *text, int state)
225 static const char *actions[] = {
226 "!",
227 "source",
228 "color",
229 "bind",
230 "set",
231 "toggle",
232 "save-display",
233 #define REQ_GROUP(help)
234 #define REQ_(req, help) #req
235 REQ_INFO,
236 #undef REQ_GROUP
237 #undef REQ_
238 NULL
241 static int index, len;
242 const char *name;
243 char *match = NULL; /* No match */
245 /* If it is a new word to complete, initialize */
246 if (!state) {
247 index = 0;
248 len = strlen(text);
251 /* Return the next name which partially matches */
252 while ((name = actions[index])) {
253 name = enum_name(name);
254 index++;
256 if (strncmp(name, text, len) == 0) {
257 /* Ignore exact completion */
258 if (strlen(name) > len)
259 match = strdup(name);
260 break;
264 return match;
267 static char *
268 readline_set_generator(const char *text, int state)
270 static const char *words[] = {
271 #define DEFINE_OPTION_NAME(name, type, flags) #name " = ",
272 OPTION_INFO(DEFINE_OPTION_NAME)
273 #undef DEFINE_OPTION_NAME
274 NULL
277 static int index, len;
278 const char *name;
279 char *match = NULL; /* No match */
281 /* If it is a new word to complete, initialize */
282 if (!state) {
283 index = 0;
284 len = strlen(text);
287 /* Return the next name which partially matches */
288 while ((name = words[index])) {
289 name = enum_name(name);
290 index++;
292 if (strncmp(name, text, len) == 0) {
293 /* Ignore exact completion */
294 if (strlen(name) > len)
295 match = strdup(name);
296 break;
300 return match;
303 static char *
304 readline_toggle_generator(const char *text, int state)
306 static const char **words;
307 static int index, len;
308 const char *name;
309 char *match = NULL; /* No match */
311 if (!words) {
312 /* TODO: Only complete column options that are defined
313 * for the view. */
315 #define DEFINE_OPTION_WORD(name, type, flags) argv_append(&words, #name);
316 #define DEFINE_COLUMN_OPTIONS_WORD(name, type, flags) #name,
317 #define DEFINE_COLUMN_OPTIONS_WORDS(name, id, options) \
318 if (VIEW_COLUMN_##id != VIEW_COLUMN_SECTION) { \
319 const char *vars[] = { \
320 options(DEFINE_COLUMN_OPTIONS_WORD) \
321 }; \
322 char buf[SIZEOF_STR]; \
323 int i; \
324 for (i = 0; i < ARRAY_SIZE(vars); i++) { \
325 if (enum_name_prefixed(buf, sizeof(buf), #name, vars[i])) \
326 argv_append(&words, buf); \
330 OPTION_INFO(DEFINE_OPTION_WORD)
331 COLUMN_OPTIONS(DEFINE_COLUMN_OPTIONS_WORDS);
334 /* If it is a new word to complete, initialize */
335 if (!state) {
336 index = 0;
337 len = strlen(text);
340 /* Return the next name which partially matches */
341 while ((name = words[index])) {
342 name = enum_name(name);
343 index++;
345 if (strncmp(name, text, len) == 0) {
346 /* Ignore exact completion */
347 if (strlen(name) > len)
348 match = strdup(name);
349 break;
353 return match;
356 static int
357 readline_getc(FILE *stream)
359 return get_input_char();
362 static char **
363 readline_completion(const char *text, int start, int end)
365 /* Do not append a space after a completion */
366 rl_completion_suppress_append = 1;
369 * If the word is at the start of the line,
370 * then it is a tig action to complete.
372 if (start == 0)
373 return rl_completion_matches(text, readline_action_generator);
376 * If the line begins with "toggle", then we complete toggle options.
378 if (start >= 7 && strncmp(rl_line_buffer, "toggle ", 7) == 0)
379 return rl_completion_matches(text, readline_toggle_generator);
382 * If the line begins with "set", then we complete set options.
383 * (unless it is already completed)
385 if (start >= 4 && strncmp(rl_line_buffer, "set ", 4) == 0 &&
386 !strchr(rl_line_buffer, '='))
387 return rl_completion_matches(text, readline_set_generator);
390 * Otherwise it might be a variable name...
392 if (strncmp(text, "%(", 2) == 0)
393 return rl_completion_matches(text, readline_variable_generator);
396 * ... or finally fall back to filename completion.
398 return NULL;
401 static void
402 readline_display_matches(char **matches, int num_matches, int max_length)
404 unsigned int i;
406 wmove(status_win, 0, 0);
407 waddstr(status_win, "matches: ");
409 /* matches[0] is the incomplete word */
410 for (i = 1; i < num_matches + 1; ++i) {
411 waddstr(status_win, matches[i]);
412 waddch(status_win, ' ');
415 wgetch(status_win);
416 wrefresh(status_win);
419 static void
420 readline_init(void)
422 /* Allow conditional parsing of the ~/.inputrc file. */
423 rl_readline_name = "tig";
425 /* Word break caracters (we removed '(' to match variables) */
426 rl_basic_word_break_characters = " \t\n\"\\'`@$><=;|&{";
428 /* Custom display function */
429 rl_redisplay_function = readline_display;
430 rl_getc_function = readline_getc;
432 /* Completion support */
433 rl_attempted_completion_function = readline_completion;
435 rl_completion_display_matches_hook = readline_display_matches;
438 char *
439 read_prompt(const char *prompt)
441 static char *line = NULL;
443 if (line) {
444 free(line);
445 line = NULL;
448 line = readline(prompt);
450 if (line && !*line) {
451 free(line);
452 line = NULL;
455 if (line)
456 add_history(line);
458 return line;
461 void
462 prompt_init(void)
464 readline_init();
466 #else
467 char *
468 read_prompt(const char *prompt)
470 return read_prompt_incremental(prompt, TRUE, NULL, NULL);
473 void
474 prompt_init(void)
477 #endif /* HAVE_READLINE */
479 bool
480 prompt_menu(const char *prompt, const struct menu_item *items, int *selected)
482 enum input_status status = INPUT_OK;
483 struct key key;
484 int size = 0;
486 while (items[size].text)
487 size++;
489 assert(size > 0);
491 while (status == INPUT_OK) {
492 const struct menu_item *item = &items[*selected];
493 char hotkey[] = { '[', (char) item->hotkey, ']', ' ', 0 };
494 int i;
496 update_status("%s (%d of %d) %s%s", prompt, *selected + 1, size,
497 item->hotkey ? hotkey : "", item->text);
499 switch (get_input(COLS - 1, &key, FALSE)) {
500 case KEY_RETURN:
501 case KEY_ENTER:
502 case '\n':
503 status = INPUT_STOP;
504 break;
506 case KEY_LEFT:
507 case KEY_UP:
508 *selected = *selected - 1;
509 if (*selected < 0)
510 *selected = size - 1;
511 break;
513 case KEY_RIGHT:
514 case KEY_DOWN:
515 *selected = (*selected + 1) % size;
516 break;
518 case KEY_ESC:
519 status = INPUT_CANCEL;
520 break;
522 default:
523 for (i = 0; items[i].text; i++)
524 if (items[i].hotkey == key.data.bytes[0]) {
525 *selected = i;
526 status = INPUT_STOP;
527 break;
532 report_clear();
534 return status != INPUT_CANCEL;
537 struct prompt_toggle {
538 const char *name;
539 const char *type;
540 enum view_flag flags;
541 void *opt;
544 static struct prompt_toggle option_toggles[] = {
545 #define DEFINE_OPTION_TOGGLES(name, type, flags) { #name, #type, flags, &opt_ ## name },
546 OPTION_INFO(DEFINE_OPTION_TOGGLES)
549 static bool
550 find_arg(const char *argv[], const char *arg)
552 int i;
554 for (i = 0; argv && argv[i]; i++)
555 if (!strcmp(argv[i], arg))
556 return TRUE;
557 return FALSE;
560 static enum status_code
561 prompt_toggle_option(struct view *view, const char *argv[], const char *prefix,
562 struct prompt_toggle *toggle, enum view_flag *flags)
564 char name[SIZEOF_STR];
566 if (!enum_name_prefixed(name, sizeof(name), prefix, toggle->name))
567 return error("Failed to toggle option %s", toggle->name);
569 *flags = toggle->flags;
571 if (!strcmp(toggle->type, "bool")) {
572 bool *opt = toggle->opt;
574 *opt = !*opt;
575 if (opt == &opt_mouse)
576 enable_mouse(*opt);
577 return success("set %s = %s", name, *opt ? "yes" : "no");
579 } else if (!strncmp(toggle->type, "enum", 4)) {
580 const char *type = toggle->type + STRING_SIZE("enum ");
581 enum author *opt = toggle->opt;
582 const struct enum_map *map = find_enum_map(type);
584 *opt = (*opt + 1) % map->size;
585 return success("set %s = %s", name, enum_name(map->entries[*opt].name));
587 } else if (!strcmp(toggle->type, "int")) {
588 const char *arg = argv[2] ? argv[2] : "1";
589 int diff = atoi(arg);
590 int *opt = toggle->opt;
592 if (!diff)
593 diff = *arg == '-' ? -1 : 1;
595 if (opt == &opt_diff_context && *opt < 0)
596 *opt = -*opt;
597 if (opt == &opt_diff_context && diff < 0) {
598 if (!*opt)
599 return error("Diff context cannot be less than zero");
600 if (*opt < -diff)
601 diff = -*opt;
604 if (strstr(name, "commit-title-overflow")) {
605 *opt = *opt ? -*opt : 50;
606 if (*opt < 0)
607 return success("set %s = no", name);
608 diff = 0;
611 *opt += diff;
612 return success("set %s = %d", name, *opt);
614 } else if (!strcmp(toggle->type, "double")) {
615 const char *arg = argv[2] ? argv[2] : "1.0";
616 double *opt = toggle->opt;
617 int sign = 1;
618 double diff;
620 if (*arg == '-') {
621 sign = -1;
622 arg++;
625 if (parse_step(&diff, arg) != SUCCESS)
626 diff = strtod(arg, NULL);
628 *opt += sign * diff;
629 return success("set %s = %.2f", name, *opt);
631 } else if (!strcmp(toggle->type, "const char **")) {
632 const char ***opt = toggle->opt;
633 bool found = TRUE;
634 int i;
636 if (argv_size(argv) <= 2) {
637 argv_free(*opt);
638 (*opt)[0] = NULL;
639 return SUCCESS;
642 for (i = 2; argv[i]; i++) {
643 if (!find_arg(*opt, argv[i])) {
644 found = FALSE;
645 break;
649 if (found) {
650 int next, pos;
652 for (next = 0, pos = 0; (*opt)[pos]; pos++) {
653 const char *arg = (*opt)[pos];
655 if (find_arg(argv + 2, arg)) {
656 free((void *) arg);
657 continue;
659 (*opt)[next++] = arg;
662 (*opt)[next] = NULL;
664 } else if (!argv_copy(opt, argv + 2)) {
665 return ERROR_OUT_OF_MEMORY;
667 return SUCCESS;
669 } else {
670 return error("Unsupported `:toggle %s` (%s)", name, toggle->type);
674 static struct prompt_toggle *
675 find_prompt_toggle(struct prompt_toggle toggles[], size_t toggles_size,
676 const char *prefix, const char *name, size_t namelen)
678 char prefixed[SIZEOF_STR];
679 int i;
681 if (*prefix && namelen == strlen(prefix) &&
682 !string_enum_compare(prefix, name, namelen)) {
683 name = "display";
684 namelen = strlen(name);
687 for (i = 0; i < toggles_size; i++) {
688 struct prompt_toggle *toggle = &toggles[i];
690 if (namelen == strlen(toggle->name) &&
691 !string_enum_compare(toggle->name, name, namelen))
692 return toggle;
694 if (enum_name_prefixed(prefixed, sizeof(prefixed), prefix, toggle->name) &&
695 namelen == strlen(prefixed) &&
696 !string_enum_compare(prefixed, name, namelen))
697 return toggle;
700 return NULL;
703 static enum status_code
704 prompt_toggle(struct view *view, const char *argv[], enum view_flag *flags)
706 const char *option = argv[1];
707 size_t optionlen = option ? strlen(option) : 0;
708 struct prompt_toggle *toggle;
709 struct view_column *column;
711 if (!option)
712 return error("%s", "No option name given to :toggle");
714 if (enum_equals_static("sort-field", option, optionlen) ||
715 enum_equals_static("sort-order", option, optionlen)) {
716 if (!view_has_flags(view, VIEW_SORTABLE)) {
717 return error("Sorting is not yet supported for the %s view", view->name);
718 } else {
719 bool sort_field = enum_equals_static("sort-field", option, optionlen);
720 struct sort_state *sort = &view->sort;
722 sort_view(view, sort_field);
723 return success("set %s = %s", option,
724 sort_field ? view_column_name(get_sort_field(view))
725 : sort->reverse ? "descending" : "ascending");
729 toggle = find_prompt_toggle(option_toggles, ARRAY_SIZE(option_toggles),
730 "", option, optionlen);
731 if (toggle)
732 return prompt_toggle_option(view, argv, "", toggle, flags);
734 #define DEFINE_COLUMN_OPTIONS_TOGGLE(name, type, flags) \
735 { #name, #type, flags, &opt->name },
737 #define DEFINE_COLUMN_OPTIONS_CHECK(name, id, options) \
738 if (column->type == VIEW_COLUMN_##id) { \
739 struct name##_options *opt = &column->opt.name; \
740 struct prompt_toggle toggles[] = { \
741 options(DEFINE_COLUMN_OPTIONS_TOGGLE) \
742 }; \
743 toggle = find_prompt_toggle(toggles, ARRAY_SIZE(toggles), #name, option, optionlen); \
744 if (toggle) \
745 return prompt_toggle_option(view, argv, #name, toggle, flags); \
748 for (column = view->columns; column; column = column->next) {
749 COLUMN_OPTIONS(DEFINE_COLUMN_OPTIONS_CHECK);
752 return error("`:toggle %s` not supported", option);
755 static void
756 prompt_update_display(enum view_flag flags)
758 struct view *view;
759 int i;
761 if (flags & VIEW_RESET_DISPLAY) {
762 resize_display();
763 redraw_display(TRUE);
766 foreach_displayed_view(view, i) {
767 if (view_has_flags(view, flags) && view_can_refresh(view))
768 reload_view(view);
769 else
770 redraw_view(view);
774 enum request
775 run_prompt_command(struct view *view, const char *argv[])
777 enum request request;
778 const char *cmd = argv[0];
779 size_t cmdlen = cmd ? strlen(cmd) : 0;
781 if (!cmd)
782 return REQ_NONE;
784 if (string_isnumber(cmd)) {
785 int lineno = view->pos.lineno + 1;
787 if (parse_int(&lineno, cmd, 0, view->lines + 1) == SUCCESS) {
788 if (!lineno)
789 lineno = 1;
790 select_view_line(view, lineno - 1);
791 report_clear();
792 } else {
793 report("Unable to parse '%s' as a line number", cmd);
795 } else if (iscommit(cmd)) {
796 int lineno;
798 if (!(view->ops->column_bits & view_column_bit(ID))) {
799 report("Jumping to commits is not supported by the %s view", view->name);
800 return REQ_NONE;
803 for (lineno = 0; lineno < view->lines; lineno++) {
804 struct view_column_data column_data = {};
805 struct line *line = &view->line[lineno];
807 if (view->ops->get_column_data(view, line, &column_data) &&
808 column_data.id &&
809 !strncasecmp(column_data.id, cmd, cmdlen)) {
810 string_ncopy(view->env->search, cmd, cmdlen);
811 select_view_line(view, lineno);
812 report_clear();
813 return REQ_NONE;
817 report("Unable to find commit '%s'", view->env->search);
818 return REQ_NONE;
820 } else if (cmdlen > 1 && (cmd[0] == '/' || cmd[0] == '?')) {
821 char search[SIZEOF_STR];
823 if (!argv_to_string(argv, search, sizeof(search), " ")) {
824 report("Failed to copy search string");
825 return REQ_NONE;
828 if (!strcmp(search + 1, view->env->search))
829 return cmd[0] == '/' ? REQ_FIND_NEXT : REQ_FIND_PREV;
831 string_ncopy(view->env->search, search + 1, strlen(search + 1));
832 return cmd[0] == '/' ? REQ_SEARCH : REQ_SEARCH_BACK;
834 } else if (cmdlen > 1 && cmd[0] == '!') {
835 struct view *next = &pager_view;
836 bool copied;
838 /* Trim the leading '!'. */
839 argv[0] = cmd + 1;
840 copied = argv_format(view->env, &next->argv, argv, FALSE, TRUE);
841 argv[0] = cmd;
843 if (!copied) {
844 report("Argument formatting failed");
845 } else {
846 /* When running random commands, initially show the
847 * command in the title. However, it maybe later be
848 * overwritten if a commit line is selected. */
849 argv_to_string(next->argv, next->ref, sizeof(next->ref), " ");
851 next->dir = NULL;
852 open_pager_view(view, OPEN_PREPARED | OPEN_WITH_STDERR);
855 } else if (!strcmp(cmd, "save-display")) {
856 const char *path = argv[1] ? argv[1] : "tig-display.txt";
858 if (!save_display(path))
859 report("Failed to save screen to %s", path);
860 else
861 report("Saved screen to %s", path);
863 } else if (!strcmp(cmd, "toggle")) {
864 enum view_flag flags = VIEW_NO_FLAGS;
865 enum status_code code = prompt_toggle(view, argv, &flags);
866 const char *action = get_status_message(code);
868 if (code != SUCCESS) {
869 report("%s", action);
870 return REQ_NONE;
873 prompt_update_display(flags);
875 if (*action)
876 report("%s", action);
878 } else if (!strcmp(cmd, "script")) {
879 if (is_script_executing()) {
880 report("Scripts cannot be run from scripts");
881 } else if (!open_script(argv[1])) {
882 report("Failed to open %s", argv[1]);
885 } else {
886 struct key key = {};
887 enum status_code code;
888 enum view_flag flags = VIEW_NO_FLAGS;
890 /* Try :<key> */
891 key.modifiers.multibytes = 1;
892 string_ncopy(key.data.bytes, cmd, cmdlen);
893 request = get_keybinding(view->keymap, &key, 1);
894 if (request != REQ_NONE)
895 return request;
897 /* Try :<command> */
898 request = get_request(cmd);
899 if (request != REQ_UNKNOWN)
900 return request;
902 code = set_option(argv[0], argv_size(argv + 1), &argv[1]);
903 if (code != SUCCESS) {
904 report("%s", get_status_message(code));
905 return REQ_NONE;
908 if (!strcmp(cmd, "set")) {
909 struct prompt_toggle *toggle;
911 toggle = find_prompt_toggle(option_toggles, ARRAY_SIZE(option_toggles),
912 "", argv[1], strlen(argv[1]));
914 if (toggle)
915 flags = toggle->flags;
918 if (flags) {
919 prompt_update_display(flags);
921 } else {
922 request = view_can_refresh(view) ? REQ_REFRESH : REQ_SCREEN_REDRAW;
923 if (!strcmp(cmd, "color"))
924 init_colors();
925 resize_display();
926 redraw_display(TRUE);
930 return REQ_NONE;
933 enum request
934 open_prompt(struct view *view)
936 char *cmd = read_prompt(":");
937 const char *argv[SIZEOF_ARG] = { NULL };
938 int argc = 0;
940 if (cmd && !argv_from_string(argv, &argc, cmd)) {
941 report("Too many arguments");
942 return REQ_NONE;
945 return run_prompt_command(view, argv);
948 /* vim: set ts=8 sw=8 noexpandtab: */