1 #ifndef EDITOR_H 2 #define EDITOR_H 3 4 #include <stdbool.h> 5 #include "cmdline.h" 6 #include "mode.h" 7 #include "options.h" 8 #include "encoding/encoding.h" 9 #include "terminal/color.h" 10 #include "util/macros.h" 11 #include "util/ptr-array.h" 12 13 typedef enum { 14 EDITOR_INITIALIZING, 15 EDITOR_RUNNING, 16 EDITOR_EXITING, 17 } EditorStatus; 18 19 typedef enum { 20 INPUT_NORMAL, 21 INPUT_COMMAND, 22 INPUT_SEARCH, 23 INPUT_GIT_OPEN, 24 } InputMode; 25 26 typedef struct { 27 EditorStatus status; 28 const EditorModeOps *mode_ops[4]; 29 InputMode input_mode; 30 CommandLine cmdline; 31 GlobalOptions options; 32 const char *home_dir; 33 const char *user_config_dir; 34 Encoding charset; 35 const char *pager; 36 bool child_controls_terminal; 37 bool everything_changed; 38 bool term_utf8; 39 size_t cmdline_x; 40 PointerArray search_history; 41 PointerArray command_history; 42 const char *const version; 43 void (*resize)(void); 44 void (*ui_end)(void); 45 } EditorState; 46 47 extern EditorState editor; 48 mark_everything_changed(void)49static inline void mark_everything_changed(void) 50 { 51 editor.everything_changed = true; 52 } 53 set_input_mode(InputMode mode)54static inline void set_input_mode(InputMode mode) 55 { 56 editor.input_mode = mode; 57 } 58 59 void init_editor_state(void); 60 char *editor_file(const char *name) XSTRDUP; 61 char get_confirmation(const char *choices, const char *format, ...) PRINTF(2); 62 void any_key(void); 63 void normal_update(void); 64 void handle_sigwinch(int signum); 65 void suspend(void); 66 void main_loop(void); 67 68 #endif 69