This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Problems with remote programs using ncurses (aptitude)

SO wrote:

> I have problems opening remote programs using ncurses library.
> Aptitude for example. Menus and other interface components are just
> garbage on my term on windows vista. Is there a solution for that?

The answer will depend on what terminal you're using.  But first a
summary of the problem: The application wants to draw nice looking boxes
or lines.  So it checks the value of the TERM environment variable and
then asks its local terminfo database what the appropriate characters
are for that terminal, and prints them.  Simple, so far.

The problem is that Cygwin terminals are all codepage-based, not
Unicode.  (There is a rxvt-unicode package, but does not actually
support Unicode yet.)  A codepage-based program is restricted to only
being able to output characters in that codepage, which is pretty much
the whole reason in a nutshell why Unicode was invented and is so

But anyway the default Windows codepage for most systems does *not*
include the line drawing characters.  For example, most western locales
use Windows-1252:
<>.  Compare
this to codepage 437, which is sometimes called the "OEM" codepage
because it corresponds to the one originally used on the original IBM
PC: <>.  Hey
look, line drawing characters!  If you look in slot C4 for example
you'll a horizontal line, and then look in the same slot in CP-1252 and
you'll see LATIN CAPITAL LETTER A WITH DIAERESIS, which explains why you
see Ä where you should see a horizontal line, because the terminfo entry
was written with CP437 in mind.

So one solution is to switch to that codepage.  If and only if you are
using the Cygwin terminal, then you can do this by adding "codepage:oem"
to your CYGWIN environment variable, and everything should work.  Except
of course if you need to actually view any text with those Latin
accented characters.

If you are using something other than the built-in Cygwin terminal, then
you need a different solution.  If you are using rxvt in non-X11 mode,
you can try using the built-in Windows font 'Terminal':

rxvt -fn Terminal -tn rxvt-cygwin-native -e /bin/bash -li

Another alternative (again, for non-X rxvt) is to use a font that is
hacked up to pretend to be CP1252 except it's got the line drawing
glyphs subsituted in those slots.  Google the list archives for
"" which is a verion of Lucida Console appropriately
modified.  After installing this font you should invoke rxvt with
something like:

rxvt -fn "Lucida ConsoleP-14" -tn rxvt-cygwin-native -e /bin/bash -li

You can modify the -14 to select the desired font size.  And again this
assumes you are using non-X rxvt -- if you're using it in X11 mode you
could do something similar (find and specify a font with line drawing
characters) except you would want the terminal name set to rxvt-cygwin
without "-native".

Another solution would be to use a unicode terminal, with the
appropriate setting of TERM.  This means using a non-Cygwin application
which unfortunately usually means pain because they don't play well with
Cygwin's pty emulation, but I'm fairly sure there are some out there
that work (poderosa?) or have been specially modified to work

Another solution is to instead of changing terminals, just select a
different value of TERM, i.e. *tell* the remote end you're using a
different terminal.  The goal here is to select something that is close
enough to your terminal that it shares a common set of control codes,
but doesn't try to use the line drawing chars.  This can be hit and
miss, as you're really lying by saying you're using a different terminal
than the one you really are, but it can be a quick solution.  For
example you might try:

$ TERM=linux-lat aptitude

(This linux-lat terminfo entry is described as "linux with latin1 or
latin2 alternate character set" and it conveniently has all the line
drawing stuff disabled so you'll just see blanks instead.)

And one more possible workaround: take the terminfo entry for your
terminal and modify it to use boring Latin ASCII characters (e.g. + | -
etc) for line drawing.  This is better than the last alternative as you
can rest assured that all the other capabilities should work correctly
as you're just copying the existing one and modifying it.  Here is an
example that does this with the rxvt-cygwin-native terminfo entry:

$ infocmp -1 rxvt-cygwin-native | \
  perl -pe 's@(rxvt-cygwin-native)@$1-latin@;' \
  -e 's@acsc=.*$@acsc=!g#w*q+x\\,<-s.v<m>{\\\\`_0a\\:f\\\\h#}f~p|,@;' \
  >/tmp/term.tmp && \
  tic -o ~/.terminfo /tmp/term.tmp && \
  rm /tmp/term.tmp

This creates a new terminal called rxvt-cygwin-native-latin, compiles
it, and installs it under your home directory in $HOME/.terminfo.  This
is useful because terminfo applications look there first before the
system location /usr/share/terminfo.  You can now use this by changing
your rxvt startup shortcut to specify "-tn rxvt-cygwin-native-latin" or
as above just for one command as:

$ TERM=rxvt-cygwin-native-latin aptitude

Note, the terminfo database has to be local to the machine that runs the
command, not the machine that runs the terminal.  Since you are running
aptitude on a remote system you'll need to transfer your new terminfo
entry there for this to work, but that's pretty simple:

$ (cd ~ && tar c .terminfo) | ssh hostname tar xv


Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]