help / color / mirror / code / Atom feed
* PATCH: terminal attributes and singlelinezle
@ 2023-01-09 20:41 Oliver Kiddle
  0 siblings, 0 replies; only message in thread
From: Oliver Kiddle @ 2023-01-09 20:41 UTC (permalink / raw)
  To: Zsh workers

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


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)
 	/* 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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-09 20:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 20:41 PATCH: terminal attributes and singlelinezle Oliver Kiddle

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


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).