diff options
author | Joe <rbo@gmx.us> | 2024-04-24 20:20:20 +0200 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-04-24 20:20:20 +0200 |
commit | 6df427e26a4e4890ad9994940bb38cd96e5970e8 (patch) | |
tree | 2c5caadc228e706402c489ccd2561c34e690792f /src/i_ui.go | |
parent | jump (diff) | |
download | hardflip-6df427e26a4e4890ad9994940bb38cd96e5970e8.tar.gz hardflip-6df427e26a4e4890ad9994940bb38cd96e5970e8.tar.bz2 hardflip-6df427e26a4e4890ad9994940bb38cd96e5970e8.tar.xz hardflip-6df427e26a4e4890ad9994940bb38cd96e5970e8.tar.zst hardflip-6df427e26a4e4890ad9994940bb38cd96e5970e8.zip |
refactor
Diffstat (limited to 'src/i_ui.go')
-rw-r--r-- | src/i_ui.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/i_ui.go b/src/i_ui.go index b19921b..8dc9721 100644 --- a/src/i_ui.go +++ b/src/i_ui.go @@ -649,6 +649,8 @@ func i_init_styles(ui *HardUI) { Foreground(tcell.ColorYellow).Dim(true).Bold(true) } +type key_event_mode_func func(*HardData, tcell.EventKey) bool + func i_ui(data_dir string) { home_dir, _ := os.UserHomeDir() ui := HardUI{} @@ -691,6 +693,15 @@ func i_ui(data_dir string) { data.ui.mode = WELCOME_MODE data.keys = c_get_secret_gpg_keyring() } + fp := [MODE_MAX + 1]key_event_mode_func{ + NORMAL_MODE: e_normal_events, + DELETE_MODE: e_delete_events, + LOAD_MODE: e_load_events, + ERROR_MODE: e_error_events, + WELCOME_MODE: e_welcome_events, + MKDIR_MODE: e_mkdir_events, + INSERT_MODE: e_insert_events, + } for { data.ui.s.Clear() i_draw_bottom_text(data.ui, data.opts, data.insert, data.insert_err) @@ -727,6 +738,6 @@ func i_ui(data_dir string) { } } data.ui.s.Show() - e_events(&data) + e_events(&data, fp) } } |