1 /* vifm
2  * Copyright (C) 2001 Ken Steen.
3  * Copyright (C) 2015 xaizek.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19 
20 #ifndef VIFM__MODES__DIALOGS__MSG_DIALOG_H__
21 #define VIFM__MODES__DIALOGS__MSG_DIALOG_H__
22 
23 #include "../../utils/macros.h"
24 
25 #include <stdio.h> /* FILE */
26 
27 /* Definition of a dialog option. */
28 typedef struct response_variant
29 {
30 	char key;          /* Corresponding key. */
31 	const char *descr; /* Description to be displayed. */
32 }
33 response_variant;
34 
35 /* Initializes message dialog mode. */
36 void init_msg_dialog_mode(void);
37 
38 /* Redraws currently visible error message on the screen. */
39 void redraw_msg_dialog(int lazy);
40 
41 /* Shows error message to a user. */
42 void show_error_msg(const char title[], const char message[]);
43 
44 /* Same as show_error_msg(...), but with format. */
45 void show_error_msgf(const char title[], const char format[], ...)
46 	_gnuc_printf(2, 3);
47 
48 /* Same as show_error_msg(...), but asks about future errors.  Returns non-zero
49  * when user asks to skip error messages that left. */
50 int prompt_error_msg(const char title[], const char message[]);
51 
52 /* Same as show_error_msgf(...), but asks about future errors.  Returns non-zero
53  * when user asks to skip error messages that left. */
54 int prompt_error_msgf(const char title[], const char format[], ...)
55 	_gnuc_printf(2, 3);
56 
57 /* Asks user to confirm some action by answering "Yes" or "No".  Returns
58  * non-zero when user answers yes, otherwise zero is returned. */
59 int prompt_msg(const char title[], const char message[]);
60 
61 /* Same as prompt_msg() but with custom list of options.  The responses array
62  * should be terminated with a record filled with zeroes.  Returns one of keys
63  * defined in the array.  The array has to contain at least one element.  Use
64  * '\r' key to handle Enter and '\x03' to handle cancellation (both Ctrl-C and
65  * Escape).  variants elements with empty lines instead of descriptions are not
66  * displayed. */
67 char prompt_msg_custom(const char title[], const char message[],
68 		const response_variant variants[]);
69 
70 /* Draws centered formatted message with specified title and control message on
71  * error_win. */
72 void draw_msgf(const char title[], const char ctrl_msg[], int recommended_width,
73 		const char format[], ...) _gnuc_printf(4, 5);
74 
75 /* Checks with the user that deletion is permitted.  Returns non-zero if so,
76  * otherwise zero is returned. */
77 int confirm_deletion(char *files[], int nfiles, int use_trash);
78 
79 /* Reads contents of the file and displays it in series of dialog messages.  ef
80  * can be NULL.  Closes ef. */
81 void show_errors_from_file(FILE *ef, const char title[]);
82 
83 #endif /* VIFM__MODES__DIALOGS__MSG_DIALOG_H__ */
84 
85 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
86 /* vim: set cinoptions+=t0 filetype=c : */
87