diff options
author | bptato <nincsnevem662@gmail.com> | 2023-06-29 13:39:58 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-06-29 13:51:55 +0200 |
commit | 19068fd7d803a157de671e189e01731bc903ba9e (patch) | |
tree | aae00bec40a00b67586373199cfe6d9789e19013 /src/io/lineedit.nim | |
parent | 1dd9eba6aba9760339fbef9bbd4244108fac2eab (diff) | |
download | chawan-19068fd7d803a157de671e189e01731bc903ba9e.tar.gz |
Factor out map search, remove sugar
Diffstat (limited to 'src/io/lineedit.nim')
-rw-r--r-- | src/io/lineedit.nim | 12 |
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 |