-
Notifications
You must be signed in to change notification settings - Fork 162
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
clear_screen to fit in Warp's manner #811
Comments
rustyline's implementation uses |
you can try that out with keybindings to see if that makes a difference with |
@fdncred I saw the custom keybindings right now but I'm wondering what to put here ... let mut keybindings = reedline::default_emacs_keybindings();
keybindings.add_binding(
reedline::KeyModifiers::CONTROL,
reedline::KeyCode::Char('l'),
todo!("not yet find the effect alternative clear_screen impl"),
);
let mut state = Reedline::create()
.with_validator(Box::new(..))
.with_highlighter(Box::new(..))
.with_edit_mode(Box::new(Emacs::new(keybindings))); |
Perhaps |
I was giving you nushell commands to try, sorry. It looks like the reedline pub(crate) fn clear_screen(&mut self) -> Result<()> {
self.stdout.queue(cursor::Hide)?;
let (_, num_lines) = terminal::size()?;
for _ in 0..2 * num_lines {
self.stdout.queue(Print("\n"))?;
}
self.stdout.queue(MoveTo(0, 0))?; # This is go to home
self.stdout.queue(cursor::Show)?;
self.stdout.flush()?;
self.initialize_prompt_position()
} Seems like it might should be closer to the pub(crate) fn clear_scrollback(&mut self) -> Result<()> {
self.stdout
.queue(crossterm::terminal::Clear(ClearType::All))?
.queue(crossterm::terminal::Clear(ClearType::Purge))?
.queue(cursor::MoveTo(0, 0))?
.flush()?;
self.initialize_prompt_position()
} |
To mimic rustline you'd have to use One last thing related to keybindings. You could try |
This should happen within reedline (so a PR). Does it what you mean ;)? |
I mean, you make the changes in your cloned reedline repo and see how it works. If it works well, then you can think about a PR for reedline. |
pub(crate) fn clear_screen(&mut self) -> Result<()> {
self.stdout.queue(cursor::Hide)?;
self.stdout.queue(Clear(ClearType::All))?;
self.stdout.queue(MoveTo(0, 0))?;
self.stdout.queue(cursor::Show)?;
self.stdout.flush()?;
self.initialize_prompt_position(None)
} This change set looks work well (for both Warp and MacOS's Terminal, I don't test other terminals since I don't have one). I'll prepare a patch later after #812 merged. It's 11 PM now so perhaps I'll resume this task tomorrow :D |
If you want it to work like rustyline, |
History time: that we print those newlines is down to my second PR ever to reedline in #30, basically the goal was to replicate the Not sure if Our |
@sholderbach Thanks for the background! I typically have a few options to start a PR for discussions:
I'll send a PR first adopt 3 and see if we can reach 4. |
Warp always has an upper block for the last command:
Currently, Reedline's
clear_screen
will print empty lines to move the current insert point to the most upper position, which is hidden by the block quoted.I don't know how
mysql
can "clear screen" (ctrl+l) properly as shown above, but this can be a compatibility request.The text was updated successfully, but these errors were encountered: