From cb0d118859edf82e37f64b75c1a2db922f9d7917 Mon Sep 17 00:00:00 2001 From: keith Date: Thu, 12 Dec 2019 11:30:47 -0800 Subject: [PATCH] refactor message parsing --- src/editor.rs | 143 +++++++++++++++++--------------- src/events.rs | 226 +++++++++++++++++++++++++++++++++++++++++++++++--- src/main.rs | 159 +++-------------------------------- src/window.rs | 6 +- 4 files changed, 308 insertions(+), 226 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 5f878f6..d964b2a 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -1,8 +1,9 @@ use std::collections::HashMap; +use neovim_lib::{Neovim, NeovimApi}; use skulpin::skia_safe::{colors, Color4f}; -use neovim_lib::{Neovim, NeovimApi}; +use crate::events::{GridLineCell, RedrawEvent}; #[derive(new, PartialEq, Debug, Clone)] pub struct Colors { @@ -30,22 +31,13 @@ pub struct Style { pub blend: u8 } -#[derive(new)] -pub struct GridLineCell { - pub grid: usize, - pub text: String, - pub row: usize, - pub col_start: usize, - pub style_id: Option -} - pub type GridCell = Option<(char, Style)>; #[derive(new, Debug, Clone)] pub struct DrawCommand { pub text: String, - pub row: usize, - pub col_start: usize, + pub row: u64, + pub col_start: u64, pub style: Style } @@ -59,16 +51,16 @@ pub enum CursorType { pub struct Editor { pub nvim: Neovim, pub grid: Vec>, - pub cursor_pos: (usize, usize), + pub cursor_pos: (u64, u64), pub cursor_type: CursorType, - pub size: (usize, usize), + pub size: (u64, u64), pub default_colors: Colors, pub defined_styles: HashMap, pub previous_style: Option