diff options
-rw-r--r-- | src/e_events.go | 14 | ||||
-rw-r--r-- | src/e_keys.go | 12 | ||||
-rw-r--r-- | src/i_ui.go | 13 |
3 files changed, 30 insertions, 9 deletions
diff --git a/src/e_events.go b/src/e_events.go index 753b629..1b6e93e 100644 --- a/src/e_events.go +++ b/src/e_events.go @@ -306,7 +306,7 @@ func e_tab_complete_get_current_dir(str, home_dir string) (string, string) { return "./", file } -func e_tab_complete(buffer *Buffer, home_dir string) { +func e_tab_complete(buffer *Buffer, ui *HardUI, home_dir string) { dir, file := e_tab_complete_get_current_dir(buffer.str(), home_dir) log.Println("cwd:", dir, "file:", file) entries, err := os.ReadDir(dir) @@ -314,12 +314,19 @@ func e_tab_complete(buffer *Buffer, home_dir string) { return } var match []string + var match_sum string for _, v := range entries { if len(v.Name()) >= len(file) && v.Name()[:len(file)] == file { match = append(match, v.Name()) + match_sum += v.Name() + if v.IsDir() == true { + match_sum += "/" + } + match_sum += " " } } + ui.match_buff = match_sum log.Println("match:", match) if len(match) == 0 { return @@ -357,7 +364,8 @@ func e_tab_complete(buffer *Buffer, home_dir string) { } } -func e_readline(event tcell.EventKey, buffer *Buffer, home_dir string) { +func e_readline(event tcell.EventKey, buffer *Buffer, + ui *HardUI, home_dir string) { if buffer.len() > 0 && (event.Key() == tcell.KeyBackspace || event.Key() == tcell.KeyBackspace2) { @@ -400,7 +408,7 @@ func e_readline(event tcell.EventKey, buffer *Buffer, home_dir string) { buffer.cursor += 1 } else if event.Key() == tcell.KeyTab || event.Key() == tcell.KeyCtrlI { - e_tab_complete(buffer, home_dir) + e_tab_complete(buffer, ui, home_dir) } if buffer.cursor > buffer.len() { buffer.cursor = buffer.len() diff --git a/src/e_keys.go b/src/e_keys.go index 07c3c97..bc30053 100644 --- a/src/e_keys.go +++ b/src/e_keys.go @@ -325,7 +325,7 @@ func e_mkdir_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { ui.mode = NORMAL_MODE ui.buff.empty() } else { - e_readline(event, &ui.buff, data.home_dir) + e_readline(event, &ui.buff, ui, data.home_dir) } return false } @@ -360,7 +360,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { data.insert.parent = data.ldirs.head } } else { - e_readline(event, &ui.buff, data.home_dir) + e_readline(event, &ui.buff, ui, data.home_dir) } } else if data.insert != nil { if data.insert_err != nil { @@ -655,7 +655,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { ui.drives_buff = ui.buff.str() ui.buff.empty() } else { - e_readline(event, &ui.buff, data.home_dir) + e_readline(event, &ui.buff, ui, data.home_dir) } } else { if event.Key() == tcell.KeyEnter { @@ -676,7 +676,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { ui.buff.empty() ui.s.HideCursor() } else { - e_readline(event, &ui.buff, data.home_dir) + e_readline(event, &ui.buff, ui, data.home_dir) } } case INS_SSH_HOST, @@ -807,7 +807,7 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { ui.buff.empty() ui.s.HideCursor() } else { - e_readline(event, &ui.buff, data.home_dir) + e_readline(event, &ui.buff, ui, data.home_dir) } } } @@ -826,7 +826,7 @@ func e_rename_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { return true } } else { - e_readline(event, &ui.buff, data.home_dir) + e_readline(event, &ui.buff, ui, data.home_dir) return true } ui.s.HideCursor() diff --git a/src/i_ui.go b/src/i_ui.go index 0eae586..5e3d180 100644 --- a/src/i_ui.go +++ b/src/i_ui.go @@ -53,6 +53,7 @@ package main import ( "fmt" + "log" "os" "strconv" @@ -74,6 +75,7 @@ type HardUI struct { buff Buffer drives_buff string msg_buff string + match_buff string insert_sel int insert_sel_max int insert_sel_ok bool @@ -613,6 +615,13 @@ func i_draw_scrollhint(ui HardUI, litems *ItemsList) { } } +func i_draw_match_buff(ui HardUI) { + log.Println("match_buff", ui.match_buff) + i_draw_msg(ui.s, 1, ui.style[BOX_STYLE], ui.dim, "") + i_draw_text(ui.s, 2, ui.dim[H] - 2 - 1, ui.dim[W] - 2, ui.dim[H] - 2 - 1, + ui.style[DEF_STYLE], ui.match_buff) +} + var g_load_count int = -1 func i_draw_load_ui(ui *HardUI, opts HardOpts) { @@ -792,6 +801,10 @@ func i_ui(data_dir string) { case HELP_MODE: i_draw_help(&data.ui) } + if len(data.ui.match_buff) > 0 { + i_draw_match_buff(data.ui) + data.ui.match_buff = "" + } data.ui.s.Show() e_events(&data, fp) } |