Fix scrolling issue introduced when extracting the grid

macos-click-through
Jon Valdés 5 years ago
parent ddad13be2d
commit 1750ac8e76

@ -15,14 +15,17 @@ pub struct CharacterGrid {
} }
impl CharacterGrid { impl CharacterGrid {
pub fn new() -> CharacterGrid { pub fn new(size: (u64, u64)) -> CharacterGrid {
CharacterGrid { let mut result = CharacterGrid {
characters: vec![], characters: vec![],
dirty: vec![], dirty: vec![],
width: 0, width: 0,
height: 0, height: 0,
should_clear: true, should_clear: true,
} };
result.resize(size.0, size.1);
result
} }
pub fn resize(&mut self, width: u64, height: u64) { pub fn resize(&mut self, width: u64, height: u64) {

@ -33,7 +33,6 @@ pub struct DrawCommand {
pub struct Editor { pub struct Editor {
pub grid: CharacterGrid, pub grid: CharacterGrid,
pub title: String, pub title: String,
pub size: (u64, u64),
pub font_name: Option<String>, pub font_name: Option<String>,
pub font_size: Option<f32>, pub font_size: Option<f32>,
pub cursor: Cursor, pub cursor: Cursor,
@ -45,10 +44,8 @@ pub struct Editor {
impl Editor { impl Editor {
pub fn new() -> Editor { pub fn new() -> Editor {
let mut editor = Editor { let mut editor = Editor {
grid: CharacterGrid::new(), grid: CharacterGrid::new(INITIAL_DIMENSIONS),
title: "Neovide".to_string(), title: "Neovide".to_string(),
size: INITIAL_DIMENSIONS,
font_name: None, font_name: None,
font_size: None, font_size: None,
cursor: Cursor::new(), cursor: Cursor::new(),
@ -216,11 +213,9 @@ impl Editor {
Box::new((top as i64 .. (bot as i64 + rows)).rev()) Box::new((top as i64 .. (bot as i64 + rows)).rev())
}; };
let (_, height) = self.size;
for y in y_iter { for y in y_iter {
let dest_y = y - rows; let dest_y = y - rows;
if dest_y >= 0 && dest_y < height as i64 { if dest_y >= 0 && dest_y < self.grid.height as i64 {
let x_iter : Box<dyn Iterator<Item=i64>> = if cols > 0 { let x_iter : Box<dyn Iterator<Item=i64>> = if cols > 0 {
Box::new((left as i64 + cols) .. right as i64) Box::new((left as i64 + cols) .. right as i64)

@ -182,8 +182,7 @@ impl CursorRenderer {
let editor = EDITOR.lock().unwrap(); let editor = EDITOR.lock().unwrap();
let (_, grid_y) = cursor.position; let (_, grid_y) = cursor.position;
let (_, previous_y) = self.previous_position; let (_, previous_y) = self.previous_position;
let (_, height) = editor.size; if grid_y == editor.grid.height - 1 && previous_y != grid_y {
if grid_y == height - 1 && previous_y != grid_y {
self.command_line_delay = self.command_line_delay + 1; self.command_line_delay = self.command_line_delay + 1;
if self.command_line_delay < COMMAND_LINE_DELAY_FRAMES { if self.command_line_delay < COMMAND_LINE_DELAY_FRAMES {
self.previous_position self.previous_position

Loading…
Cancel
Save