diff options
author | Ivan Tham | 2021-06-15 05:03:56 +0000 |
---|---|---|
committer | Ivan Tham | 2021-06-15 15:46:21 +0000 |
commit | 124514aa7024b0cf40bf01def54d280fcc86897c (patch) | |
tree | e4fa3e9566755d40bd322578fd25f7de99b28377 /helix-view/src | |
parent | 6bdf609caaf4eb1c137f503f147d1e4e4f3e8676 (diff) |
Add cursor kind to separate hidden cursor from pos
Now IME cursor position should be correct since we can still set cursor
position without drawing the cursor.
Diffstat (limited to 'helix-view/src')
-rw-r--r-- | helix-view/src/editor.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 2fd01817..24f43c0e 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -1,5 +1,6 @@ use crate::{theme::Theme, tree::Tree, Document, DocumentId, RegisterSelection, View, ViewId}; use tui::layout::Rect; +use tui::terminal::CursorKind; use std::path::PathBuf; @@ -9,6 +10,7 @@ use anyhow::Error; pub use helix_core::diagnostic::Severity; pub use helix_core::register::Registers; +use helix_core::Position; #[derive(Debug)] pub struct Editor { @@ -276,7 +278,7 @@ impl Editor { // let doc = &mut editor.documents[id]; // } - pub fn cursor_position(&self) -> Option<helix_core::Position> { + pub fn cursor(&self) -> (Option<Position>, CursorKind) { const OFFSET: u16 = 7; // 1 diagnostic + 5 linenr + 1 gutter let view = self.view(); let doc = &self.documents[view.doc]; @@ -284,8 +286,9 @@ impl Editor { if let Some(mut pos) = view.screen_coords_at_pos(doc, doc.text().slice(..), cursor) { pos.col += view.area.x as usize + OFFSET as usize; pos.row += view.area.y as usize; - return Some(pos); + (Some(pos), CursorKind::Hidden) + } else { + (None, CursorKind::Hidden) } - None } } |