ColdGrub1384 / LibTerm

iOS sandboxed terminal with Python, Lua and Clang
https://libterm.app
MIT License
630 stars 115 forks source link

Support adding/deleting text at arbitrary cursor position in a command line #27

Open kevin-he-01 opened 4 years ago

kevin-he-01 commented 4 years ago

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

  1. Open LibTerm
  2. Enter a long line, such as echo some long string to be displayed
  3. Move the cursor to anywhere except at the end of the command line in a way described above
  4. 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.

ColdGrub1384 commented 4 years ago

I will work on it

dullbananas commented 4 years ago

Are you still working on it?

ColdGrub1384 commented 4 years ago

I tried sometime ago but I couldn't find a way to do it. I'll keep trying.

ColdGrub1384 commented 4 years ago

I found a way to do it but it does not currently work for commands like the Python REPL, the Lua REPL or bc

ongyx commented 4 years ago

The Libterm 5.1.4 update yesterday has fixed this. I checked it myself