diff options
author | Joe <rbo@gmx.us> | 2024-04-25 20:20:20 +0200 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-04-25 20:20:20 +0200 |
commit | 72578a19bf46b6e0519c3bbd5940e229a1cf5605 (patch) | |
tree | 196e6de0a85ba19dab78d35b9b7491990a29855a /src | |
parent | red (diff) | |
download | hardflip-72578a19bf46b6e0519c3bbd5940e229a1cf5605.tar.gz hardflip-72578a19bf46b6e0519c3bbd5940e229a1cf5605.tar.bz2 hardflip-72578a19bf46b6e0519c3bbd5940e229a1cf5605.tar.xz hardflip-72578a19bf46b6e0519c3bbd5940e229a1cf5605.tar.zst hardflip-72578a19bf46b6e0519c3bbd5940e229a1cf5605.zip |
ok
Diffstat (limited to '')
-rw-r--r-- | src/c_defs.go | 3 | ||||
-rw-r--r-- | src/e_events.go | 10 | ||||
-rw-r--r-- | src/e_keys.go | 24 | ||||
-rw-r--r-- | src/i_insert.go | 3 | ||||
-rw-r--r-- | src/i_ui.go | 14 |
5 files changed, 47 insertions, 7 deletions
diff --git a/src/c_defs.go b/src/c_defs.go index f16abaa..53c8317 100644 --- a/src/c_defs.go +++ b/src/c_defs.go @@ -82,7 +82,8 @@ const ( WELCOME_MODE MKDIR_MODE INSERT_MODE - MODE_MAX = INSERT_MODE + RENAME_MODE + MODE_MAX = RENAME_MODE ) const ( diff --git a/src/e_events.go b/src/e_events.go index 673fc1a..60f7db9 100644 --- a/src/e_events.go +++ b/src/e_events.go @@ -316,6 +316,16 @@ func e_mkdir(data *HardData, ui *HardUI) { } } +func e_rename(data *HardData, ui *HardUI) { + if len(ui.buff) == 0 || + data.litems.curr == nil || data.litems.curr.is_dir() == true { + return + } + data.litems.curr.Host.Name = ui.buff + // ui.insert_method = INSERT_MOVE + // i_insert_host(data, new_host) +} + func e_set_drive_keys(data *HardData) { data.insert.drive_keys = nil for key := range data.insert.Drive { diff --git a/src/e_keys.go b/src/e_keys.go index 20552d7..d160f47 100644 --- a/src/e_keys.go +++ b/src/e_keys.go @@ -238,6 +238,14 @@ func e_normal_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { } data.yank = nil ui.msg_buff = "pasted " + new_host.Name + } else if (event.Rune() == 'c' || + event.Rune() == 'C' || + event.Rune() == 'r' || + event.Rune() == 'R') && + data.litems.curr != nil && + data.litems.curr.is_dir() == false { + ui.mode = RENAME_MODE + ui.buff = data.litems.curr.Host.Name } return false } @@ -766,3 +774,19 @@ func e_insert_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { } return false } + +func e_rename_events(data *HardData, ui *HardUI, event tcell.EventKey) bool { + if event.Key() == tcell.KeyEscape || + event.Key() == tcell.KeyCtrlC { + data.insert = nil + } else if event.Key() == tcell.KeyEnter { + e_rename(data, ui) + } else { + e_readline(event, &ui.buff) + return true + } + ui.s.HideCursor() + ui.mode = NORMAL_MODE + ui.buff = "" + return false +} diff --git a/src/i_insert.go b/src/i_insert.go index 97dda36..8ea6754 100644 --- a/src/i_insert.go +++ b/src/i_insert.go @@ -140,7 +140,8 @@ func i_insert_host(data *HardData, insert *HostNode) error { } filename := insert.filename if data.ui.insert_method == INSERT_ADD || - data.ui.insert_method == INSERT_COPY { + data.ui.insert_method == INSERT_COPY || + data.ui.insert_method == INSERT_MOVE { filename = i_insert_format_filename(insert.Name, data.data_dir + insert.parent.path()) insert.filename = filename diff --git a/src/i_ui.go b/src/i_ui.go index e6155aa..dc7165e 100644 --- a/src/i_ui.go +++ b/src/i_ui.go @@ -43,7 +43,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * hardflip: src/i_ui.go - * Thu Apr 18 16:59:53 2024 + * Thu Apr 25 16:20:41 2024 * Joe * * interfacing with the user @@ -710,6 +710,7 @@ func i_ui(data_dir string) { WELCOME_MODE: e_welcome_events, MKDIR_MODE: e_mkdir_events, INSERT_MODE: e_insert_events, + RENAME_MODE: e_rename_events, } for { data.ui.s.Clear() @@ -730,13 +731,14 @@ func i_ui(data_dir string) { } else if data.litems.head == nil { i_draw_zhosts_box(data.ui) } - if data.ui.mode == DELETE_MODE { + switch data.ui.mode { + case DELETE_MODE: i_draw_delete_msg(data.ui, data.litems.curr) - } else if data.ui.mode == ERROR_MODE { + case ERROR_MODE: i_draw_error_msg(data.ui, data.load_err) - } else if data.ui.mode == MKDIR_MODE { + case MKDIR_MODE: i_prompt_mkdir(data.ui, data.litems.curr) - } else if data.ui.mode == INSERT_MODE { + case INSERT_MODE: if data.insert == nil { i_prompt_insert(data.ui, data.litems.curr) } else { @@ -745,6 +747,8 @@ func i_ui(data_dir string) { i_draw_insert_err_msg(data.ui, data.insert_err) } } + case RENAME_MODE: + i_prompt_insert(data.ui, data.litems.curr) } data.ui.s.Show() e_events(&data, fp) |