Feature request: Make Home and End keys work properly in SSH character mode

21 replies [Last post]
Seb
Joined: Aug 14 2004
Posts: 18
Feature request: Make Home and End keys work properly in SSH character mode
In PuTTY my home and end keys work properly on a Linux SSH Bash session. In TeSSH 2.33 they don't appear to do anything. I note that there are options for controlling how these work in PuTTY but I simply have it on Standard (the default).
Zugg
Zugg's picture
Joined: Jan 1 1999
Posts: 178
I'll need someone to post a link to a page that describes what these keys are supposed to send to the server. Since these keys are not part of the ANSI standard, I have no idea what codes I'm supposed to send for them.
Vijilante
Joined: Nov 17 2001
Posts: 5
I think this is the most complete guide I have ever found on the subject. http://www.cit.gu.edu.au/~anthony/info/misc/vt102.codes It really isn't too clear in the guide which are codes from the server, and which are codes from the terminal; and requires some interpretation. Scanning down to the "cursor positioning" will give you appropiate codes to send for Home and End.
The only good questions are the ones we have never answered before. Search the Forums
Seb
Joined: Aug 14 2004
Posts: 18
OK, so I did some Googling and the best search I could come up with is this or this. There appear to be several variations on what Home and End, etc. should do so I suggest reading the first 3 results from the 2nd Google search: http://wiki.archlinux.org/index.php/Why_don%27t_my_Home_and_End_keys_wor... http://osdir.com/ml/gnu.mingw.msys/2003-06/msg00042.html http://www.nylug.org/pipermail/nylug-talk/2004-May/019549.html Note that all three include _some_ different codes. It clearly depends on the shell you are using in your remote session. I don't think it is related to the type of SSH or Telnet server. Another suggestion is to set up a telnet server in debug mode, use PuTTY to connect to it, try sending keys with various terminal options set (as there are many) and see what you get. EDIT: Ninja'd but Vij's article only deals with VT102.
Zugg
Zugg's picture
Joined: Jan 1 1999
Posts: 178
I think PuTTY actually has a low-level log file that I can also look at to figure out what it is sending. Thanks for the links! zMUD/CMUD/TeSSH already sends the VT102 codes for these keys as far as I can tell, so my guess is that PuTTY is sending something else. Btw, Seb, you should also check your server shell after you log in with TeSSH and make sure that it recognizes that you are using a VT100 terminal. One of the CMUDPro SSH testers was running into problems with terminal types for some reason. So there might be some bug where the server isn't detecting the terminal type properly. I know that with *nix, it's not a matter of sending a single code for a key on the keyboard...it depends upon the terminal emulation mode. In VT100 mode a key might send something different than when in "xterm" mode, for example.
Rainchild
Joined: Oct 10 2000
Posts: 17
I think for TeSSH you probably should make some base packages like "VT100" "VT220" "Linux" etc etc and have them load based on a terminal type drop down in the session list (not sure if there is one yet or not). PuTTY has a whole page on different keyboard options that you can select, I imagine you don't want to hardcode those options, it'd be better to do them as packages? I expect the answer to be "No", but do you plan to support IBM emulation (eg 5250 for the AS/400, etc). It's quite a bunch different to the more standard ANSI/VT type emulations.
Seb
Joined: Aug 14 2004
Posts: 18
Well, according to the debug window, left key sends and receives:
i     IVRA3 ><ESC>[D
i     IVRA3 <<8>
Right key is extremely odd because it seems to work fine (like left key), but the debug window says:
i     IVRA3 ><ESC>[C
i     IVRA3 <<CR>
[root@IVRA3 ~]# dsgsdf
where dsgsdf is what I had on the command line, and my cursor was mid-way through that text. However, Home and End appear to send nothing. My terminal type is set to vt100, which I believe is the default. All other terminal options are set to default except enabling character mode.
Zugg
Zugg's picture
Joined: Jan 1 1999
Posts: 178
OK, thanks for the info on that. By checking the terminal type, I meant that you need to type some command on your remote server to see what your shell thinks the terminal is set to. In other words, don't just check the TeSSH Preferences screen, but try to find out what the server really thinks your shell terminal is set to. If Home/End are not sending anything, then that's definitely a bug. My guess is that they are not getting intercepted in my keyboard hook routine and are getting eaten by Windows somehow. Edited: And *NO* plans for any IBM emulation, sorry. I'm *Really* trying not to get distracted with TeSSH here. My main product is CMUD and I just don't have time for stuff like IBM emulation. Only if more people start buying TeSSH. Like RainChild, I'm not sure about the business viability of the Telnet/SSH market yet, and I'm not going to make another "zApp mistake" and put months of work into something that nobody buys.
Seb
Joined: Aug 14 2004
Posts: 18
"Zugg" wrote:
By checking the terminal type, I meant that you need to type some command on your remote server to see what your shell thinks the terminal is set to. In other words, don't just check the TeSSH Preferences screen, but try to find out what the server really thinks your shell terminal is set to.
Well, I think this is just using what TeSSH is set to, but in my remote Bash shell over SSH:
[root@IVRA3 ~]# set | grep TERM
TERM=vt100
I tried changing my Terminal Type in TeSSH to cmud and various others, but it gets reset to vt100 every time I reconnect. I even tried changing the default instead of the package, but that didn't help, although the default package does look to have changed. It looks like Terminal Type isn't being saved for the current package. It neither changes on the server, nor in CMUD after a reconnect. That is it does change if I go back in and check in Preferences, even after disconnecting, but gets reset when I reconnect. And since Terminal Type is probably only sent during a connect...
Zugg
Zugg's picture
Joined: Jan 1 1999
Posts: 178
Are you setting the terminal type in the main Session preference page, or are you setting it in the SSH preferences? Seems like there was an additional terminal type in the SSH preferences and I don't remember why it's there or how it is related to the regular session terminal type, but I'll look into it. There was an old bug where it was forcing VT100 mode for SSH sessions, but I thought I had fixed that. The Terminal Type in the Session preferences is sent whenever the server performs a Telnet Terminal Type option request. So it is up to the server itself to request the terminal type. The Terminal stuff in the SSH Preferences set properties of the SSH Shell component (3rd party) that I am using and there are lots of other shell properties that can be set there, but I don't know exactly how they are used with SSH.
Zugg
Zugg's picture
Joined: Jan 1 1999
Posts: 178
I found out what PuTTY is sending. Turns out that xterm added some codes for various keys that VT100 didn't support. I added these keys for HOME/END and also for the F1..F12 keys. This is added in v2.34.
Seb
Joined: Aug 14 2004
Posts: 18
I was setting the terminal type in the main Session preference page - I hadn't even discovered the SSH preferences page!
Seb
Joined: Aug 14 2004
Posts: 18
OK, how about the Page Up and Page Down keys now (in character mode)? [:wink:] They are currently handled locally to scroll the window. Shift-PageUp, Shift-PageDown and Ctrl-PageDown don't seem to do anything and Ctrl-PageUp seems to go to the top of the scrollback buffer. Compare this with PuTTY where PageUp and PageDown are sent to the SSH server, Shift-PageUp and Shift-PageDown scroll the window by pages and Ctrl-PageUp and Ctrl-PageDown appear to go up one line or down one line in the scrollback buffer. This is an important feature as without PageUp and PageDown working properly it might be tricky or impossible to use certain features of certain apps, or at least rather tedious to navigate files or help pages (like in vim).
Zugg
Zugg's picture
Joined: Jan 1 1999
Posts: 178
Can you find me the links to show what codes are sent for the PgUp/Down keys? I couldn't actually get the PuTTY log to show me anything...I did the Home/End keys because PuTTY tells you what they send in the Preferences setup. But it didn't mention what was sent for PgUp/Down. Or maybe I'll check the xterm protocol since it seems that all of these keys are part of the xterm emulation that PuTTY is doing (since the VT100 didn't have any of these keys). The Ctrl-Arrow (or maybe Shift-Arrow) keys scroll line by line, so I don't plan to change that. But having an option to switch the Pageup vs Shift-Pageup might be a good idea.
Seb
Joined: Aug 14 2004
Posts: 18
Well I wasn't talking about ArrowUp or ArrowDown. Yes, this doesn't seem to be VT100, but going on two of the links I had above:
Quote:
"\e[5~": beginning-of-history "\e[6~": end-of-history "\e[3~": delete-char "\e[2~": quoted-insert "\e[5C": forward-word "\e[5D": backward-word "\e\e[C": forward-word "\e\e[D": backward-word
Quote:
# --- Ctrl-Left "\eOd": backward-word # --- Ctrl-Right "\eOc": forward-word # --- Delete key "\e[3~": delete-char
PageUp and PageDown correspond to beginning-of-history and end-of-history as you can see if you use them in bash - they work on your command history. The Delete key is nice too, plus Ctrl-Left and Ctrl-Right for moving around quicker. I didn't know what "quoted-insert" meant, but from my first link above:
Quote:
"quoted-insert" which outputs the actual value of a key, rather than issuing the keypress. quoted-insert is typically "Ctrl-v".
So in PuTTY, doing Ctrl-v Ctrl-Left displays "^[OD" - the same as my second quote. Useful for seeing what PuTTY is doing quickly! [:D] PageUp and PageDown are covered by my first quote and I checked them using Ctrl-v.
Rainchild
Joined: Oct 10 2000
Posts: 17
Written you an essay of an email, Zugg... let me know if you don't get it - it has a zip file attached so I don't know if you block that kinda jazz. I'm not sure if it's any use for SSH connections, but I'd say that the emulation is the same regardless of if you are connecting via SSH or via Telnet.
Zugg
Zugg's picture
Joined: Jan 1 1999
Posts: 178
Rainchild, I haven't received any email from you. Try sending it to sales@zuggsoft.com and put the word zMUD or CMUD into the Subject line and that should ensure that it gets delivered. Seb: Thanks for the additional emulation info. I'll try to add that.
Rainchild
Joined: Oct 10 2000
Posts: 17
Well, the subject line now contains TeSSH, ZMUD and CMUD, so hopefully that should trick the spam rules :) I know the pain, just having rainchild.com for the last 8-10 years (which doesn't even really have a website) brings in 1000's of spams per day... it's insanity! :\ I've been pondering giving it up and registering something else, since all I use it for is personal email/storage.
bortaS
Joined: Oct 9 2000
Posts:
Rainchild, I had the same problem with my domains. I ended up setting up an Email Server that has gray-listing. That helped immensely. I'm on Windows servers, but I know that this feature started on Linux servers and migrated to other operating systems. It went from around 10K spams a month to only about 7-10 a month. [:twisted:]
bortaS ~~ Crusty Klingon Programmer ~~
Zugg
Zugg's picture
Joined: Jan 1 1999
Posts: 178
Rainchild, I got your file. I'll take a look at it after WorldCon next week. Thanks! Our email system uses a combination of Spam Assassin and something called Barracuda (which is a gray-list kind of service that updates regularly). We've gone from about 3000 spam a day down to about 5 a day.
NachosDLC
Joined: Dec 22 2008
Posts: 1
Did this ever get resolved? I'm testing TeSSH 2.37 right now, and it looks like PageUp/PageDown (at least) don't quite work. They still send the key-combination locally.
Zugg
Zugg's picture
Joined: Jan 1 1999
Posts: 178
I've been working on this in the next beta version (3.04) which will also have a TeSSH release. I have fixed the PageUp/PageDown keys so that they properly send the xterm ESC codes whenever you are in "Keypad" mode (like within the vi editor). I am also considering adding a "Keys" preference page where you will be able to specify which keys send which codes in which modes. For example, you'll be able to set Ctrl-V to execute the Paste menu command when at the command line, but send a Ctrl-V character when in keypad mode. I have also changed the default terminal type for TeSSH from VT100 to XTerm since only XTerm supports other keys like PgUp/PgDn. Working great now in VI on v3.04.