about summary refs log tree commit diff stats
path: root/src/io/lineedit.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-29 13:39:58 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-29 13:51:55 +0200
commit19068fd7d803a157de671e189e01731bc903ba9e (patch)
treeaae00bec40a00b67586373199cfe6d9789e19013 /src/io/lineedit.nim
parent1dd9eba6aba9760339fbef9bbd4244108fac2eab (diff)
downloadchawan-19068fd7d803a157de671e189e01731bc903ba9e.tar.gz
Factor out map search, remove sugar
Diffstat (limited to 'src/io/lineedit.nim')
-rw-r--r--src/io/lineedit.nim12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/io/lineedit.nim b/src/io/lineedit.nim
index 83f98ccb..51bf7cd9 100644
--- a/src/io/lineedit.nim
+++ b/src/io/lineedit.nim
@@ -1,7 +1,6 @@
 import unicode
 import strutils
 import sequtils
-import sugar
 
 import bindings/quickjs
 import buffer/cell
@@ -153,7 +152,16 @@ proc drawPrompt*(edit: LineEdit) =
 
 proc insertCharseq(edit: LineEdit, cs: var seq[Rune]) =
   let escNext = edit.escNext
-  cs.keepIf((r) => (escNext or not r.isControlChar) and not (r.isAscii and char(r) in edit.disallowed))
+  var i = 0
+  for j in 0 ..< cs.len:
+    if cs[i].isAscii():
+      let c = cast[char](cs[i])
+      if not escNext and c in Controls or c in edit.disallowed:
+        continue
+    if i != j:
+      cs[i] = cs[j]
+    inc i
+
   edit.escNext = false
   if cs.len == 0:
     return