Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: terminal attributes and singlelinezle



The tsetcap() function is used for setting terminal attributes from
two places - prompt escapes and at the beginning of a fresh line when
it is called to turn off first all attributes and then standout and
underline. In addition to %B, %U etc it is also used for %E (clear
to end-of-line) in a prompt. If the SINGLE_LINE_ZLE option is set,
tsetcap() bails out early. Given that you can use %F, %K etc with
SINGLE_LINE_ZLE along with all of zle_highlight and region_highlight
this seems like a fairly pointless limitation. The manual entry for the
option talks about ksh emulation but ksh emulation includes disabling
PROMPT_PERCENT which achieves the same effect.

I also don't see what is achieved with the belt-and-braces approach of
explicitly turning off standout and underline after turning off all
attributes. If tsetcap(TCALLATTRSOFF, 0) doesn't work, you'll have other
problems besides. And for this particular case, users have the option
of adding extra sequences to PROMPT_EOL_MARK. We could perhaps restore
an if (isset(SINGLELINEZLE)) around this call to tsetcap()? Or some
other condition?

This patch drops the option check and the two superfluous termcap
sequences.

Oliver

diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 51090119f..6d75b0fda 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -1112,8 +1112,6 @@ zrefresh(void)
 #endif
 	/* we probably should only have explicitly set attributes */
 	tsetcap(TCALLATTRSOFF, 0);
-	tsetcap(TCSTANDOUTEND, 0);
-	tsetcap(TCUNDERLINEEND, 0);
 	txtcurrentattrs = txtpendingattrs = txtunknownattrs = 0;
 
 	if (trashedzle && !clearflag)
diff --git a/Src/prompt.c b/Src/prompt.c
index fd83dee64..39fcf5eb7 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1004,8 +1004,7 @@ stradd(char *d)
 mod_export void
 tsetcap(int cap, int flags)
 {
-    if (tccan(cap) && !isset(SINGLELINEZLE) &&
-        !(termflags & (TERM_NOUP|TERM_BAD|TERM_UNKNOWN))) {
+    if (tccan(cap) && !(termflags & (TERM_NOUP|TERM_BAD|TERM_UNKNOWN))) {
 	switch (flags) {
 	case TSC_RAW:
 	    tputs(tcstr[cap], 1, putraw);




Messages sorted by: Reverse Date, Date, Thread, Author