From 293bd23f9ecb87c498e088b92537fd7376a7ecfa Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Thu, 12 Dec 2019 14:25:28 -0800 Subject: [PATCH] working cursor styling --- src/editor.rs | 47 +++++++++++++++++++++++++++++++++--- src/events.rs | 60 +++++++++++++++++++++++++++++++++++++++++++++- src/keybindings.rs | 4 ++++ src/main.rs | 2 +- src/window.rs | 4 ---- 5 files changed, 108 insertions(+), 9 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index d964b2a..94a5a5e 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -31,6 +31,14 @@ pub struct Style { pub blend: u8 } +#[derive(new, Debug, Clone, PartialEq)] +pub struct ModeInfo { + #[new(default)] + pub cursor_type: Option, + #[new(default)] + pub cursor_style_id: Option +} + pub type GridCell = Option<(char, Style)>; #[derive(new, Debug, Clone)] @@ -41,21 +49,34 @@ pub struct DrawCommand { pub style: Style } -#[derive(Clone)] +#[derive(Debug, Clone, PartialEq)] pub enum CursorType { Block, Horizontal, Vertical } +impl CursorType { + pub fn from_type_name(name: &str) -> Option { + match name { + "block" => Some(CursorType::Block), + "horizontal" => Some(CursorType::Horizontal), + "vertical" => Some(CursorType::Vertical), + _ => None + } + } +} + pub struct Editor { pub nvim: Neovim, pub grid: Vec>, pub cursor_pos: (u64, u64), pub cursor_type: CursorType, + pub cursor_style: Option