Vim Tips Wiki
m (Added to Syntax and integration categories + minor reformatings)
(Remove html character entities)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=748
 
|id=748
  +
|previous=747
|title=Get bright background colors in linux console (framebuffer)
 
  +
|next=749
|created=June 17, 2004 5:55
+
|created=June 17, 2004
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Michael Hofmann
 
|author=Michael Hofmann
 
|version=6.0
 
|version=6.0
 
|rating=1/3
 
|rating=1/3
 
|category1=Integration
|text=
 
  +
|category2=Syntax
To get 16 background colors in a linux framebuffer console to achieve an appearance like in a 16 color xterm, place the following in your .vimrc (you have to use a real escape character instead of <ESC>, try something like <Ctrl-V><ESC>):
 
 
}}
 
To get 16 background colors in a linux framebuffer console to achieve an appearance like in a 16 color xterm, place the following in your vimrc (you have to use a real escape character instead of <Esc>, try something like <Ctrl-V><Esc>):
   
 
<pre>
 
<pre>
if &amp;term =~ "linux"
+
if &term =~ "linux"
if has("terminfo")
+
if has("terminfo")
set t_Co=16
+
set t_Co=16
" We use the blink attribute for bright background (console_codes(4)) and the
+
" We use the blink attribute for bright background (console_codes(4)) and the
" bold attribute for bright foreground. The redefinition of t_AF is necessary
+
" bold attribute for bright foreground. The redefinition of t_AF is necessary
" for bright "Normal" highlighting to not influence the rest.
+
" for bright "Normal" highlighting to not influence the rest.
set t_AB=<ESC>[%?%p1%{7}%>%t5%p1%{8}%-%e25%p1%;m<ESC>[4%dm
+
set t_AB=<Esc>[%?%p1%{7}%>%t5%p1%{8}%-%e25%p1%;m<Esc>[4%dm
set t_AF=<ESC>[%?%p1%{7}%>%t1%p1%{8}%-%e22%p1%;m�<ESC>[3%dm
+
set t_AF=<Esc>[%?%p1%{7}%>%t1%p1%{8}%-%e22%p1%;m<Esc>[3%dm
  +
endif
endif
 
endif
+
endif
 
</pre>
 
</pre>
  +
Pseudo code for the terminfo entry:
+
Pseudo code for the terminfo entry:
  +
 
<pre>
 
<pre>
if bgcol &gt; 7
+
if bgcol > 7
blink = on (&lt;ESC&gt;[5m)
+
blink = on (<Esc>[5m)
bgcolor = bgcol - 8 (&lt;ESC&gt;[4...m)
+
bgcolor = bgcol - 8 (<Esc>[4...m)
else
+
else
blink = off (&lt;ESC&gt;[25m)
+
blink = off (<Esc>[25m)
bgcolor = bgcol
+
bgcolor = bgcol
end
+
end
   
if fgcol &gt; 7
+
if fgcol > 7
bold = on (&lt;ESC&gt;[1m)
+
bold = on (<Esc>[1m)
fgcolor = fgcol - 8 (&lt;ESC&gt;[3...m)
+
fgcolor = fgcol - 8 (<Esc>[3...m)
else
+
else
bold = off (&lt;ESC&gt;[22m)
+
bold = off (<Esc>[22m)
fgcolor = fgcol
+
fgcolor = fgcol
end
+
end
 
</pre>
 
</pre>
}}
 
 
== Comments ==
 
<!-- parsed by vimtips.py in 0.728172 seconds-->
 
   
 
==Comments==
[[Category:Syntax]]
 
[[Category:Integration]]
 

Latest revision as of 09:20, 29 September 2008

Tip 748 Printable Monobook Previous Next

created June 17, 2004 · complexity intermediate · author Michael Hofmann · version 6.0


To get 16 background colors in a linux framebuffer console to achieve an appearance like in a 16 color xterm, place the following in your vimrc (you have to use a real escape character instead of <Esc>, try something like <Ctrl-V><Esc>):

if &term =~ "linux"
  if has("terminfo")
    set t_Co=16
    " We use the blink attribute for bright background (console_codes(4)) and the
    " bold attribute for bright foreground. The redefinition of t_AF is necessary
    " for bright "Normal" highlighting to not influence the rest.
    set t_AB=<Esc>[%?%p1%{7}%>%t5%p1%{8}%-%e25%p1%;m<Esc>[4%dm
    set t_AF=<Esc>[%?%p1%{7}%>%t1%p1%{8}%-%e22%p1%;m<Esc>[3%dm
  endif
endif

Pseudo code for the terminfo entry:

if bgcol > 7
  blink = on (<Esc>[5m)
  bgcolor = bgcol - 8 (<Esc>[4...m)
else
  blink = off (<Esc>[25m)
  bgcolor = bgcol
end

if fgcol > 7
  bold = on (<Esc>[1m)
  fgcolor = fgcol - 8 (<Esc>[3...m)
else
  bold = off (<Esc>[22m)
  fgcolor = fgcol
end

Comments[]