cling
cling copied to clipboard
added a command line flag and associated code to support dumb terminals
Emacs and other subshells that manage their own input result in noisy output at the cling interpreter. More specifically, entering "int x = 5;" at the prompt will result in the interpreter recursively printing the input adding one character each time - "iinintint int xint x int x =int x = int x = 5int x = 5;int x = 5;". This seems to be because cling cannot control the cursor location in dumb terminals and therefore cannot update the text at the prompt with each new character. It instead prints each update.
Subshells such as those in emacs, manage user input until a newline and then send the input to the underlying process. The output of the underlying process is echoed in the subshell. Because this shell is managed and cling does not have as much control, this results in noisy output.
This pull request adds a command line flag to indicate whether this is a dumb terminal. If so, it does not update the content of the terminal on each input character and does not add a newline (since the dumb terminal would add its own). This is implemented as a member variable of the TextInput class.
Thanks, Adler!
therefore cannot update the text at the prompt with each new character. It instead prints each update.
I was hoping for textinput to only print that new character. That's what I expected it to do - instead of re-writing the whole line. Can you find out / remind us why it prints everything again and again when adding a single character?
If we manage to fix that (i.e. only add that new character) then we don't need a flag at all - everything will work, magically :-)
I'll take a look! However, I do think it's still a better user experience if the input is not echoed at all on these dumb terminals because the input will already be there and would be duplicated if there is any printing on user input.
Let's step back for a second: when I run M-x term
in emacs and then start cling, the prompt without your patch seems to work fine. I have this as TERM:
$ echo $TERM
eterm-color
What do you have?
Yes, unfortunately, term is not the subshell that the other emacs tools are built on (comint, for example). I believe that the tools are built on eshell which is why the interactive cling mode that I am working on for emacs has the noisy echo.
Welcome to the Emacs shell
~ $ echo $TERM
dumb
~ $
Ah that's great! textinput already checks for $TERM
(in TerminalDisplayUnix.cpp) - can we switch to dumb mode for a dumb TERM instead of adding an extra flag?
Yes, that makes sense! I'll look into that.
Any news? I really like your patch, and changing this to be $TERM
sensitive sounds like a small-ish change?
I've been swamped, but I will work on it very soon
Sorry for the delay. I pushed an update to my fork that removes the flag and detects when terminal type is "dumb". However, since I had to make the change to TerminalDisplay, this may affect Windows as well (which I didn't test). Since TerminalDisplay has a fTerm field that holds the terminal type as a string, I set it to "win" in the subclass TerminalDisplayWin
I will take a look, thanks for the comments.
@Axel-Naumann Hello, I'd love this to get merged. C++ is definitely not my thing but I'm learning it, would you be open to accept the requested changes and possibly give me some advice on the way?
Hi, apologies, but I had to stop working on this pull request because of other responsibilities. I would also love to see this completed if @rilerez or @lazywithclass has some time to work on the refactoring and new conflicts.
Has there been any progress? If not, I'm happy to give it a go, but I might need some pointers to get started.
I think this repo is just a mirror, consider moving your PR here instead: https://github.com/root-project/root/pulls (subdirectory interpreter/cling). Thanks!