progress toward cleaning up event parsing

macos-click-through
Keith Simmons 5 years ago
parent 44b545fa28
commit 1f4dab9d9a

@ -0,0 +1,32 @@
use skulpin::skia_safe::Color4f;
pub struct GridLineCell {
text: String,
highlight_id: Option<usize>,
repeat: Option<usize>
}
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<GridLineCell> },
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:

@ -1,4 +1,4 @@
#![windows_subsystem = "windows"] // #![windows_subsystem = "windows"]
mod editor; mod editor;
mod window; mod window;
@ -73,19 +73,6 @@ fn handle_cursor_goto(cursor_goto_arguments: &Vec<Value>, editor: &Arc<Mutex<Edi
} }
} }
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
}
}
fn handle_default_colors(default_colors_arguments: &Vec<Value>, editor: &Arc<Mutex<Editor>>) { fn handle_default_colors(default_colors_arguments: &Vec<Value>, editor: &Arc<Mutex<Editor>>) {
if let [ if let [
Value::Integer(foreground), Value::Integer(background), Value::Integer(special), Value::Integer(foreground), Value::Integer(background), Value::Integer(special),

@ -65,8 +65,8 @@ fn draw(
let target_cursor_y = cursor_grid_y as f32 * font_height; let target_cursor_y = cursor_grid_y as f32 * font_height;
let (previous_cursor_x, previous_cursor_y) = cursor_pos; 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_x = (target_cursor_x - *previous_cursor_x) * 0.5 + *previous_cursor_x;
let cursor_y = (target_cursor_y - *previous_cursor_y) * 0.05 + *previous_cursor_y; let cursor_y = (target_cursor_y - *previous_cursor_y) * 0.5 + *previous_cursor_y;
*cursor_pos = (cursor_x, cursor_y); *cursor_pos = (cursor_x, cursor_y);

Loading…
Cancel
Save