ref: 1e548b7fd5c731682ad49d01bb834037e987c9cf
parent: ed89b32da6ef6fcae739e05d7540082dc918db9d
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jan 2 19:51:47 EST 2018
Delete spaces. This prevents space buildup at the end of the line when hitting ctrl+w
--- a/main.myr
+++ b/main.myr
@@ -908,19 +908,8 @@
irc.cmd = b
irc.off += irc.yank.len
| `termdraw.Ctrl 'w':
- while irc.off > 0
- if !std.isspace(irc.cmd[irc.off - 1])
- break
- ;;
- irc.off--
- ;;
- while irc.off > 0
- if std.isspace(irc.cmd[irc.off - 1])
- break
- ;;
- std.sldel(&irc.cmd, irc.off - 1)
- irc.off--
- ;;
+ deltext(irc, true)
+ deltext(irc, false)
| `termdraw.Kbksp:
if irc.off > 0
irc.off--
@@ -930,6 +919,16 @@
-> false
;;
-> true
+}
+
+const deltext = {irc, isspace+ while irc.off > 0
+ if isspace != std.isspace(irc.cmd[irc.off - 1])
+ break
+ ;;
+ std.sldel(&irc.cmd, irc.off - 1)
+ irc.off--
+ ;;
}
const complete = {irc, chan--
⑨