~ecs/mrsh-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH madeline v2] Add ^b and ^f as equivalent to left and right arrows

Details
Message ID
<20230228224538.15388-1-sebastian@sebsite.pw>
DKIM signature
pass
Download raw message
Patch: +22 -5
This also makes the right arrow behave identically to ^f when inserting
hints. It also adds ctrl+shift+right and ctrl+alt+right for inserting
only one word of the hint.

Signed-off-by: Sebastian <sebastian@sebsite.pw>
---
 made/actions.ha | 13 ++++++++++---
 made/line.ha    | 14 ++++++++++++--
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/made/actions.ha b/made/actions.ha
index ca6ac90..0444d74 100644
--- a/made/actions.ha
+++ b/made/actions.ha
@@ -13,18 +13,25 @@ fn home(s: *state) void = {
};

fn end(s: *state) void = {
	insert_hint(s);
	insert_hint(s, false);
	s.pos = len(s.buf);
};

fn insert_hint(s: *state) void = {
fn insert_hint(s: *state, word: bool) void = {
	if (s.pos == len(s.buf)) {
		if (s.searching) {
			clear(s);
			s.searching = false;
			s.hidx = len(hist(s));
		};
		appendstr(s, s.hint);
		if (word) {
			let hint = strings::toutf8(s.hint);
			let idx = nextword(hint, 0);
			insert(s.buf[s.pos], hint[..idx]...);
			s.pos += idx;
		} else {
			appendstr(s, s.hint);
		};
	};
};

diff --git a/made/line.ha b/made/line.ha
index ec41f85..20a17c1 100644
--- a/made/line.ha
+++ b/made/line.ha
@@ -44,6 +44,8 @@ export fn line(cfg: (*config | str)) (str | void | io::EOF | error) = {
		switch (r) {
		case '\x01' => // ^a
			home(&s);
		case '\x02' => // ^b
			prev(&s, false);
		case '\x03' => // ^c
			if (!s.searching) {
				return void;
@@ -62,7 +64,11 @@ export fn line(cfg: (*config | str)) (str | void | io::EOF | error) = {
		case '\x05' => // ^e
			end(&s);
		case '\x06' => // ^f
			insert_hint(&s);
			if (s.pos == len(s.buf)) {
				insert_hint(&s, false);
			} else {
				next(&s, false);
			};
		case '\x08', '\x7f' => // ^h, backspace
			if (s.pos > 0) {
				s.pos = prevchr(s.buf, s.pos);
@@ -168,7 +174,11 @@ fn csi(s: *state) (bool | str | error) = {
	case 'B' => // down
		histmove(s, false);
	case 'C' => // right
		next(s, len(buf) != 0);
		if (s.pos == len(s.buf)) {
			insert_hint(s, len(buf) != 0);
		} else {
			next(s, len(buf) != 0);
		};
	case 'D' => // left
		prev(s, len(buf) != 0);
	case 'H' => // home
-- 
2.38.4
Details
Message ID
<CQUMXVXWV3RX.23IRIE2W1RWHG@monch>
In-Reply-To
<20230228224538.15388-1-sebastian@sebsite.pw> (view parent)
DKIM signature
missing
Download raw message
thanks!

To git@git.d2evs.net:~ecs/madeline
   04c2052..872fa27  madeline -> madeline
Reply to thread Export thread (mbox)