1 #pragma once 2 3 #include <stdint.h> 4 #include <stdbool.h> 5 6 #include <tllist.h> 7 8 #include "terminal.h" 9 #include "user-notification.h" 10 #include "wayland.h" 11 12 #define DEFINE_LIST(type) \ 13 type##_list { \ 14 size_t count; \ 15 type *arr; \ 16 } 17 18 enum conf_size_type {CONF_SIZE_PX, CONF_SIZE_CELLS}; 19 20 struct config_font { 21 char *pattern; 22 float pt_size; 23 int px_size; 24 }; 25 DEFINE_LIST(struct config_font); 26 27 struct config_key_modifiers { 28 bool shift; 29 bool alt; 30 bool ctrl; 31 bool meta; 32 }; 33 34 struct argv { 35 char **args; 36 }; 37 38 struct config_binding_pipe { 39 struct argv argv; 40 bool master_copy; 41 }; 42 43 struct config_key_binding { 44 int action; /* One of the varios bind_action_* enums from wayland.h */ 45 struct config_key_modifiers modifiers; 46 xkb_keysym_t sym; 47 struct config_binding_pipe pipe; 48 }; 49 DEFINE_LIST(struct config_key_binding); 50 51 struct config_mouse_binding { 52 enum bind_action_normal action; 53 struct config_key_modifiers modifiers; 54 int button; 55 int count; 56 struct config_binding_pipe pipe; 57 }; 58 DEFINE_LIST(struct config_mouse_binding); 59 60 typedef tll(char *) config_override_t; 61 62 struct config_spawn_template { 63 struct argv argv; 64 }; 65 66 struct config { 67 char *term; 68 char *shell; 69 char *title; 70 char *app_id; 71 wchar_t *word_delimiters; 72 bool login_shell; 73 bool locked_title; 74 75 struct { 76 enum conf_size_type type; 77 uint32_t width; 78 uint32_t height; 79 } size; 80 81 unsigned pad_x; 82 unsigned pad_y; 83 bool center; 84 uint16_t resize_delay_ms; 85 86 struct { 87 bool enabled; 88 bool palette_based; 89 } bold_in_bright; 90 91 enum { STARTUP_WINDOWED, STARTUP_MAXIMIZED, STARTUP_FULLSCREEN } startup_mode; 92 93 enum {DPI_AWARE_AUTO, DPI_AWARE_YES, DPI_AWARE_NO} dpi_aware; 94 struct config_font_list fonts[4]; 95 96 /* Custom font metrics (-1 = use real font metrics) */ 97 struct pt_or_px line_height; 98 struct pt_or_px letter_spacing; 99 100 /* Adjusted letter x/y offsets */ 101 struct pt_or_px horizontal_letter_offset; 102 struct pt_or_px vertical_letter_offset; 103 104 bool use_custom_underline_offset; 105 struct pt_or_px underline_offset; 106 107 bool box_drawings_uses_font_glyphs; 108 bool can_shape_grapheme; 109 110 struct { 111 bool urgent; 112 bool notify; 113 struct config_spawn_template command; 114 bool command_focused; 115 } bell; 116 117 struct { 118 uint32_t lines; 119 120 struct { 121 enum { 122 SCROLLBACK_INDICATOR_POSITION_NONE, 123 SCROLLBACK_INDICATOR_POSITION_FIXED, 124 SCROLLBACK_INDICATOR_POSITION_RELATIVE 125 } position; 126 127 enum { 128 SCROLLBACK_INDICATOR_FORMAT_PERCENTAGE, 129 SCROLLBACK_INDICATOR_FORMAT_LINENO, 130 SCROLLBACK_INDICATOR_FORMAT_TEXT, 131 } format; 132 133 wchar_t *text; 134 } indicator; 135 float multiplier; 136 } scrollback; 137 138 struct { 139 wchar_t *label_letters; 140 struct config_spawn_template launch; 141 enum { 142 OSC8_UNDERLINE_URL_MODE, 143 OSC8_UNDERLINE_ALWAYS, 144 } osc8_underline; 145 146 wchar_t **protocols; 147 wchar_t *uri_characters; 148 size_t prot_count; 149 size_t max_prot_len; 150 } url; 151 152 struct { 153 uint32_t fg; 154 uint32_t bg; 155 uint32_t table[256]; 156 uint16_t alpha; 157 uint32_t selection_fg; 158 uint32_t selection_bg; 159 uint32_t url; 160 161 uint32_t dim[8]; 162 163 struct { 164 uint32_t fg; 165 uint32_t bg; 166 } jump_label; 167 168 struct { 169 uint32_t fg; 170 uint32_t bg; 171 } scrollback_indicator; 172 173 struct { 174 bool selection:1; 175 bool jump_label:1; 176 bool scrollback_indicator:1; 177 bool url:1; 178 uint8_t dim; 179 } use_custom; 180 } colors; 181 182 struct { 183 enum cursor_style style; 184 bool blink; 185 struct { 186 uint32_t text; 187 uint32_t cursor; 188 } color; 189 struct pt_or_px beam_thickness; 190 struct pt_or_px underline_thickness; 191 } cursor; 192 193 struct { 194 bool hide_when_typing; 195 bool alternate_scroll_mode; 196 } mouse; 197 198 struct { 199 /* Bindings for "normal" mode */ 200 struct config_key_binding_list key; 201 struct config_mouse_binding_list mouse; 202 203 /* 204 * Special modes 205 */ 206 207 /* While searching (not - action to *start* a search is in the 208 * 'key' bindings above */ 209 struct config_key_binding_list search; 210 211 /* While showing URL jump labels */ 212 struct config_key_binding_list url; 213 } bindings; 214 215 struct { 216 enum { CONF_CSD_PREFER_NONE, CONF_CSD_PREFER_SERVER, CONF_CSD_PREFER_CLIENT } preferred; 217 218 uint16_t title_height; 219 uint16_t border_width; 220 uint16_t border_width_visible; 221 uint16_t button_width; 222 223 struct { 224 bool title_set:1; 225 bool buttons_set:1; 226 bool minimize_set:1; 227 bool maximize_set:1; 228 bool close_set:1; 229 bool border_set:1; 230 uint32_t title; 231 uint32_t buttons; 232 uint32_t minimize; 233 uint32_t maximize; 234 uint32_t close; 235 uint32_t border; 236 } color; 237 238 struct config_font_list font; 239 } csd; 240 241 uint16_t render_worker_count; 242 char *server_socket_path; 243 bool presentation_timings; 244 bool hold_at_exit; 245 enum { 246 SELECTION_TARGET_NONE, 247 SELECTION_TARGET_PRIMARY, 248 SELECTION_TARGET_CLIPBOARD, 249 SELECTION_TARGET_BOTH 250 } selection_target; 251 252 struct config_spawn_template notify; 253 bool notify_focus_inhibit; 254 255 struct { 256 enum fcft_scaling_filter fcft_filter; 257 bool overflowing_glyphs; 258 bool grapheme_shaping; 259 enum { 260 GRAPHEME_WIDTH_WCSWIDTH, 261 GRAPHEME_WIDTH_DOUBLE, 262 GRAPHEME_WIDTH_MAX, 263 } grapheme_width_method; 264 bool render_timer_osd; 265 bool render_timer_log; 266 bool damage_whole_window; 267 uint32_t delayed_render_lower_ns; 268 uint32_t delayed_render_upper_ns; 269 off_t max_shm_pool_size; 270 float box_drawing_base_thickness; 271 bool box_drawing_solid_shades; 272 bool font_monospace_warn; 273 } tweak; 274 275 user_notifications_t notifications; 276 }; 277 278 bool config_override_apply(struct config *conf, config_override_t *overrides, 279 bool errors_are_fatal); 280 bool config_load( 281 struct config *conf, const char *path, 282 user_notifications_t *initial_user_notifications, 283 config_override_t *overrides, bool errors_are_fatal); 284 void config_free(struct config conf); 285 struct config *config_clone(const struct config *old); 286 287 bool config_font_parse(const char *pattern, struct config_font *font); 288 void config_font_list_destroy(struct config_font_list *font_list); 289 290 bool check_if_font_is_monospaced( 291 const char *pattern, user_notifications_t *notifications); 292