@@ -4,7 +4,7 @@
5use crossterm::event::Event;
5use crossterm::event::Event;
6use helix_core::Position;
6use helix_core::Position;
7−use tui::{buffer::Buffer as Surface, layout::Rect};
7+use tui::{buffer::Buffer as Surface, layout::Rect, terminal::CursorKind};
9pub type Callback = Box<dyn FnOnce(&mut Compositor)>;
9pub type Callback = Box<dyn FnOnce(&mut Compositor)>;
@@ -47,8 +47,9 @@ pub trait Component: Any + AnyComponent {
47 /// Render the component onto the provided surface.
47 /// Render the component onto the provided surface.
48 fn render(&self, area: Rect, frame: &mut Surface, ctx: &mut Context);
48 fn render(&self, area: Rect, frame: &mut Surface, ctx: &mut Context);
50+ /// Get cursor position and cursor kind.
50− fn cursor_position(&self, area: Rect, ctx: &Editor) -> Option<Position> {
51+ fn cursor(&self, area: Rect, ctx: &Editor) -> (Option<Position>, CursorKind) {
51− None
52+ (None, CursorKind::Hidden)
54 /// May be used by the parent component to compute the child area.
55 /// May be used by the parent component to compute the child area.
@@ -137,20 +138,19 @@ impl Compositor {
137 layer.render(area, surface, cx)
138 layer.render(area, surface, cx)
140− let pos = self
141+ let (pos, kind) = self.cursor(area, cx.editor);
141− .cursor_position(area, cx.editor)
142− .map(|pos| (pos.col as u16, pos.row as u16));
142+ let pos = pos.map(|pos| (pos.col as u16, pos.row as u16));
144− self.terminal.draw(pos);
144+ self.terminal.draw(pos, kind);
147− pub fn cursor_position(&self, area: Rect, editor: &Editor) -> Option<Position> {
147+ pub fn cursor(&self, area: Rect, editor: &Editor) -> (Option<Position>, CursorKind) {
148 for layer in self.layers.iter().rev() {
148 for layer in self.layers.iter().rev() {
149− if let Some(pos) = layer.cursor_position(area, editor) {
149+ if let (Some(pos), kind) = layer.cursor(area, editor) {
150− return Some(pos);
150+ return (Some(pos), kind);
153− None
153+ (None, CursorKind::Hidden)
156 pub fn find(&mut self, type_name: &str) -> Option<&mut dyn Component> {
156 pub fn find(&mut self, type_name: &str) -> Option<&mut dyn Component> {