Skip to content
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

Moving the cursor wipes out next lines #48

Closed
dcampbell24 opened this issue Jul 9, 2016 · 10 comments
Closed

Moving the cursor wipes out next lines #48

dcampbell24 opened this issue Jul 9, 2016 · 10 comments

Comments

@dcampbell24
Copy link

dcampbell24 commented Jul 9, 2016

The library calls refresh in the cursor movement functions causing future lines to be wiped out. This is causing issues for a game I embedded the line editor in, because the bottom portion of the screen gets wiped if the user moves the cursor while entering a command.

@gwenn
Copy link
Collaborator

gwenn commented Jul 13, 2016

Indeed, it seems possible to move only the cursor like here or here.
I will try on unix.

@gwenn
Copy link
Collaborator

gwenn commented Jul 14, 2016

Ok,
Moving only the cursor may be difficult in multi-line mode.
I am not sure but it seems to me that the culprit is the current strategy used to refresh the screen.
Because we are clearing from the prompt to the end of the screen (\x1b[J).
Could you please confirm that if we clear only the lines/rows drawn/used by the editor, your issue will be solved ?

@dcampbell24
Copy link
Author

@gwenn yes, I think that is the right strategy. Even better might be to take a rectangle or bounding box as a parameter. I also don't think that the prompt should write anything to output. This can be done by application code and separates concerns.

@dcampbell24
Copy link
Author

dcampbell24 commented Jul 15, 2016

What I mean about writing to stdout is to not write the prefix or the line ending. That gives a lot more flexibility to the code consuming the library. For example if I want to have "\r\n" rather "\n" as the EOL.

@gwenn
Copy link
Collaborator

gwenn commented Jul 15, 2016

Just so I fully understand, you want the following line to be removed:
https://github.com/kkawakam/rustyline/blob/master/src/lib.rs#L877

    println!("");

?

@dcampbell24
Copy link
Author

@gwenn yes, I think that line should either be removed, or the readline function should at least take an argument to allow for cross platform line endings. Thank you for your help.

@gwenn
Copy link
Collaborator

gwenn commented Jul 16, 2016

Are you sure println!("") doesn't print \r\n on windows ?

gwenn added a commit to gwenn/rustyline that referenced this issue Jul 16, 2016
And do not ignorespace by default.
And do not panic when the history is empty
gwenn added a commit to gwenn/rustyline that referenced this issue Jul 16, 2016
And do not ignorespace by default.
And do not panic when the history is empty
@dcampbell24
Copy link
Author

dcampbell24 commented Jul 17, 2016

Are you sure println!("") doesn't print \r\n on windows ?

No.

I am more concerned with how it inter-operates with termion. I am going to open source the project I am using rustyline in, so I can give a link after I update the license. Also, I can open a new ticket to discuss line terminators if it makes sense to.

@gwenn
Copy link
Collaborator

gwenn commented Aug 3, 2016

The associated patch has been merged in master.

@dcampbell24
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants