summaryrefslogtreecommitdiff
path: root/ui/editor.go
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2021-07-12 19:54:52 +0200
committerHubert Hirtz <hubert@hirtz.pm>2021-07-13 19:21:08 +0200
commitc078fbbb029fd248756ea5d7726f9ae6090a4ee3 (patch)
tree22577d5ea43eb26d75cdbd065bfbdcd4088884fc /ui/editor.go
parentRatelimit +typing and send +typing=done once only (diff)
Clear the input on CTRL+C instead of quitting
We have /QUIT for quitting. Most well-known IRC clients don't quit on CTRL+C but they do on QUIT. Clearing the editor input on CTRL+C is useful for shell-like behaviour "abort current line, let me start my line again".
Diffstat (limited to 'ui/editor.go')
-rw-r--r--ui/editor.go12
1 files changed, 12 insertions, 0 deletions
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