[SERVER-2852] Linenoise doesn't work well with some terminals Created: 28/Mar/11  Updated: 25/Nov/14  Resolved: 07/Dec/11

Status: Closed
Project: Core Server
Component/s: Shell
Affects Version/s: 1.9.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Kristina Chodorow (Inactive) Assignee: Tad Marshall
Resolution: Duplicate Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux (and other Unix-like OSes)


Issue Links:
Duplicate
duplicates SERVER-4312 Add "key" missing readline/bash (EMAC... Closed
Operating System: ALL
Participants:

 Description   

Particularly rxvt. This is like death by 1000 paper cuts: nothing major, but super annoying.

1) refreshing the line (on backspaces, moving the cursor left, etc.) messed up the prompt (resulting in ">> ").
2) long lines get messed up (this may be related to 1, haven't looked yet)
3) alt shortcuts not supported

#1 (and maybe #2) is because rxvt expects \xb1[1G to return to the start of a line and xterm expects \xb1[0G. I have a feeling that there are a million of these and there's a reason readline is huge. Working on the ones listed above, I'll submit fixes upstream.



 Comments   
Comment by Tad Marshall [ 07/Dec/11 ]

I talked to Kristina and there are no issues here specifically related to one terminal program versus another. It is the lack of specific readline features that is the problem, so this is a duplicate of SERVER-4312 (the merged "add missing readline features" bug).

Comment by Tad Marshall [ 02/Dec/11 ]

Kristina, can you please either add the names of some terminals I should test, or point me to some online list of popular ones I should look at? Most of the (current) code is just assuming that we're running on a VT100 or something close, though we have some keyboard handling that (piecemeal) accepts non-VT100 sequences.

I have tested against Gnome terminal (as provided in Ubuntu) and also against xterm and rxvt and I don't see any terminal-specific issues with any of that set. If there are popular ones that I don't know about, it would help me to know what they are.

readline doesn't itself contain any real terminal-specific code (like escape sequence stuff), but it knows a lot about how to get that information from Linux. linenoise is much more from the "just hard-code it" school, so if we want support for a diverse set of terminals we either need to add a lot of hard-coding or do it the readline way, and get the info from Linux. Either way, I need some failing test cases to do anything with this bug.

Oh, and the cut-and-paste EMACS feature is part of what I'm planning on doing for SERVER-4312, my merged "be more like readline" bug (Add "key" missing readline/bash (EMACS-style) command line features to the shell). I want to hit ctrl-Z job control, ctrl-R history search, ctrl-K kill and ctrl-Y yank, at a minimum.

Thanks!

Comment by Tad Marshall [ 05/Oct/11 ]

Regarding the comment "rxvt expects \xb1[1G to return to the start of a line and xterm expects \xb1[0G", this isn't quite correct. The ESC [ <param> G behaves like some similar VT100 escape sequences and provides a default value which can be explicitly "defaulted" by using a 0 as the parameter. So, ESC [ 1 G is an explicit command to go to the leftmost column and ESC [ 0 G is a more verbose way of saying ESC [ G and means to go to the default column, which is the leftmost one. So, this is a bug in rxvt: it isn't that xterm wants a zero, it just works correctly when it gets one. The code in linenoise.cpp is fixed as you said and uses ESC [ 1 G to work right in both emulators.

Comment by Kristina Chodorow (Inactive) [ 12/Apr/11 ]

#1 & #2 are now fixed.

Another one: Ctrl-y doesn't paste Ctrl-k'd strings.

Generated at Thu Feb 08 03:01:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.