diff --git a/src/events.rs b/src/events.rs new file mode 100644 index 0000000..069878e --- /dev/null +++ b/src/events.rs @@ -0,0 +1,32 @@ +use skulpin::skia_safe::Color4f; + +pub struct GridLineCell { + text: String, + highlight_id: Option, + repeat: Option +} + +pub enum RedrawEvent { + Resize { grid: usize, width: usize, height: usize }, + DefaultColorsSet { foreground: Color4f, background: Color4f, special: Color4f }, + HighlightAttributesDefine { id: usize, style: Style }, + GridLine { grid: usize, row: usize, column_start: usize, cells: Vec }, + Clear { grid: usize }, + CursorGoto { grid: usize, row: usize, column: usize }, + Scroll { grid: usize, top: usize, bottom: usize, left: usize, right: usize, rows: isize, cols: isize } +} + +fn unpack_color(packed_color: u64) -> Color4f { + let packed_color = packed_color as u32; + let r = ((packed_color & 0xff0000) >> 16) as f32; + let g = ((packed_color & 0xff00) >> 8) as f32; + let b = (packed_color & 0xff) as f32; + Color4f { + r: r / 255.0, + g: g / 255.0, + b: b / 255.0, + a: 1.0 + } +} + +pub fn parse_neovim_event(event_name: diff --git a/src/main.rs b/src/main.rs index 44a146a..a20f945 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -#![windows_subsystem = "windows"] +// #![windows_subsystem = "windows"] mod editor; mod window; @@ -73,19 +73,6 @@ fn handle_cursor_goto(cursor_goto_arguments: &Vec, editor: &Arc Color4f { - let packed_color = packed_color as u32; - let r = ((packed_color & 0xff0000) >> 16) as f32; - let g = ((packed_color & 0xff00) >> 8) as f32; - let b = (packed_color & 0xff) as f32; - Color4f { - r: r / 255.0, - g: g / 255.0, - b: b / 255.0, - a: 1.0 - } -} - fn handle_default_colors(default_colors_arguments: &Vec, editor: &Arc>) { if let [ Value::Integer(foreground), Value::Integer(background), Value::Integer(special), diff --git a/src/window.rs b/src/window.rs index 2a45aaa..2668142 100644 --- a/src/window.rs +++ b/src/window.rs @@ -65,8 +65,8 @@ fn draw( let target_cursor_y = cursor_grid_y as f32 * font_height; let (previous_cursor_x, previous_cursor_y) = cursor_pos; - let cursor_x = (target_cursor_x - *previous_cursor_x) * 0.05 + *previous_cursor_x; - let cursor_y = (target_cursor_y - *previous_cursor_y) * 0.05 + *previous_cursor_y; + let cursor_x = (target_cursor_x - *previous_cursor_x) * 0.5 + *previous_cursor_x; + let cursor_y = (target_cursor_y - *previous_cursor_y) * 0.5 + *previous_cursor_y; *cursor_pos = (cursor_x, cursor_y);