From: Joey Pabalinas <joeypabalinas@gmail.com>
To: Zsh Workers Mailing List <zsh-workers@zsh.org>
Cc: Joey Pabalinas <joeypabalinas@gmail.com>
Subject: [PATCH] Src/prompt.c: Add %O and %o prompt escapes
Date: Fri, 27 Jul 2018 00:14:28 -1000 [thread overview]
Message-ID: <20180727101428.lrylyaghwcpykupu@hobbes.alyptik.lan> (raw)
[-- Attachment #1: Type: text/plain, Size: 2505 bytes --]
Implement %O and %o as shorthands for resetting fg/bg color and
terminal attributes (underline/standout/boldface) respectively.
Update the documentation to include the two new prompt escapes.
Signed-off-by: Joey Pabalinas <joeypabalinas@gmail.com>
---
Doc/Zsh/prompt.yo | 6 ++++++
Src/prompt.c | 19 +++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo
index 909012c8e787b04fcf..8086c54b2e651923c5 100644
--- a/Doc/Zsh/prompt.yo
+++ b/Doc/Zsh/prompt.yo
@@ -244,10 +244,16 @@ colours are allowed in the second format also.
)
item(tt(%K) LPAR()tt(%k)RPAR())(
Start (stop) using a different bacKground colour. The syntax is
identical to that for tt(%F) and tt(%f).
)
+item(tt(%O))(
+Reset foreground and background colours to default.
+)
+item(tt(%o))(
+Turn off all terminal attributes (underline/standout/boldface).
+)
item(tt(%{)...tt(%}))(
Include a string as a literal escape sequence.
The string within the braces should not change the cursor
position. Brace pairs can nest.
diff --git a/Src/prompt.c b/Src/prompt.c
index 959ed8e3d57a0286a8..48980e744437bc6b23 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -567,10 +567,29 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep)
case 'k':
txtchangeset(txtchangep, TXTNOBGCOLOUR, TXT_ATTR_BG_ON_MASK);
txtunset(TXT_ATTR_BG_ON_MASK);
set_colour_attribute(TXTNOBGCOLOUR, COL_SEQ_BG, TSC_PROMPT);
break;
+ case 'O':
+ txtchangeset(txtchangep, TXTNOFGCOLOUR, TXT_ATTR_FG_ON_MASK);
+ txtchangeset(txtchangep, TXTNOBGCOLOUR, TXT_ATTR_BG_ON_MASK);
+ txtunset(TXT_ATTR_FG_ON_MASK);
+ txtunset(TXT_ATTR_BG_ON_MASK);
+ set_colour_attribute(TXTNOFGCOLOUR, COL_SEQ_FG, TSC_PROMPT);
+ set_colour_attribute(TXTNOBGCOLOUR, COL_SEQ_BG, TSC_PROMPT);
+ break;
+ case 'o':
+ txtchangeset(txtchangep, TXTNOUNDERLINE, TXTUNDERLINE);
+ txtchangeset(txtchangep, TXTNOSTANDOUT, TXTSTANDOUT);
+ txtchangeset(txtchangep, TXTNOBOLDFACE, TXTBOLDFACE);
+ txtunset(TXTUNDERLINE);
+ txtunset(TXTSTANDOUT);
+ txtunset(TXTBOLDFACE);
+ tsetcap(TCUNDERLINEEND, TSC_PROMPT|TSC_DIRTY);
+ tsetcap(TCSTANDOUTEND, TSC_PROMPT|TSC_DIRTY);
+ tsetcap(TCALLATTRSOFF, TSC_PROMPT|TSC_DIRTY);
+ break;
case '[':
if (idigit(*++bv->fm))
arg = zstrtol(bv->fm, &bv->fm, 10);
if (!prompttrunc(arg, ']', doprint, endchar, txtchangep))
return *bv->fm;
--
Cheers,
Joey Pabalinas
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
reply other threads:[~2018-07-27 10:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180727101428.lrylyaghwcpykupu@hobbes.alyptik.lan \
--to=joeypabalinas@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).