From 124514aa7024b0cf40bf01def54d280fcc86897c Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Tue, 15 Jun 2021 13:03:56 +0800 Subject: 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. --- helix-view/src/editor.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'helix-view/src') 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 { + pub fn cursor(&self) -> (Option, 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 } } -- cgit v1.2.3-70-g09d2