summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authordelthas <delthas@dille.cc>2022-02-13 14:21:59 +0100
committerdelthas <delthas@dille.cc>2022-02-13 14:21:59 +0100
commit31f90336bed276b0ff9e71647a030c11fa838294 (patch)
tree0495b6d6698131a078fb0aaa703e5606aae03318 /ui
parent/query: only send MONITOR, ... if the buffer is new (diff)
Make CTRL+C alternatively clear the input and set '/quit' in it
Diffstat (limited to 'ui')
-rw-r--r--ui/editor.go13
-rw-r--r--ui/ui.go4
2 files changed, 17 insertions, 0 deletions
diff --git a/ui/editor.go b/ui/editor.go
index f4bd247..606bf8d 100644
--- a/ui/editor.go
+++ b/ui/editor.go
@@ -214,6 +214,19 @@ func (e *Editor) Clear() bool {
return true
}
+func (e *Editor) Set(text string) {
+ r := []rune(text)
+ e.text[e.lineIdx] = r
+ e.cursorIdx = len(r)
+ e.computeTextWidth()
+ e.offsetIdx = 0
+ for e.width < e.textWidth[e.cursorIdx]-e.textWidth[e.offsetIdx]+16 {
+ e.offsetIdx++
+ }
+ e.autoCache = nil
+ e.backsearchEnd()
+}
+
func (e *Editor) Right() {
e.right()
e.autoCache = nil
diff --git a/ui/ui.go b/ui/ui.go
index 9f0b13d..fc1a2da 100644
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -318,6 +318,10 @@ func (ui *UI) InputClear() bool {
return ui.e.Clear()
}
+func (ui *UI) InputSet(text string) {
+ ui.e.Set(text)
+}
+
func (ui *UI) InputBackSearch() {
ui.e.BackSearch()
}