about summary refs log tree commit diff stats
path: root/src/io/buffer.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-06-17 15:43:46 +0200
committerbptato <nincsnevem662@gmail.com>2022-06-17 15:44:50 +0200
commit692b0bcc108107c191c04a255eeeab237ea5c385 (patch)
tree2ee29223423cd3a49a2d92aac537034d912b1757 /src/io/buffer.nim
parent7addf30a055aaf1a787d3b32cf4254d7afde65f9 (diff)
downloadchawan-692b0bcc108107c191c04a255eeeab237ea5c385.tar.gz
Submit form on pressing enter in search field
Diffstat (limited to 'src/io/buffer.nim')
-rw-r--r--src/io/buffer.nim14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/io/buffer.nim b/src/io/buffer.nim
index 57537cf6..e3858908 100644
--- a/src/io/buffer.nim
+++ b/src/io/buffer.nim
@@ -995,7 +995,19 @@ proc click*(buffer: Buffer): Option[ClickAction] =
     of TAG_INPUT:
       let input = HTMLInputElement(clickable)
       case input.inputType
-      of INPUT_SEARCH, INPUT_TEXT, INPUT_PASSWORD:
+      of INPUT_SEARCH:
+        var value = input.value
+        print(HVP(buffer.height + 1, 1))
+        print(EL())
+        let status = readLine("SEARCH: ", value, buffer.width, {'\r', '\n'})
+        if status:
+          input.value = value
+          input.rendered = false
+          buffer.reshape = true
+        if input.form != nil:
+          let submitaction = submitForm(input.form, input)
+          return submitaction
+      of INPUT_TEXT, INPUT_PASSWORD:
         var value = input.value
         print(HVP(buffer.height + 1, 1))
         print(EL())