default colors for PuTTY

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

default colors for PuTTY

Michael Wardle-2
Hi

When using Vim with the PuTTY terminal emulator, Vim defaults to a light background, however PuTTY defaults to a dark background (white on black).  This makes some colors in the default color scheme very difficult to read.

PuTTY defaults to sending its terminal type as xterm (and hence TERM=xterm in the environment), and a light background seems like a reasonable default from the XTerms (and other XTerm emulators such as GNOME Terminal) I have seen.

Recent versions of ncurses provide a separate terminfo definition for a "putty" terminal, so we should expect optimal results when using a terminal type of "putty" combined with PuTTY's defaults, however if I set my terminal type to "putty", Vim still sets a light background.

I know a lot of users have overcome this problem by adding an explicit

        set background=dark

in their .vimrc, however this causes problems when that user uses a different terminal that defaults to having a light background.

I have overcome this problem by setting PuTTY's terminal type to putty (under Connection->Data->Terminal-type string) and instead adding the following to my .vimrc

        " PuTTY has a black background by default
        if &term == "putty"
            set background=dark
        endif

Users who prefer PuTTY with a light background are best served by keeping the default setting of "xterm" for the terminal-type string.

As I understand it, Vim already hardcodes some settings for terminal types such as vt220 (no colors), linux (dark background), and xterm (light background).

I would like to see a similar addition for putty if this seems reasonable.

Reply | Threaded
Open this post in threaded view
|

Re: default colors for PuTTY

Bram Moolenaar

Michael Wardle wrote:

> When using Vim with the PuTTY terminal emulator, Vim defaults to a
> light background, however PuTTY defaults to a dark background (white
> on black).  This makes some colors in the default color scheme very
> difficult to read.
>
> PuTTY defaults to sending its terminal type as xterm (and hence
> TERM=xterm in the environment), and a light background seems like a
> reasonable default from the XTerms (and other XTerm emulators such as
> GNOME Terminal) I have seen.
>
> Recent versions of ncurses provide a separate terminfo definition for
> a "putty" terminal, so we should expect optimal results when using a
> terminal type of "putty" combined with PuTTY's defaults, however if I
> set my terminal type to "putty", Vim still sets a light background.
>
> I know a lot of users have overcome this problem by adding an explicit
>
> set background=dark
>
> in their .vimrc, however this causes problems when that user uses a
> different terminal that defaults to having a light background.
>
> I have overcome this problem by setting PuTTY's terminal type to putty
> (under Connection->Data->Terminal-type string) and instead adding the
> following to my .vimrc
>
> " PuTTY has a black background by default
> if &term == "putty"
>    set background=dark
> endif
>
> Users who prefer PuTTY with a light background are best served by
> keeping the default setting of "xterm" for the terminal-type string.
>
> As I understand it, Vim already hardcodes some settings for terminal
> types such as vt220 (no colors), linux (dark background), and xterm
> (light background).
>
> I would like to see a similar addition for putty if this seems reasonable.

If you can compile Vim, you could use this patch:

*** option.c~ Fri Sep 23 21:35:50 2005
--- option.c Wed Sep 28 12:37:02 2005
***************
*** 3277,3282 ****
--- 3277,3283 ----
  * "linux"    Linux console
  * "screen.linux"   Linux console with screen
  * "cygwin"    Cygwin shell
+ * "putty"    Putty program
  * We also check the COLORFGBG environment variable, which is set by
  * rxvt and derivatives. This variable contains either two or three
  * values separated by semicolons; we want the last value in either
