summaryrefslogtreecommitdiff
path: root/Src/prompt.c
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2024-02-15 14:48:04 +0100
committerOliver Kiddle <opk@zsh.org>2024-02-15 14:48:04 +0100
commit14c230dc3216b7fe0f63d797347e14178d4ede2b (patch)
tree127a4799cc5db7544bbad9ee20d0592bc96f949f /Src/prompt.c
parent04ae7dc64cde2fa6b7354f685596ff570404a2c9 (diff)
downloadzsh-14c230dc3216b7fe0f63d797347e14178d4ede2b.tar.gz
zsh-14c230dc3216b7fe0f63d797347e14178d4ede2b.zip
52533: add module to provide alternate readonly views of the content of .zle.hlgroups
Diffstat (limited to 'Src/prompt.c')
-rw-r--r--Src/prompt.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/Src/prompt.c b/Src/prompt.c
index 0d674ceab..7acbe0e47 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -241,6 +241,34 @@ promptexpand(char *s, int ns, char *rs, char *Rs)
return new_vars.buf;
}
+/* Get the escape sequence for a given attribute. */
+/**/
+mod_export char *
+zattrescape(zattr atr, int *len)
+{
+ struct buf_vars new_vars;
+ zattr savecurrent = txtcurrentattrs;
+ zattr saveunknown = txtunknownattrs;
+
+ memset(&new_vars, 0, sizeof(new_vars));
+ new_vars.last = bv;
+ bv = &new_vars;
+ new_vars.bufspc = 256;
+ new_vars.bp = new_vars.bufline = new_vars.buf = zshcalloc(new_vars.bufspc);
+ new_vars.dontcount = 1;
+
+ txtunknownattrs = 0;
+ treplaceattrs(atr);
+ applytextattributes(TSC_PROMPT);
+
+ bv = new_vars.last;
+
+ txtpendingattrs = txtcurrentattrs = savecurrent;
+ txtunknownattrs = saveunknown;
+
+ return unmetafy(new_vars.buf, len);
+}
+
/* Parse the argument for %H */
static char *
parsehighlight(char *arg, char endchar, zattr *atr)