From df229c602c6c05e5beae0f52650145fe1aff7d15 Mon Sep 17 00:00:00 2001 From: exoticus <56480961+exoticus@users.noreply.github.com> Date: Fri, 17 Apr 2020 15:22:26 +0200 Subject: [PATCH] =?UTF-8?q?more=20house=20keeping=20=F0=9F=A7=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/mod.rs | 1 + src/renderer/cursor_renderer/mod.rs | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/editor/mod.rs b/src/editor/mod.rs index 9218c5f..bd052fe 100644 --- a/src/editor/mod.rs +++ b/src/editor/mod.rs @@ -111,6 +111,7 @@ impl Editor { pub fn build_draw_commands(&mut self) -> (Vec, bool) { let mut draw_commands = Vec::new(); + for (row_index, row) in self.grid.rows().enumerate() { let mut command = None; diff --git a/src/renderer/cursor_renderer/mod.rs b/src/renderer/cursor_renderer/mod.rs index ea1cd9f..21b10ff 100644 --- a/src/renderer/cursor_renderer/mod.rs +++ b/src/renderer/cursor_renderer/mod.rs @@ -105,14 +105,17 @@ impl Corner { ) -> bool { // Update destination if needed let mut immediate_movement = false; + if destination != self.previous_destination { let travel_distance = destination - self.previous_destination; let chars_travel_x = travel_distance.x / font_dimensions.x; + if travel_distance.y == 0.0 && (chars_travel_x - 1.0).abs() < 0.1 { // We're moving one character to the right. Make movement immediate to avoid lag // while typing immediate_movement = true; } + self.t = 0.0; self.start_position = self.current_position; self.previous_destination = destination; @@ -127,8 +130,7 @@ impl Corner { let relative_scaled_position: Point = ( self.relative_position.x * font_dimensions.x, self.relative_position.y * font_dimensions.y, - ) - .into(); + ).into(); let corner_destination = destination + relative_scaled_position; @@ -240,7 +242,6 @@ impl CursorRenderer { dt: f32, ) { let render = self.blink_status.update_status(&cursor); - let settings = SETTINGS.get::(); if settings.vfx_mode != self.previous_vfx_mode { @@ -270,7 +271,6 @@ impl CursorRenderer { }; let (grid_x, grid_y) = self.previous_position; - let (character, font_dimensions): (String, Point) = { let editor = EDITOR.lock(); let character = match editor.grid.get_cell(grid_x, grid_y) { @@ -289,9 +289,9 @@ impl CursorRenderer { }; (character, (font_width, font_height).into()) }; + let destination: Point = (grid_x as f32 * font_width, grid_y as f32 * font_height).into(); let center_destination = destination + font_dimensions * 0.5; - let new_cursor = Some(cursor.shape.clone()); if self.previous_cursor_shape != new_cursor { @@ -307,6 +307,7 @@ impl CursorRenderer { } let mut animating = false; + if !center_destination.is_zero() { for corner in self.corners.iter_mut() { let corner_animating =