mirror of
https://github.com/nushell/reedline.git
synced 2024-08-17 11:50:42 +03:00
change cursor shape depending on edit mode (#494)
This commit is contained in:
parent
8e1511ad05
commit
da27f0041a
@ -1373,8 +1373,13 @@ impl Reedline {
|
||||
"",
|
||||
);
|
||||
|
||||
self.painter
|
||||
.repaint_buffer(prompt, &lines, None, self.use_ansi_coloring)?;
|
||||
self.painter.repaint_buffer(
|
||||
prompt,
|
||||
&lines,
|
||||
self.prompt_edit_mode(),
|
||||
None,
|
||||
self.use_ansi_coloring,
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@ -1435,8 +1440,13 @@ impl Reedline {
|
||||
|
||||
let menu = self.menus.iter().find(|menu| menu.is_active());
|
||||
|
||||
self.painter
|
||||
.repaint_buffer(prompt, &lines, menu, self.use_ansi_coloring)
|
||||
self.painter.repaint_buffer(
|
||||
prompt,
|
||||
&lines,
|
||||
self.prompt_edit_mode(),
|
||||
menu,
|
||||
self.use_ansi_coloring,
|
||||
)
|
||||
}
|
||||
|
||||
/// Adds an external printer
|
||||
|
@ -1,3 +1,5 @@
|
||||
use crate::PromptEditMode;
|
||||
|
||||
use {
|
||||
super::utils::{coerce_crlf, line_width},
|
||||
crate::{
|
||||
@ -132,6 +134,7 @@ impl Painter {
|
||||
&mut self,
|
||||
prompt: &dyn Prompt,
|
||||
lines: &PromptLines,
|
||||
prompt_mode: PromptEditMode,
|
||||
menu: Option<&ReedlineMenu>,
|
||||
use_ansi_coloring: bool,
|
||||
) -> Result<()> {
|
||||
@ -172,7 +175,13 @@ impl Painter {
|
||||
// can print without overwriting the things written during the painting
|
||||
self.last_required_lines = required_lines;
|
||||
|
||||
self.stdout.queue(RestorePosition)?.queue(cursor::Show)?;
|
||||
self.stdout
|
||||
.queue(RestorePosition)?
|
||||
.queue(cursor::SetCursorShape(match prompt_mode {
|
||||
PromptEditMode::Vi(crate::PromptViMode::Insert) => cursor::CursorShape::Line,
|
||||
_ => cursor::CursorShape::Block,
|
||||
}))?
|
||||
.queue(cursor::Show)?;
|
||||
|
||||
self.stdout.flush()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user