~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] Add ^g to cancel search

Details
Message ID
<20230217051626.13371-1-sebastian@sebsite.pw>
DKIM signature
pass
Download raw message
Patch: +6 -3
Ok so this one is actually a bit tricky, since there's some variation on
exactly how this behaves in other readline-esque programs. It's pretty
universal that ^g cancels the search, similarly to what ^d used to do,
so I implemented that here. ^d at the end of a line is now a no-op when
searching. ^g also keeps the text you typed in the buffer. The line that
you searched for can be edited by using ^e at the end of the line (or ^a
at the beginning of the line), as was already the case. ^c cancels the
search and removes the text from the buffer, as it already did (so ^c is
like ^g except it clears the buffer as well).

Signed-off-by: Sebastian <sebastian@sebsite.pw>
---
 made/line.ha | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/made/line.ha b/made/line.ha
index 98b3f87..f36e01b 100644
--- a/made/line.ha
+++ b/made/line.ha
@@ -55,9 +55,7 @@ export fn line(cfg: (*config | str)) (str | void | io::EOF | error) = {
		case '\x04' => // ^d
			if (s.pos < len(s.buf)) {
				delete(s.buf[s.pos..nextchr(s.buf, s.pos)]);
			} else if (s.searching) {
				s.searching = false;
			} else if (len(s.buf) == 0) {
			} else if (len(s.buf) == 0 && !s.searching) {
				return io::EOF;
			};
		case '\x05' => // ^e
@@ -68,6 +66,11 @@ export fn line(cfg: (*config | str)) (str | void | io::EOF | error) = {
			} else {
				next(&s, false);
			};
		case '\x07' => // ^g
			if (s.searching) {
				s.searching = false;
				s.hidx = len(hist(&s));
			};
		case '\x08', '\x7f' => // ^h, backspace
			if (s.pos > 0) {
				s.pos = prevchr(s.buf, s.pos);
-- 
2.38.4
Details
Message ID
<CQSPYR97Z7I4.1KGH1FH273AH4@monch>
In-Reply-To
<20230217051626.13371-1-sebastian@sebsite.pw> (view parent)
DKIM signature
missing
Download raw message
hm, i think we should keep ^d like it is now (albeit probably fixing
s.hidx like you did with ^g), but i'm open to adding ^g as well
Reply to thread Export thread (mbox)