LibTerm
LibTerm copied to clipboard
Support adding/deleting text at arbitrary cursor position in a command line
Issue
LibTerm does not seem to support line-editing features, such as editing in the middle of a command. For example, if you have typed echo some long string to be displayed
and realized that you want to insert very
between some
and long
to make the command echo some very long string to be displayed
, you would have to delete all the text up to some
and insert very
, which is very annoying.
This may be considered a bug, since the shell prompt should behave mostly like edit
, which allows editing at any cursor position, but this is more like a feature request since one would be to detect whether the cursor position is "legal" (somewhere in the current command line and not in the shell prompt hostname $
or in previous commands)
The discontinued OpenTerm does support such editing feature. One can try it out by building it from source (no longer available from the App Store though). Furthermore, on a normal bash session on a computer you can use the arrow keys and insert some text in the middle assuming one have GNU readline
enabled (by default on an interactive shell). I know iOS do not have cursor keys in its built in on screen keyboard but there are still plenty ways to change the cursor position without using an external keyboard.
Moving the cursor is possible by clicking at a position in the command line or deep pressing the on screen keyboard and move your finger to move the cursor.
Steps to reproduce
- Open LibTerm
- Enter a long line, such as
echo some long string to be displayed
- Move the cursor to anywhere except at the end of the command line in a way described above
- Enter text, notice that nothing you type is displayed (typing have no effect)
Expected Behavior
The characters typed are inserted in the command line at the cursor position.
Actual Behavior
One can move the cursor, but typing have no effect unless the cursor is at the end of the command line.
I will work on it
Are you still working on it?
I tried sometime ago but I couldn't find a way to do it. I'll keep trying.
I found a way to do it but it does not currently work for commands like the Python REPL, the Lua REPL or bc
The Libterm 5.1.4 update yesterday has fixed this. I checked it myself