***************
*** 3287,3292 ****
--- 3288,3294 ----
  && (STRCMP(T_NAME, "linux") == 0
     || STRCMP(T_NAME, "screen.linux") == 0
     || STRCMP(T_NAME, "cygwin") == 0
+    || STRCMP(T_NAME, "putty") == 0
     || ((p = mch_getenv((char_u *)"COLORFGBG")) != NULL
  && (p = vim_strrchr(p, ';')) != NULL
  && ((p[1] >= '0' && p[1] <= '6') || p[1] == '8')


This is for Vim 7, for Vim 6.3 you may need to make the change manually.

--
ROBIN:  (warily) And if you get a question wrong?
ARTHUR: You are cast into the Gorge of Eternal Peril.
ROBIN:  Oh ... wacho!
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

RE: default colors for PuTTY

Suresh Govindachar`
In reply to this post by Michael Wardle-2


Basic question:  How do you get any colors after opening vim in Putty?  I am using PuTTY to get to a Solaris machine, and turning
syntax on does not give any colors -- I only get black and white.

--Suresh
 

-----Original Message-----
From: Michael Wardle [mailto:[hidden email]]
Sent: Wednesday, September 28, 2005 12:57 AM
To: [hidden email]
Subject: default colors for PuTTY

Hi

When using Vim with the PuTTY terminal emulator, Vim defaults to a light background, however PuTTY defaults to a dark background
(white on black).  This makes some colors in the default color scheme very difficult to read.

PuTTY defaults to sending its terminal type as xterm (and hence TERM=xterm in the environment), and a light background seems like a
reasonable default from the XTerms (and other XTerm emulators such as GNOME Terminal) I have seen.

Recent versions of ncurses provide a separate terminfo definition for a "putty" terminal, so we should expect optimal results when
using a terminal type of "putty" combined with PuTTY's defaults, however if I set my terminal type to "putty", Vim still sets a
light background.

I know a lot of users have overcome this problem by adding an explicit

        set background=dark

in their .vimrc, however this causes problems when that user uses a different terminal that defaults to having a light background.

I have overcome this problem by setting PuTTY's terminal type to putty (under Connection->Data->Terminal-type string) and instead
adding the following to my .vimrc

        " PuTTY has a black background by default
        if &term == "putty"
            set background=dark
        endif

Users who prefer PuTTY with a light background are best served by keeping the default setting of "xterm" for the terminal-type
string.

As I understand it, Vim already hardcodes some settings for terminal types such as vt220 (no colors), linux (dark background), and
xterm (light background).

I would like to see a similar addition for putty if this seems reasonable.

Reply | Threaded
Open this post in threaded view
|

Re: default colors for PuTTY

Wes Potts
I added the following to my login scripts:

export TERM=xtermc


Changing the terminal-type string in the putty session options didn't
seem to have any effect for me.  However, ne of my co-workers had
success using the '-T xtermc' option to vim.

Wes

On 9/30/05, Suresh Govindachar <[hidden email]> wrote:

>
>
> Basic question:  How do you get any colors after opening vim in Putty?  I am using PuTTY to get to a Solaris machine, and turning
> syntax on does not give any colors -- I only get black and white.
>
> --Suresh
>
>
> -----Original Message-----
> From: Michael Wardle [mailto:[hidden email]]
> Sent: Wednesday, September 28, 2005 12:57 AM
> To: [hidden email]
> Subject: default colors for PuTTY
>
> Hi
>
> When using Vim with the PuTTY terminal emulator, Vim defaults to a light background, however PuTTY defaults to a dark background
> (white on black).  This makes some colors in the default color scheme very difficult to read.
>
> PuTTY defaults to sending its terminal type as xterm (and hence TERM=xterm in the environment), and a light background seems like a
> reasonable default from the XTerms (and other XTerm emulators such as GNOME Terminal) I have seen.
>
> Recent versions of ncurses provide a separate terminfo definition for a "putty" terminal, so we should expect optimal results when
> using a terminal type of "putty" combined with PuTTY's defaults, however if I set my terminal type to "putty", Vim still sets a
> light background.
>
> I know a lot of users have overcome this problem by adding an explicit
>
>         set background=dark
>
> in their .vimrc, however this causes problems when that user uses a different terminal that defaults to having a light background.
>
> I have overcome this problem by setting PuTTY's terminal type to putty (under Connection->Data->Terminal-type string) and instead
> adding the following to my .vimrc
>
>         " PuTTY has a black background by default
>         if &term == "putty"
>             set background=dark
>         endif
>
> Users who prefer PuTTY with a light background are best served by keeping the default setting of "xterm" for the terminal-type
> string.
>
> As I understand it, Vim already hardcodes some settings for terminal types such as vt220 (no colors), linux (dark background), and
> xterm (light background).
>
> I would like to see a similar addition for putty if this seems reasonable.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: default colors for PuTTY

Chris Allen
On 30/09/05, Wes Potts <[hidden email]> wrote:
> I added the following to my login scripts:
>
> export TERM=xtermc

More generally, you may want to select different terminal types based
on the terminal you are logging in from (I believe putty sets TERM to
'putty', for example).  The trick, of course, is knowing the
equivalencies.  Here's a snippet from my .login file for tcsh on SunOS
5.8:

if ( $TERM == 'linux' ) then
    setenv TERM rxvt
endif

Another, and better, mechanism is available to you if you've got
terminfo available to Vim (+terminfo feature).  Terminfo allows the
user to store personal terminfo files in a place of their choosing,
which means you can upload settings for any client you've got to your
server and get the right results.  Again, a snippet from my .login
file for tcsh:

if ( $TERM == 'xterm' || $TERM == 'xterm-color' || $TERM == 'screen' ) then
    setenv TERMINFO ~allenc1/.terminfo
endif

The TERMINFO directory contains a number of directories named 'a' to
'z' which contain terminfo files.  For putty support with terminfo you
can simply upload the putty terminfo file to $TERMINFO/p/putty and
applications with support for terminfo will use it.

I say simply, but it might not be.  The creation of a terminfo file is
beyond the scope of this list and the easiest way to get one is to
purloin it from somewhere else (like your system's terminfo diretory
tree, ideally).  My system comes with a putty terminfo file, and there
is a suggestion for one at
http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/terminfo.html
but there appears to be no canonical terminfo file for putty.

Now, if you're wondering why I've blathered on about terminfo when you
could just set your TERM to 'xterm', the answer is that not all xterms
are created equal.  On the SunOS box I use, for example, an xterm is
black and white, so you might want to combine the two tricks into
something like this, depending on where you are:

if ( $TERM == 'putty' ) then
    setenv TERM xterm
    setenv TERMINFO ~allenc1/.terminfo
endif

That does, of course, depend on uploading a 'correct' version of the
xterm terminfo file to $TERMINFO/x/xterm.

Hope that helps,
Chris Allen
Reply | Threaded
Open this post in threaded view
|

Re: default colors for PuTTY

Wes Potts
Chris,

The reason I took such a "sledge hammer" approach was that the sys
admins on our server had forced a generic TERM setting (I think VT100)
in one of the global login scripts.  Do you know of a way to get the
terminal emulator to resend it's term-type string after the login
scripts have finished?  (Or have I mis-understood how the shell gets
this value?)

Wes

On 9/30/05, Chris Allen <[hidden email]> wrote:

> On 30/09/05, Wes Potts <[hidden email]> wrote:
> > I added the following to my login scripts:
> >
> > export TERM=xtermc
>
> More generally, you may want to select different terminal types based
> on the terminal you are logging in from (I believe putty sets TERM to
> 'putty', for example).  The trick, of course, is knowing the
> equivalencies.  Here's a snippet from my .login file for tcsh on SunOS
> 5.8:
>
> if ( $TERM == 'linux' ) then
>     setenv TERM rxvt
> endif
>
> Another, and better, mechanism is available to you if you've got
> terminfo available to Vim (+terminfo feature).  Terminfo allows the
> user to store personal terminfo files in a place of their choosing,
> which means you can upload settings for any client you've got to your
> server and get the right results.  Again, a snippet from my .login
> file for tcsh:
>
> if ( $TERM == 'xterm' || $TERM == 'xterm-color' || $TERM == 'screen' ) then
>     setenv TERMINFO ~allenc1/.terminfo
> endif
>
> The TERMINFO directory contains a number of directories named 'a' to
> 'z' which contain terminfo files.  For putty support with terminfo you
> can simply upload the putty terminfo file to $TERMINFO/p/putty and
> applications with support for terminfo will use it.
>
> I say simply, but it might not be.  The creation of a terminfo file is
> beyond the scope of this list and the easiest way to get one is to
> purloin it from somewhere else (like your system's terminfo diretory
> tree, ideally).  My system comes with a putty terminfo file, and there
> is a suggestion for one at
> http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/terminfo.html
> but there appears to be no canonical terminfo file for putty.
>
> Now, if you're wondering why I've blathered on about terminfo when you
> could just set your TERM to 'xterm', the answer is that not all xterms
> are created equal.  On the SunOS box I use, for example, an xterm is
> black and white, so you might want to combine the two tricks into
> something like this, depending on where you are:
>
> if ( $TERM == 'putty' ) then
>     setenv TERM xterm
>     setenv TERMINFO ~allenc1/.terminfo
> endif
>
> That does, of course, depend on uploading a 'correct' version of the
> xterm terminfo file to $TERMINFO/x/xterm.
>
> Hope that helps,
> Chris Allen
>
Reply | Threaded
Open this post in threaded view
|

Re: default colors for PuTTY

Chris Allen
On 30/09/05, Wes Potts <[hidden email]> wrote:
> The reason I took such a "sledge hammer" approach was that the sys
> admins on our server had forced a generic TERM setting (I think VT100)
> in one of the global login scripts.

Ouch.  I can almost hear the SIGNOCLUE signals bouncing around the
system from here!

> Do you know of a way to get the
> terminal emulator to resend it's term-type string after the login
> scripts have finished?  (Or have I mis-understood how the shell gets
> this value?)

The terminal type is passed as part of telnet option negotiation.  I
do not think there is any effective way to get the value re-sent
automatically.  There is a program called qterm
(http://www.magnicomp.com/qterm/) which claims to detect and print
your terminal type, however.  I can only imagine that it checks the
termcap settings and attempts to map that onto a name in the termcap
database.  No idea how well it works.  It is also commercial software.

If I was in your situation and needed to set a variety of term types
in my login files I think I would probably try to do it based on host.
 That might not work from you, but I only ever tend to use one
particular sort of terminal per host.

HTH,
Chris Allen
Reply | Threaded
Open this post in threaded view
|

Re: default colors for PuTTY

Wes Potts
Thanks so much.  I'm fine for now with what I've done because I only
connect to this particular sever with Putty but, I would really like a
"better" approach for principle and possible future scenarios.  I also
wish the sys admins had not taken such restrictive measures; however,
I don't know their motivations (although I suspect they just didn't
know any better).  Also, my interests lie in Unix systems and, simply
know the right answers to questions like this is important to me.
Would you happen to know where I might find more information about how
Unix/Linux and terminals work and work togethor?  Thanks again for
your help.

Wes

On 9/30/05, Chris Allen <[hidden email]> wrote:

> On 30/09/05, Wes Potts <[hidden email]> wrote:
> > The reason I took such a "sledge hammer" approach was that the sys
> > admins on our server had forced a generic TERM setting (I think VT100)
> > in one of the global login scripts.
>
> Ouch.  I can almost hear the SIGNOCLUE signals bouncing around the
> system from here!
>
> > Do you know of a way to get the
> > terminal emulator to resend it's term-type string after the login
> > scripts have finished?  (Or have I mis-understood how the shell gets
> > this value?)
>
> The terminal type is passed as part of telnet option negotiation.  I
> do not think there is any effective way to get the value re-sent
> automatically.  There is a program called qterm
> (http://www.magnicomp.com/qterm/) which claims to detect and print
> your terminal type, however.  I can only imagine that it checks the
> termcap settings and attempts to map that onto a name in the termcap
> database.  No idea how well it works.  It is also commercial software.
>
> If I was in your situation and needed to set a variety of term types
> in my login files I think I would probably try to do it based on host.
>  That might not work from you, but I only ever tend to use one
> particular sort of terminal per host.
>
> HTH,
> Chris Allen
>