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

[readline] Ctrl-A and Ctrl-E results invalid position of cursor #2

Closed
g1eng opened this issue Aug 24, 2023 · 5 comments
Closed

[readline] Ctrl-A and Ctrl-E results invalid position of cursor #2

g1eng opened this issue Aug 24, 2023 · 5 comments
Labels
bug Something isn't working cursor

Comments

@g1eng
Copy link
Owner

g1eng commented Aug 24, 2023

Cursor position after C-A or C-E is invalid.

For reproduction, set some prefix, input words and press C-A and C-E.

C-A results bit right position than valid place. and C-E results left side than valid one.

@g1eng
Copy link
Owner Author

g1eng commented Aug 24, 2023

testing with this implementation MANUALLY:

use std::env;
use std::io;
use ttyui::readline::Buffer;

fn main() -> io::Result<()> {
    let mut buf = Buffer::new();
    buf.set_prefix("oi kitarou> ".to_string());
    if let Some(x) = env::args().nth(1) {
        if x == "-d" || x == "--double" {
            buf.double_line_response = true;
        } else {
            panic!("unknown arguments");
        }
    }
    buf.read_line()?;
    println!("\n\n[output]\n\x1b[33m{}\x1b[0m", buf.to_string(),);
    Ok(())
}

@g1eng
Copy link
Owner Author

g1eng commented Aug 24, 2023

It seems to be a problem caused by simple misunderstanding on prefix length handling .

fixing end() and home()...

@g1eng
Copy link
Owner Author

g1eng commented Aug 24, 2023

fixed #4

@g1eng g1eng closed this as completed Aug 24, 2023
@g1eng g1eng reopened this Aug 24, 2023
@g1eng
Copy link
Owner Author

g1eng commented Aug 24, 2023

The problem is not fixed completely.
Try to place cursor on mid of the line and press C-A or C-E.
This is caused by invalid sequence calculation for cursor moving on home() and end(), which is not revealed without prefix string functionality.

@g1eng
Copy link
Owner Author

g1eng commented Aug 24, 2023

refixed #6

@g1eng g1eng closed this as completed Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cursor
Projects
None yet
Development

No branches or pull requests

1 participant