bug: Vim trys to set color -1

2010-03-17 Fir de Conversatie graywh
I found a bug where Vim tries to set foreground/background color -1.
I noticed the issue when running Vim inside Tmux and
using :CSApproxSnapshot.  Tmux doesn't handle the escape sequences
(\E[3-1m and \E[4-1m) the same as Xterm does.  Godlygeek seems to
think Vim is trying to reset the colors back to the terminal default.
Anyway, I'm hoping someone else can help fix this or make sense of the
problem.

--
Will Gray

-- 
You received this message from the vim_dev maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php


Re: bug: Vim trys to set color -1

2010-03-17 Fir de Conversatie Matt Wozniski
On Wed, Mar 17, 2010 at 9:51 AM, graywh gra...@gmail.com wrote:
 I found a bug where Vim tries to set foreground/background color -1.
 I noticed the issue when running Vim inside Tmux and
 using :CSApproxSnapshot.  Tmux doesn't handle the escape sequences
 (\E[3-1m and \E[4-1m) the same as Xterm does.  Godlygeek seems to
 think Vim is trying to reset the colors back to the terminal default.
 Anyway, I'm hoping someone else can help fix this or make sense of the
 problem.

This problem can be  reproduced without CSApprox by just doing

:hi Normal ctermbg=NONE

or

:hi Normal ctermfg=NONE

These commands result in a call to term_fg_color or term_bg_color from
syntax.c with an argument of  -1.  I'm not sure what exactly the fix
should be, though.  Maybe this?  The below seems to work from quick
tests, using ^[[39m and ^[[49m as the color-reset for xterm-alikes.

~Matt

--- src/term.c.orig 2010-03-17 11:33:36.289769000 -0400
+++ src/term.c  2010-03-17 11:35:31.71950 -0400
@@ -2756,7 +2756,8 @@
 /* Special handling of 16 colors, because termcap can't handle it */
 /* Also accept \e[3%dm for TERMINFO, it is sometimes used */
 /* Also accept CSI instead of Esc[ */
-if (n = 8  t_colors = 16
+/* Also handle -1 specially as a reset to default */
+if (((n = 8  t_colors = 16) || n == -1)
   ((s[0] == ESC  s[1] == '[') || (s[0] == CSI  (i = 1) == 1))
   s[i] != NUL
   (STRCMP(s + i + 1, %p1%dm) == 0
@@ -2770,9 +2771,9 @@
%s%s%%dm,
 #endif
i == 2 ? IF_EB(\033[, ESC_STR [) : \233,
-   s[i] == '3' ? (n = 16 ? 38;5; : 9)
-   : (n = 16 ? 48;5; : 10));
-   OUT_STR(tgoto(buf, 0, n = 16 ? n : n - 8));
+   s[i] == '3' ? (n == -1 ? 3 : n = 16 ? 38;5; : 9)
+   : (n == -1 ? 4 : n = 16 ? 48;5; : 10));
+   OUT_STR(tgoto(buf, 0, n == -1 ? 9 : n = 16 ? n : n - 8));
 }
 else
OUT_STR(tgoto((char *)s, 0, n));

-- 
You received this message from the vim_dev maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php