1 #ifndef OPTIONS_H 2 #define OPTIONS_H 3 4 #include <stdbool.h> 5 #include "encoding/encoder.h" 6 7 enum { 8 // Trailing whitespace 9 WSE_TRAILING = 1 << 0, 10 11 // Spaces in indentation. 12 // Does not include less than tab-width spaces at end of indentation. 13 WSE_SPACE_INDENT = 1 << 1, 14 15 // Less than tab-width spaces at end of indentation 16 WSE_SPACE_ALIGN = 1 << 2, 17 18 // Tab in indentation 19 WSE_TAB_INDENT = 1 << 3, 20 21 // Tab anywhere but in indentation 22 WSE_TAB_AFTER_INDENT = 1 << 4, 23 24 // Special whitespace characters 25 WSE_SPECIAL = 1 << 5, 26 27 // expand-tab = false: WSE_SPACE_INDENT 28 // expand-tab = true: WSE_TAB_AFTER_INDENT | WSE_TAB_INDENT 29 WSE_AUTO_INDENT = 1 << 6, 30 }; 31 32 typedef enum { 33 CSS_FALSE, 34 CSS_TRUE, 35 CSS_AUTO, 36 } SearchCaseSensitivity; 37 38 typedef enum { 39 TAB_BAR_HIDDEN, 40 TAB_BAR_HORIZONTAL, 41 TAB_BAR_VERTICAL, 42 TAB_BAR_AUTO, 43 } TabBarMode; 44 45 #define COMMON_OPTIONS \ 46 unsigned int auto_indent; \ 47 unsigned int detect_indent; \ 48 unsigned int editorconfig; \ 49 unsigned int emulate_tab; \ 50 unsigned int expand_tab; \ 51 unsigned int file_history; \ 52 unsigned int indent_width; \ 53 unsigned int syntax; \ 54 unsigned int tab_width; \ 55 unsigned int text_width; \ 56 unsigned int ws_error 57 58 typedef struct { 59 COMMON_OPTIONS; 60 } CommonOptions; 61 62 typedef struct { 63 COMMON_OPTIONS; 64 // Only local 65 unsigned int brace_indent; 66 const char *filetype; 67 const char *indent_regex; 68 } LocalOptions; 69 70 typedef struct { 71 COMMON_OPTIONS; 72 // Only global 73 unsigned int display_invisible; 74 unsigned int display_special; 75 unsigned int esc_timeout; 76 unsigned int filesize_limit; 77 unsigned int lock_files; 78 unsigned int scroll_margin; 79 unsigned int set_window_title; 80 unsigned int show_line_numbers; 81 unsigned int tab_bar_max_components; 82 unsigned int tab_bar_width; 83 LineEndingType newline; // Default value for new files 84 SearchCaseSensitivity case_sensitive_search; 85 TabBarMode tab_bar; 86 const char *statusline_left; 87 const char *statusline_right; 88 } GlobalOptions; 89 90 #undef COMMON_OPTIONS 91 92 #define TAB_BAR_MIN_WIDTH 12 93 94 void set_option(const char *name, const char *value, bool local, bool global); 95 void set_bool_option(const char *name, bool local, bool global); 96 void toggle_option(const char *name, bool global, bool verbose); 97 void toggle_option_values(const char *name, bool global, bool verbose, char **values, size_t count); 98 bool validate_local_options(char **strs); 99 void collect_options(const char *prefix); 100 void collect_toggleable_options(const char *prefix); 101 void collect_option_values(const char *name, const char *prefix); 102 103 #endif 104