diff options
-rw-r--r-- | app.go | 3 | ||||
-rw-r--r-- | ui/editor.go | 12 | ||||
-rw-r--r-- | ui/ui.go | 4 |
3 files changed, 18 insertions, 1 deletions
@@ -320,7 +320,8 @@ func (app *App) handleMouseEvent(ev *tcell.EventMouse) { func (app *App) handleKeyEvent(ev *tcell.EventKey) { switch ev.Key() { case tcell.KeyCtrlC: - app.win.Exit() + app.win.InputClear() + app.typing() case tcell.KeyCtrlL: app.win.Resize() case tcell.KeyCtrlU, tcell.KeyPgUp: diff --git a/ui/editor.go b/ui/editor.go index bf21f85..15785e8 100644 --- a/ui/editor.go +++ b/ui/editor.go @@ -164,6 +164,18 @@ func (e *Editor) Flush() (content string) { return } +func (e *Editor) Clear() { + if e.TextLen() == 0 { + return + } + e.text[e.lineIdx] = []rune{} + e.textWidth = e.textWidth[:1] + e.cursorIdx = 0 + e.offsetIdx = 0 + e.autoCache = nil + return +} + func (e *Editor) Right() { e.right() e.autoCache = nil @@ -228,6 +228,10 @@ func (ui *UI) InputEnter() (content string) { return ui.e.Flush() } +func (ui *UI) InputClear() { + ui.e.Clear() +} + func (ui *UI) Resize() { w, h := ui.screen.Size() ui.e.Resize(w - 9 - ui.config.ChanColWidth - ui.config.NickColWidth) |