[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OS X Terminal.app and Aptitude

Thomas Dickey wrote:
>> I compiled your terminfo on my Debian box, and ssh'd over with TERM
>> set to 'nsterm'.  A few initial observations:
>>   - Color is lost at the Bash prompt.
> bash on Debian?  odd - since I thought it would be using ncurses (actually
> the termcap interface).  It may be special-casing $TERM by comparing for
> something containing "xterm".

Correct, bash on Debian.  You're right, the default .bashrc contains:

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in

00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

# Comment in the above and uncomment this below for a color prompt
\]\$ '

# If this is an xterm set the title to user@host:dir
case "$TERM" in
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:

Adding 'macosx' to the cases cleared that up.

>>   - Horizontal borders in Aptitude (e.g. in the search or quit
>> dialogs) become '?' characters.
> This is more interesting.  Those dashes look like they're double-width.  I have
> a hunch that your locale on Debian is set to a UTF-8 flavor and that aptitude
> is emitting line-drawing in UTF-8, but that Terminal isn't doing the Right
> Thing with that.  A quick check with uxterm shows me that aptitude sends
> _something_ in UTF-8.
> I seem to recall reading that Terminal can handle UTF-8, so given that, one of
> these possibilities comes to mind:
> 	a) the OS X locale isn't UTF-8 (and Terminal gets confused)

I checked my Terminal settings and the encoding is set to UTF-8.  I
tried changing my Terminal font from Bitstream Vera Sans Mono to the
included VT-100 and Courier fonts to see if it could be a bug in the
font, but no change.

> 	b) Terminal works for UTF-8 text, but not line-drawing (chooses
> 	   an incorrect set of glyphs for mapping the line-drawing text).

Is one of the terminfo settings related to how double byte characters
are sent to the terminal?  Feeling my way around tack I found the
alternate character set tests.  Sure enough when set to nsterm many of
the characters are rendered as '?'.  Set to our running macosx copy of
OS X's included /usr/share/terminfo/78/xterm-color I see that all the
alternate characters are drawn correctly.

During that process I also noticed that blink worked when I was set to
nsterm, so I've added 'enter_blink_mode=\E[5m' to macosx with success.

>>   - Delete works at the bash prompt, but in Aptitude it prints '^[[3~'.
>>   - Backspace works in Aptitude, whereas with xterm-color it printed '^?'.
> Your stty settings might not match the nsterm terminfo entry.  Bear in
> mind that for *BSD the general rule is
> 	stty erase \^H
> while Debian does
> 	stty erase \^?

On the Mac stty is:

$ stty -a
speed 9600 baud; 40 rows; 100 columns;
lflags: icanon isig iexten echo echoe -echok echoke -echonl echoctl
        -echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
        brkint -inpck -ignpar -parmrk
oflags: opost onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
        -dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
        eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
        min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
        stop = ^S; susp = ^Z; time = 0; werase = ^W;

When I ssh to Debian it's:

$ stty -a
speed 9600 baud; rows 40; columns 100; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>;
swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase
= ^W; lnext = ^V; flush = ^O;
min = 1; time = 0;
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl
ixon -ixoff -iuclc ixany imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0
bs0 vt0 ff0
isig icanon iexten echo echoe -echok -echonl -noflsh -xcase -tostop
-echoprt echoctl echoke

Looks like they were consistently ^?.  Leaving all that alone and
changing to key_backspace=\177 in our macosx terminfo fixed up my
backspace issues in Aptitude after recompiling.

I'm starting to get more familiar with tack, and I see that the
solution here is to get a proper terminfo definition made and
disseminated for Terminal.app.  A couple questions related to that quest:

Many tests say a capability is "...not present" or "...not defined".

(flash) Flash is not defined.  (flash) Done
(cnorm) Cursor-normal is not defined.  (cnorm) Done
(hs) Has-status line is not defined.  (hs) Done

Would the advisable strategy be to enable these in the terminfo and
see if Terminal.app will then pass the tests?  Finding that it
supports blink makes me wonder what other capabilities it might
support, though not having comprehensive knowledge of the individual
capabilities themselves I don't know whether you necessarily want them
defined just because Terminal supports them.

Also, since the menu issues in Aptitude are my only known remaining
bug, any guidance on particular tests/capability settings that might
relate to the rendering issues in the screen shots I posted?  A lot of
the drawing and alignment related tests seemed to pass, so nothing is
jumping out at me.



P.S. My current nsterm/macosx diff:

$ infocmp nsterm macosx
comparing nsterm to macosx.
    comparing booleans.
        bw: T:F.
        km: F:T.
        mir: F:T.
        xon: T:F.
    comparing numbers.
        ncv: 37, NULL.
    comparing strings.
        clear: '\E[H\E[J', '\E[H\E[2J'.
        dch: NULL, '\E[%p1%dP'.
        dch1: NULL, '\E[P'.
        el1: '\E[1K', NULL.
        enacs: '\E(B\E)0', '\E)0'.
        is2: NULL, '\E7\E[r\E[m\E[?7h\E[?1;3;4;6l\E[4l\E8\E>'.
        ka1: '\EOq', NULL.
        ka3: '\EOs', NULL.
        kb2: '\EOr', NULL.
        kc1: '\EOp', NULL.
        kc3: '\EOn', NULL.
        kdch1: NULL, '\E[3~'.
        kent: '\EOM', NULL.
        kf1: '\EOP', '\E[11~'.
        kf10: NULL, '\E[21~'.
        kf11: NULL, '\E[23~'.
        kf12: NULL, '\E[24~'.
        kf13: NULL, '\E[25~'.
        kf14: NULL, '\E[26~'.
        kf15: NULL, '\E[28~'.
        kf16: NULL, '\E[29~'.
        kf17: NULL, '\E[31~'.
        kf18: NULL, '\E[32~'.
        kf19: NULL, '\E[33~'.
        kf2: '\EOQ', '\E[12~'.
        kf20: NULL, '\E[34~'.
        kf3: '\EOR', '\E[13~'.
        kf4: '\EOS', '\E[14~'.
        kf5: NULL, '\E[15~'.
        kf6: NULL, '\E[17~'.
        kf7: NULL, '\E[18~'.
        kf8: NULL, '\E[19~'.
        kf9: NULL, '\E[20~'.
        kfnd: NULL, '\E[1~'.
        kich1: NULL, '\E[2~'.
        kmous: NULL, '\E[M'.
        knp: NULL, '\E[6~'.
        kpp: NULL, '\E[5~'.
        kslt: NULL, '\E[4~'.
        op: '\E[0m', '\E[m'.
        rmam: '\E[?7l', NULL.
        rmcup: NULL, '\E[2J\E[?47l\E8'.
        rmir: NULL, '\E[4l'.
        rs2: '\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h',
        sgr0: '\E[m\017', '\E[m'.
        smam: '\E[?7h', NULL.
        smcup: NULL, '\E7\E[?47h'.
        smir: NULL, '\E[4h'.

Reply to: