aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-09-23 15:30:05 +0200
committerJoe <rbo@gmx.us>2024-09-23 15:30:05 +0200
commitfc2186ec5c8859589d9cb3cb0612135d24369cfe (patch)
treee2f568a5947047cdbaabff6f750336b27b47a690
parentfixed segv (diff)
downloadhardflip-fc2186ec5c8859589d9cb3cb0612135d24369cfe.tar.gz
hardflip-fc2186ec5c8859589d9cb3cb0612135d24369cfe.tar.bz2
hardflip-fc2186ec5c8859589d9cb3cb0612135d24369cfe.tar.xz
hardflip-fc2186ec5c8859589d9cb3cb0612135d24369cfe.tar.zst
hardflip-fc2186ec5c8859589d9cb3cb0612135d24369cfe.zip
wip
-rw-r--r--src/c_defs.go4
-rw-r--r--src/e_keys.go19
-rw-r--r--src/i_ui.go12
3 files changed, 30 insertions, 5 deletions
diff --git a/src/c_defs.go b/src/c_defs.go
index f4cbcbf..b955f0c 100644
--- a/src/c_defs.go
+++ b/src/c_defs.go
@@ -83,7 +83,8 @@ const (
INSERT_MODE
RENAME_MODE
HELP_MODE
- MODE_MAX = HELP_MODE
+ FUZZ_MODE
+ MODE_MAX = FUZZ_MODE
)
const (
@@ -221,6 +222,7 @@ var HELP_NORMAL_KEYS = [][2]string{
{"e", "Edit selected host"},
{"c | C | A", "Rename selected item"},
{"<c-r>", "Reload data and configuration"},
+ {"/ | <c-f>", "Fuzzy search"},
{"?", "Display this help menu"},
{"<c-c> | q", "Quit"},
}
diff --git a/src/e_keys.go b/src/e_keys.go
index e7c71c8..e64f727 100644
--- a/src/e_keys.go
+++ b/src/e_keys.go
@@ -76,10 +76,6 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
} else if event.Key() == tcell.KeyCtrlU ||
event.Key() == tcell.KeyPgUp {
data.litems.inc(-(ui.dim[H] / 3))
- } else if event.Key() == tcell.KeyCtrlF {
- // TODO: maybe keymap these
- } else if event.Key() == tcell.KeyCtrlB {
- // TODO: maybe keymap these
} else if event.Rune() == '}' ||
event.Rune() == ']' {
if next := data.litems.curr.next_dir(); next != nil {
@@ -262,6 +258,10 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
} else {
ui.buff.insert(data.litems.curr.Dirs.Name)
}
+ } else if (event.Rune() == '/' ||
+ event.Key() == tcell.KeyCtrlF) &&
+ data.litems.curr != nil {
+ ui.mode = FUZZ_MODE
} else if event.Rune() == '?' {
ui.mode = HELP_MODE
ui.help_scroll = 0
@@ -915,3 +915,14 @@ func e_help_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
}
return false
}
+
+func e_fuzz_events(data *HardData, ui *HardUI, event tcell.EventKey) bool {
+ if event.Key() == tcell.KeyEscape ||
+ event.Key() == tcell.KeyCtrlC {
+ ui.s.HideCursor()
+ ui.mode = NORMAL_MODE
+ ui.buff.empty()
+ return true
+ }
+ return false
+}
diff --git a/src/i_ui.go b/src/i_ui.go
index dbbcbf9..f18c090 100644
--- a/src/i_ui.go
+++ b/src/i_ui.go
@@ -512,6 +512,15 @@ func i_prompt_insert(ui HardUI, curr *ItemsNode) {
ui.buff.cursor, ui.dim[H] - 1)
}
+func i_prompt_fuzz(ui HardUI) {
+ prompt := "Search: "
+ i_draw_text(ui.s,
+ 1, ui.dim[H] - 1, ui.dim[W] - 1, ui.dim[H] - 1,
+ ui.style[DEF_STYLE], prompt)
+ ui.s.ShowCursor(len(prompt) + 1 +
+ ui.buff.cursor, ui.dim[H] - 1)
+}
+
func i_draw_remove_share(ui HardUI) {
text := "Really remove this share?"
@@ -819,6 +828,7 @@ func i_ui(data_dir string) {
INSERT_MODE: e_insert_events,
RENAME_MODE: e_rename_events,
HELP_MODE: e_help_events,
+ FUZZ_MODE: e_fuzz_events,
}
for {
data.ui.s.Clear()
@@ -861,6 +871,8 @@ func i_ui(data_dir string) {
i_prompt_insert(data.ui, data.litems.curr)
case HELP_MODE:
i_draw_help(&data.ui)
+ case FUZZ_MODE:
+ i_prompt_fuzz(data.ui)
}
if len(data.ui.match_buff) > 0 {
i_draw_match_buff(data.ui)