zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] prompt: support generic non-visible regions
@ 2022-08-10 11:51 Felipe Contreras
  2022-08-10 18:59 ` Mikael Magnusson
  2022-08-11 14:37 ` Roman Perepelitsa
  0 siblings, 2 replies; 21+ messages in thread
From: Felipe Contreras @ 2022-08-10 11:51 UTC (permalink / raw)
  To: zsh-workers; +Cc: Oliver Kiddle, dana, Felipe Contreras

readline assumes anything between \001 (start of header) and \002 (start
of text) is non-visible characters.

In zsh we do this with `%F{color}`, but we could support
`\001\e[31m\002` as well.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---

I don't know if this is the right way to do it, but in my limited
testing it seems to work fine.

 Src/prompt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Src/prompt.c b/Src/prompt.c
index 092de63a4..803937029 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -886,6 +886,12 @@ putpromptchar(int doprint, int endchar, zattr *txtchangep)
 		    bv->bp += strlen(bv->bp);
 		}
 	    }
+	} else if(*bv->fm == 0x01) { // start non-visible characters
+	    addbufspc(1);
+	    *bv->bp++ = Inpar;
+	} else if(*bv->fm == 0x02) { // end non-visible characters
+	    addbufspc(1);
+	    *bv->bp++ = Outpar;
 	} else {
 	    char c = *bv->fm == Meta ? *++bv->fm ^ 32 : *bv->fm;
 
-- 
2.37.1



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2022-08-11 23:28 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-10 11:51 [PATCH] prompt: support generic non-visible regions Felipe Contreras
2022-08-10 18:59 ` Mikael Magnusson
2022-08-10 19:56   ` Felipe Contreras
2022-08-11 14:02     ` Mikael Magnusson
2022-08-11 14:26       ` Felipe Contreras
2022-08-11 18:32         ` Mikael Magnusson
2022-08-11 18:47           ` Felipe Contreras
2022-08-11 18:54             ` Mikael Magnusson
2022-08-11 19:46               ` Felipe Contreras
2022-08-11 20:38                 ` Bart Schaefer
2022-08-11 23:22                   ` Felipe Contreras
2022-08-11 14:37 ` Roman Perepelitsa
2022-08-11 15:21   ` Bart Schaefer
2022-08-11 16:20     ` Felipe Contreras
2022-08-11 16:49       ` Bart Schaefer
2022-08-11 18:48         ` Felipe Contreras
2022-08-11 17:24   ` Roman Perepelitsa
2022-08-11 18:55     ` Roman Perepelitsa
2022-08-11 19:23     ` Felipe Contreras
2022-08-11 19:35       ` Roman Perepelitsa
2022-08-11 19:44         ` Felipe Contreras

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).