From 8467ef18ab7d5d4185a3b1e443dfef58689ee196 Mon Sep 17 00:00:00 2001 From: Keith Simmons Date: Tue, 17 Dec 2019 13:00:33 -0800 Subject: [PATCH] refactored editor into multiple files to make things more readable --- src/editor/cursor.rs | 81 ++++++++++++++ src/{editor.rs => editor/mod.rs} | 184 +++++-------------------------- src/editor/style.rs | 49 ++++++++ src/events.rs | 26 +++-- src/main.rs | 2 +- src/renderer/mod.rs | 37 +++---- 6 files changed, 188 insertions(+), 191 deletions(-) create mode 100644 src/editor/cursor.rs rename src/{editor.rs => editor/mod.rs} (56%) create mode 100644 src/editor/style.rs diff --git a/src/editor/cursor.rs b/src/editor/cursor.rs new file mode 100644 index 0000000..4bd95f8 --- /dev/null +++ b/src/editor/cursor.rs @@ -0,0 +1,81 @@ +use std::collections::HashMap; +use skulpin::skia_safe::Color4f; + +use super::style::{Style, Colors}; + +#[derive(Debug, Clone, PartialEq)] +pub enum CursorShape { + Block, + Horizontal, + Vertical +} + +impl CursorShape { + pub fn from_type_name(name: &str) -> Option { + match name { + "block" => Some(CursorShape::Block), + "horizontal" => Some(CursorShape::Horizontal), + "vertical" => Some(CursorShape::Vertical), + _ => None + } + } +} + +#[derive(new, Debug, Clone, PartialEq)] +pub struct CursorMode { + #[new(default)] + pub shape: Option, + #[new(default)] + pub style_id: Option +} + +#[derive(Clone)] +pub struct Cursor { + pub position: (u64, u64), + pub shape: CursorShape, + pub style: Option