New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issues about long commands #26
Conversation
I think this PR is ready for merge, please review. |
I found there is an old |
I'll have a look and test your PR later tonight, from a first glance it looks great! Regarding the old line-scroll branch, I really have no idea why I never merged that. But I guess I never finalized testing of it, and then just forgot about it. I'll have a look at that too, later, unless you beat me to it :) |
Depends on terminal type (I guess, but don't know how to check), I found some strange behaviors when the command is wrapping. If run BitShares cli_wallet inside If run cli_wallet in a ssh session (from a terminal running in an Ubuntu desktop), when the cursor is on the last column, typing one more character then the cursor disappears;
If run cli_wallet directly from console (virtualbox Ubuntu server), when the cursor is on the last column, typing one more character doesn't move the cursor; typing one more character again then the cursor will show on next line; pressing backspace once, the behavior is normal; pressing backspace again (with this PR applied) the cursor doesn't move to the previous line. Any idea? |
Ah, I'm starting to remember the issues I had with the line-scroll branch. You're definitely onto something with differences in terminal types, that's what haunted me as well. However, I have no really good idea how to solve it at the moment. Also, without your PR the behavior for me is ugly, but if I press backspace on a too long line I can at least see the cursor return to the previous line -- ignoring the fact that I have ten duplicate lines above mine. With your PR don't get the ugliness with duplicate lines, but on the other hand the cursor doesn't return so I cannot see where I am. Pressing Ctrl-L refreshes the screen and the line though ... I think what I wanted to accomplish with my line-scroll branch was to truncate long lines, i.e. move the entire contents to fit within the terminal. Displaying So, as things are right now, I don't think I can merge your PR. |
So you encountered the "cursor doesn't return to the previous line" issue as well, probably because the program decided that it should not go back to previous line with the special terminal emulator, so the By the way, although the "truncate" behavior would be useful in some cases, personally I don't like it, because it would be inconvenient to copy long commands (with mouse, to another program, which is useful for BitShares). Again, best if the behavior is configurable. I'll see what I can do. |
Having it configurable would be awesome. Thank you for your understanding, and your effort this far, it's very appreciated! |
Because behavior of |
Yeah, we don't want to add fully fledged ncurses support to editline. There are other projects for that ... |
This PR fixes a few bugs related to long commands.
Steps to reproduce the bugs:
(can also try commands which are longer than 2 lines.)
The root cause of the bugs is the
tty_put('\r')
call inreposition()
, which doesn't work well when the command is too long. Another issue inreposition()
is the use ofrl_point
in the loop, I don't know whether I'll break anything if change it torl_end
, so in the end I decided to not run intoreposition()
(as well asclear_line()
) at all. The new code is maybe less efficient.This PR is now ready for review/merge.