diff options
author | Joe <rbo@gmx.us> | 2024-02-14 20:20:20 +0100 |
---|---|---|
committer | Joe <rbo@gmx.us> | 2024-02-14 20:20:20 +0100 |
commit | 1c340dc589f5107d9956378e35637a0dfdf55bcb (patch) | |
tree | 530b03ac19fad0c68f3ff600f38f1d2cfe34f2d0 /src/i_events.go | |
parent | fuck it (diff) | |
download | hardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.tar.gz hardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.tar.bz2 hardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.tar.xz hardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.tar.zst hardflip-1c340dc589f5107d9956378e35637a0dfdf55bcb.zip |
cool looking
Diffstat (limited to '')
-rw-r--r-- | src/i_events.go | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/src/i_events.go b/src/i_events.go index 613709b..b543fc6 100644 --- a/src/i_events.go +++ b/src/i_events.go @@ -245,6 +245,18 @@ func i_delete_host(data *HardData) error { return nil } +func i_readline(event *tcell.EventKey, data *HardData) { + if len(data.ui.buff) > 0 && + (event.Key() == tcell.KeyBackspace || + event.Key() == tcell.KeyBackspace2) { + data.ui.buff = data.ui.buff[:len(data.ui.buff) - 1] + } else if event.Key() == tcell.KeyCtrlU { + data.ui.buff = "" + } else if event.Rune() >= 32 && event.Rune() <= 126 { + data.ui.buff += string(event.Rune()) + } +} + // screen events such as keypresses func i_events(data *HardData) { ui := &data.ui @@ -324,6 +336,9 @@ func i_events(data *HardData) { } else if event.Key() == tcell.KeyCtrlR { event = nil i_reload_data(data) + } else if event.Rune() == 'm' || + event.Key() == tcell.KeyF7 { + data.ui.mode = MKDIR_MODE } i_list_follow_cursor(data.litems, ui) case DELETE_MODE: @@ -365,22 +380,19 @@ func i_events(data *HardData) { data.opts.GPG = "" } } + case MKDIR_MODE: + if event.Key() == tcell.KeyEscape || + event.Key() == tcell.KeyCtrlC { + ui.s.HideCursor() + ui.buff = "" + ui.mode = NORMAL_MODE + } else if event.Key() == tcell.KeyEnter { + ui.s.HideCursor() + ui.buff = "" + ui.mode = NORMAL_MODE + } else { + i_readline(event, data) + } } - } } - -// readline type beat -// if len(data.ui.buff) > 0 && -// (event.Key() == tcell.KeyBackspace || -// event.Key() == tcell.KeyBackspace2) { -// data.ui.buff = data.ui.buff[:len(data.ui.buff) - 1] -// } else if event.Key() == tcell.KeyCtrlU { -// data.ui.buff = "" -// } else if event.Key() == tcell.KeyEnter { -// data.opts.GPG = data.ui.buff -// data.ui.buff = "" -// data.ui.s.HideCursor() -// } else if event.Rune() >= 32 && event.Rune() <= 126 { -// data.ui.buff += string(event.Rune()) -// } |