You are not logged in.

#1 2017-08-17 20:21:16

blippy
Member
Registered: 2010-11-18
Posts: 38

rxvt ncurses and putty configuration

I have an ncurses program on my Arch box that I am accessing from putty on Windows. There are two problems:
1. lines come out as characters
2. Home and End keys aren't respected.

I've done a lot of searching about putty issues, tried them (including setting NCURSES_NO_UTF8_ACS=1, etc.). Nothing seems to fix the problems.

I suspect there's something wrong with rxvt itself. It doesn't seem to respect .Xresources, for starters. For example, I have the lines
Rxvt*background:   black
Rxvt*foreground:  white
but the terminal still pops up black on white on my TigerVNC LXDE session, even after I have run
xrdb ~/.Xresources

I get the impression that putty might be depending on rxvt settings somehow, so maybe that's part of the problem.

Now, when I run my program in either xterm or urxvt in LXDE, it works perfectly. There's something about rxvt and putty that causes problems.

Midnight commander works perfectly on whatever terminal I use, putty, or not.

Any suggestions as to how I should proceed?

Offline

#2 2017-08-17 20:32:39

blippy
Member
Registered: 2010-11-18
Posts: 38

Re: rxvt ncurses and putty configuration

OK, seeings as rxvt is an AUR package, I removed it. So that fixes the rxvt issues.

However, when I try to gain access to Arch via putty, I still can't get the lines or the home/end keys working properly, despite various combinations of putty
Terminal>keyboard and Connection data terminal-type string to no avail.

Offline

#3 2017-08-17 20:45:01

blippy
Member
Registered: 2010-11-18
Posts: 38

Re: rxvt ncurses and putty configuration

Oh, urxvt doesn't seem to work properly now, either, even from a LXDE VNC session. xterm is working, though.

Why does life have to be so difficult?

Offline

#4 2017-08-18 07:29:52

blippy
Member
Registered: 2010-11-18
Posts: 38

Re: rxvt ncurses and putty configuration

Ah, the plot thickens! The program works on terminals st and urxvt, xterm, but not on rxvt and linux. So the trick is to try to identify the difference between key sequences that are generated, and what the terminal thinks they are.

So I wrote this program:

#include <iostream>
#include <unistd.h>

int main()
{
        while(1) {
                char b = 0;
                size_t n = read(STDIN_FILENO, &b, 1);
                if(n<1) continue;
                if(b =='q') break;
                std::cout << int(b) << "\n";
        }


        return 0;
}

Let's run it. On st and xterm terminals, the Home key generates ^[[H, whereas on rxvt it is ^[[7~, and on linux it is ^[[1~. Now let's see what the terminal thinks the keys should be:
infocmp st | grep home   has home=\E[H. Likewise for linux, rxvt, and xterm.

So for some bizarre reason, the keys generated are not the same. Not sure WTF, but in the end, I don't think it matters. The trick is to fix the terminfo database along the lines suggested in https://wiki.archlinux.org/index.php/Ho … ot_working . I haven't gotten that far yet, but I'm getting the warm fuzzies.

Offline

#5 2017-08-18 11:48:44

blippy
Member
Registered: 2010-11-18
Posts: 38

Re: rxvt ncurses and putty configuration

Fark me this is hard! I changed HOME in my terminfo, and it messed up when I pressed the home key.

I think there are two distinct things going on: key recognition, and escape sequences sent to the terminal, and you have to work out which is causing the problem.

My current thinking is that the home key sequence is not being recognised correctly, not that the wrong escape sequence is being sent to the terminal. The mangled horizontal/vertical line drawing is the result of the wrong excape sequences being sent.

Offline

#6 2017-08-18 14:42:38

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,739

Re: rxvt ncurses and putty configuration

As a sanity check, in the various terminals, check the value of the environmental variable TERM using echo $TERM.  Then see what happens if you set that variable to 'linux'; export TERM=linux    ?

Last edited by ewaller (2017-08-18 14:42:54)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#7 2017-08-19 09:58:08

blippy
Member
Registered: 2010-11-18
Posts: 38

Re: rxvt ncurses and putty configuration

ewaller wrote:

As a sanity check, in the various terminals, check the value of the environmental variable TERM using echo $TERM.  Then see what happens if you set that variable to 'linux'; export TERM=linux    ?

Thanks ewaller, I think I may have a better handle on it. I think what happens is the following (correct me if I'm wrong):

1) terminfo has two entries: "home", which is the string that is sent to the display to move the cursor home, and "khome", which is the string received from the keyboard when the home key is presses. I didn't appreciate that distinction before.

2) curses keypad() can be set to true or false. If unset, or false, the program received characters in a "raw" form. If keypad() set to true, then ncurses cooks them into a single int (>255).

Now, the application in question received characters in the raw form via a read from stdin, so it has to do its own interpretation of what's going on. However, it assumes that home is ^[[H, when it probably isn't. It's probably something like ^[[1~. Now, when I use xterm under LXDE, but not via putty, the home key generates ^[[H (despite the fact that terminfo says that it generates ^[OH).

At least that's what I think is going on.

It's at times like this I am reminded of Monty Python's Meaning of Life;

I do wish you'd listen, Wymer. It's perfectly simple. If you're not getting your hair cut, you don't have to move your brother's clothes down to the lower peg. You simply collect his note before lunch, after you've done your scripture prep, when you've written your letter home, before rest, move your own clothes onto the lower peg, greet the visitors, and report to Mr. Viney that you've had your chit signed.

Offline

Board footer

Powered by FluxBB