fix ligature rendering

macos-click-through
keith 5 years ago
parent 7f772be865
commit 4297faca63

@ -91,13 +91,11 @@ impl Editor {
} }
} }
fn add_character(command: &mut Option<DrawCommand>, character: &char, dirty: bool, row_index: u64, col_index: u64, style: Style) { fn add_character(command: &mut Option<DrawCommand>, character: &char, row_index: u64, col_index: u64, style: Style) {
match command { match command {
Some(command) => command.text.push(character.clone()), Some(command) => command.text.push(character.clone()),
None => { None => {
if dirty { command.replace(DrawCommand::new(character.to_string(), (col_index, row_index), style));
command.replace(DrawCommand::new(character.to_string(), (col_index, row_index), style));
}
} }
} }
} }
@ -108,7 +106,7 @@ impl Editor {
add_command(&mut draw_commands, command); add_command(&mut draw_commands, command);
command = None; command = None;
} }
add_character(&mut command, &character, self.dirty[row_index][col_index], row_index as u64, col_index as u64, new_style.clone()); add_character(&mut command, &character, row_index as u64, col_index as u64, new_style.clone());
} else { } else {
add_command(&mut draw_commands, command); add_command(&mut draw_commands, command);
command = None; command = None;
@ -118,6 +116,18 @@ impl Editor {
} }
let should_clear = self.should_clear; let should_clear = self.should_clear;
let draw_commands = draw_commands.into_iter().filter(|command| {
let (x, y) = command.grid_position;
let dirty_row = &self.dirty[y as usize];
for char_index in 0..command.text.chars().count() {
if dirty_row[x as usize + char_index] {
return true;
}
}
return false;
}).collect::<Vec<DrawCommand>>();
let (width, height) = self.size; let (width, height) = self.size;
self.dirty = vec![vec![false; width as usize]; height as usize]; self.dirty = vec![vec![false; width as usize]; height as usize];
self.should_clear = false; self.should_clear = false;

@ -155,6 +155,6 @@ impl Renderer {
} }
} }
delta_cursor_x.abs() > 0.001 || delta_cursor_y.abs() > 0.001 draw_commands.len() > 0 || delta_cursor_x.abs() > 0.001 || delta_cursor_y.abs() > 0.001
} }
} }

Loading…
Cancel
Save