limit ligature backtracking

macos-click-through
keith 4 years ago
parent 811c8ea2d1
commit 494f9a395c

@ -243,6 +243,6 @@ mod tests {
assert_eq!(character_grid.width, width); assert_eq!(character_grid.width, width);
assert_eq!(character_grid.height, height); assert_eq!(character_grid.height, height);
assert_eq!(character_grid.characters, vec![None; new_area]); assert_eq!(character_grid.characters, vec![grid_cell.clone(); new_area]);
} }
} }

@ -114,11 +114,9 @@ impl Editor {
height, height,
} => { } => {
if let Some(window) = self.windows.get_mut(&grid) { if let Some(window) = self.windows.get_mut(&grid) {
window.grid.resize(width, height); window.resize(width, height);
} else { } else {
let new_window = self.windows.insert(grid, Window::new(grid, width, height, None, WindowAnchor::NorthWest, 0.0, 0.0));
Window::new(grid, width, height, None, WindowAnchor::NorthWest, 0.0, 0.0);
self.windows.insert(grid, new_window);
} }
} }
RedrawEvent::GridLine { RedrawEvent::GridLine {

@ -92,7 +92,7 @@ impl Window {
text = text.repeat(times as usize); text = text.repeat(times as usize);
} }
let mut draw_command_start_index = column_pos.clone(); let cell_start_index = column_pos.clone();
if text.is_empty() { if text.is_empty() {
if let Some(cell) = self.grid.get_cell_mut(*column_pos, row_index) { if let Some(cell) = self.grid.get_cell_mut(*column_pos, row_index) {
*cell = Some(("".to_string(), style.clone())); *cell = Some(("".to_string(), style.clone()));
@ -108,27 +108,26 @@ impl Window {
} }
let row = self.grid.row(row_index).unwrap(); let row = self.grid.row(row_index).unwrap();
loop {
if draw_command_start_index > 0 { let mut draw_command_start_index = cell_start_index;
if let Some((_, previous_style)) = &row[draw_command_start_index as usize - 1] { for possible_start_index in (cell_start_index.checked_sub(3).unwrap_or(0)..cell_start_index).rev() {
if &style == previous_style { if let Some((_, possible_start_style)) = &row[possible_start_index as usize] {
draw_command_start_index = draw_command_start_index - 1; if &style == possible_start_style {
continue; draw_command_start_index = possible_start_index;
} continue;
} }
} }
break; break;
} }
let mut draw_command_end_index = column_pos.clone() - 1; let cell_end_index = column_pos.clone();
loop { let mut draw_command_end_index = column_pos.clone();
if draw_command_end_index < self.grid.width - 1 { for possible_end_index in cell_end_index..(cell_end_index + 3).min(self.grid.width - 1) {
if let Some((_, next_style)) = &row[draw_command_end_index as usize] { if let Some((_, possible_end_style)) = &row[possible_end_index as usize] {
if &style == next_style { if &style == possible_end_style {
draw_command_end_index = draw_command_end_index + 1; draw_command_end_index = possible_end_index;
continue; continue;
}
} }
} }
break; break;
@ -219,7 +218,6 @@ impl Window {
} }
pub fn build_draw_commands(&mut self) -> Vec<DrawCommand> { pub fn build_draw_commands(&mut self) -> Vec<DrawCommand> {
let mut draw_commands = Vec::new(); let mut draw_commands = Vec::new();
swap(&mut self.queued_draw_commands, &mut draw_commands); swap(&mut self.queued_draw_commands, &mut draw_commands);

@ -31,14 +31,20 @@ use cursor_renderer::CursorRenderer;
#[derive(Clone)] #[derive(Clone)]
pub struct RendererSettings { pub struct RendererSettings {
animation_length: f32, animation_length: f32,
floating_opacity: f32,
floating_blur: bool,
} }
pub fn initialize_settings() { pub fn initialize_settings() {
SETTINGS.set(&RendererSettings { SETTINGS.set(&RendererSettings {
animation_length: 0.15, animation_length: 0.15,
floating_opacity: 0.7,
floating_blur: true,
}); });
register_nvim_setting!("window_animation_length", RendererSettings::animation_length); register_nvim_setting!("window_animation_length", RendererSettings::animation_length);
register_nvim_setting!("floating_window_opacity", RendererSettings::floating_opacity);
register_nvim_setting!("floating_window_blur", RendererSettings::floating_opacity);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -157,7 +163,8 @@ impl Renderer {
cell_width: u64, cell_width: u64,
style: &Option<Arc<Style>>, style: &Option<Arc<Style>>,
default_style: &Arc<Style>, default_style: &Arc<Style>,
floating: bool floating: bool,
settings: &RendererSettings
) { ) {
self.paint.set_blend_mode(BlendMode::Src); self.paint.set_blend_mode(BlendMode::Src);
@ -167,7 +174,7 @@ impl Renderer {
let mut color = style.background(&default_style.colors); let mut color = style.background(&default_style.colors);
if floating { if floating {
color.a = 0.8; color.a = color.a * settings.floating_opacity.min(1.0).max(0.0);
} }
self.paint.set_color(color.to_color()); self.paint.set_color(color.to_color());
@ -307,7 +314,8 @@ impl Renderer {
cell_width, cell_width,
&style, &style,
&default_style, &default_style,
window_render_info.floating window_render_info.floating,
settings
); );
self.draw_foreground( self.draw_foreground(
&mut canvas, &mut canvas,
@ -356,22 +364,27 @@ impl Renderer {
} }
root_canvas.save(); root_canvas.save();
// let region = Rect::new(5.0, 5.0, 500.0, 500.0);
// root_canvas.clip_rect(&region, None, Some(false));
// let blur = blur((5.0, 5.0), None, None, None).unwrap(); let region = Rect::from_point_and_size(rendered_window.current_position, (image_width, image_height));
// let save_layer_rec = SaveLayerRec::default() root_canvas.clip_rect(&region, None, Some(false));
// .backdrop(&blur) if window_render_info.floating && settings.floating_blur {
// .bounds(&region); let blur = blur((2.0, 2.0), None, None, None).unwrap();
let save_layer_rec = SaveLayerRec::default()
.backdrop(&blur)
.bounds(&region);
// root_canvas.save_layer(&save_layer_rec); root_canvas.save_layer(&save_layer_rec);
}
rendered_window.surface.draw( rendered_window.surface.draw(
root_canvas.as_mut(), root_canvas.as_mut(),
(rendered_window.current_position.x, rendered_window.current_position.y), (rendered_window.current_position.x, rendered_window.current_position.y),
None); None);
// root_canvas.restore(); if window_render_info.floating {
root_canvas.restore();
}
root_canvas.restore(); root_canvas.restore();
let window_position = rendered_window.current_position.clone(); let window_position = rendered_window.current_position.clone();

@ -70,7 +70,7 @@ impl FromValue for bool {
} else if value.is_u64() { } else if value.is_u64() {
*self = value.as_u64().unwrap() != 0; *self = value.as_u64().unwrap() != 0;
} else { } else {
error!("Setting expected a string, but received {:?}", value); error!("Setting expected a bool or 0/1, but received {:?}", value);
} }
} }
} }

@ -305,7 +305,9 @@ mod tests {
let (nvim, _, _) = create::new_child_cmd(&mut create_nvim_command(), NeovimHandler()) let (nvim, _, _) = create::new_child_cmd(&mut create_nvim_command(), NeovimHandler())
.await .await
.unwrap_or_explained_panic("Could not locate or start the neovim process"); .unwrap_or_explained_panic("Could not locate or start the neovim process");
nvim.set_var(&v4, Value::from(v2.clone())).await.ok(); nvim.set_var(&v4, Value::from(v2.clone())).await.ok();
println!("v4 set");
fn noop_update(_v: Value) {} fn noop_update(_v: Value) {}

Loading…
Cancel
Save