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

Re: %F{1} outputs code twice, %F{red} doesn't



On Fri, 28 May 2010 00:26:49 +0200
Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> % print -P a%F{1}a|cat -v
> a^[[38;5;1m^[[38;5;1ma
> % echo ${(%V):-a%F{1}a}
> a^[[38;5;1m^[[38;5;1ma
> 
> (wasn't sure if those use the same code path)
> 
> % print -P a%F{red}a|cat -v
> a^[[38;5;1ma

I'm not sure how you get it duplicated, but it does look to me like it's
trying to do the same thing two ways, one with termcap, and one with
ANSI sequences, or whatever you've told it to use instead via
zle_highlight.

I'm not absolutely sure what I was doing, but I think I must have meant
to return if the termcap code was found, and only drop through after
that if it was an ANSI colour.  However, I'm not sure even that's
necessarily correct, it might be best just to try it in case the user is
smarter than termcap and has set up zle_highlight appropriately.

Any better theories...

Index: Src/prompt.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/prompt.c,v
retrieving revision 1.59
diff -p -u -r1.59 prompt.c
--- Src/prompt.c	10 Jul 2009 21:32:49 -0000	1.59
+++ Src/prompt.c	1 Jun 2010 20:59:48 -0000
@@ -1925,8 +1925,13 @@ set_colour_attribute(int atr, int fg_bg,
 	    } else {
 		tputs(tgoto(tcstr[tc], colour, colour), 1, putshout);
 	    }
+	    /* That worked. */
+	    return;
 	}
-	/* for 0 to 7 assume standard ANSI works, otherwise it won't. */
+	/*
+	 * Nope, that didn't work.
+	 * If 0 to 7, assume standard ANSI works, otherwise it won't.
+	 */
 	if (colour > 7)
 	    return;
     }


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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