1 /* Copyright (c) 2006-2015 Jonas Fonseca <jonas.fonseca@gmail.com>
2  *
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.
7  *
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.
12  */
13 
14 #ifndef TIG_PROMPT_H
15 #define TIG_PROMPT_H
16 
17 #include "tig/tig.h"
18 #include "tig/keys.h"
19 
20 struct view;
21 struct input;
22 
23 enum input_status {
24 	INPUT_OK,
25 	INPUT_SKIP,
26 	INPUT_DELETE,
27 	INPUT_STOP,
28 	INPUT_CANCEL
29 };
30 
31 struct menu_item {
32 	int hotkey;
33 	const char *text;
34 	void *data;
35 };
36 
37 typedef enum input_status (*input_handler)(struct input *input, struct key *key);
38 
39 struct input {
40 	input_handler handler;
41 	bool allow_empty;
42 	void *data;
43 	char buf[SIZEOF_STR];
44 	char context[SIZEOF_STR];
45 };
46 
47 enum input_status prompt_default_handler(struct input *input, struct key *key);
48 char *read_prompt_incremental(const char *prompt, bool edit_mode, bool allow_empty, input_handler handler, void *data);
49 char *read_prompt(const char *prompt);
50 void prompt_init(void);
51 bool prompt_yesno(const char *prompt);
52 bool prompt_menu(const char *prompt, const struct menu_item *items, int *selected);
53 
54 enum request run_prompt_command(struct view *view, const char *argv[]);
55 enum request open_prompt(struct view *view);
56 enum request exec_run_request(struct view *view, struct run_request *req);
57 
58 #endif
59 /* vim: set ts=8 sw=8 noexpandtab: */
60