just some whitespace for more clarity

macos-click-through
exoticus 5 years ago
parent cc783adeb4
commit 020f44abc6

@ -197,15 +197,15 @@ impl Editor {
} }
add_command(&mut draw_commands, command); add_command(&mut draw_commands, command);
} }
let should_clear = self.grid.should_clear;
let should_clear = self.grid.should_clear;
let draw_commands = draw_commands let draw_commands = draw_commands
.into_iter() .into_iter()
.filter(|command| { .filter(|command| {
let (x, y) = command.grid_position; let (x, y) = command.grid_position;
let min = (x as i64 - 1).max(0) as u64; let min = (x as i64 - 1).max(0) as u64;
let max = (x + command.cell_width + 1).min(self.grid.width); let max = (x + command.cell_width + 1).min(self.grid.width);
for char_index in min..max { for char_index in min..max {
if self.grid.is_dirty_cell(char_index, y) { if self.grid.is_dirty_cell(char_index, y) {
return true; return true;
@ -230,6 +230,7 @@ impl Editor {
}; };
let mut text = cell.text; let mut text = cell.text;
if let Some(times) = cell.repeat { if let Some(times) = cell.repeat {
text = text.repeat(times as usize); text = text.repeat(times as usize);
} }
@ -250,6 +251,7 @@ impl Editor {
} }
*column_pos += text.graphemes(true).count() as u64; *column_pos += text.graphemes(true).count() as u64;
} }
self.previous_style = style; self.previous_style = style;
} }

@ -48,6 +48,7 @@ impl RedrawScheduler {
pub fn schedule(&self, new_scheduled: Instant) { pub fn schedule(&self, new_scheduled: Instant) {
trace!("Redraw scheduled for {:?}", new_scheduled); trace!("Redraw scheduled for {:?}", new_scheduled);
let mut scheduled_frame = self.scheduled_frame.lock().unwrap(); let mut scheduled_frame = self.scheduled_frame.lock().unwrap();
if let Some(previous_scheduled) = *scheduled_frame { if let Some(previous_scheduled) = *scheduled_frame {
if new_scheduled < previous_scheduled { if new_scheduled < previous_scheduled {
*scheduled_frame = Some(new_scheduled); *scheduled_frame = Some(new_scheduled);
@ -60,18 +61,21 @@ impl RedrawScheduler {
pub fn queue_next_frame(&self) { pub fn queue_next_frame(&self) {
trace!("Next frame queued"); trace!("Next frame queued");
let buffer_frames = SETTINGS.get::<RedrawSettings>().extra_buffer_frames; let buffer_frames = SETTINGS.get::<RedrawSettings>().extra_buffer_frames;
self.frames_queued self.frames_queued
.store(buffer_frames as u16, Ordering::Relaxed); .store(buffer_frames as u16, Ordering::Relaxed);
} }
pub fn should_draw(&self) -> bool { pub fn should_draw(&self) -> bool {
let frames_queued = self.frames_queued.load(Ordering::Relaxed); let frames_queued = self.frames_queued.load(Ordering::Relaxed);
if frames_queued > 0 { if frames_queued > 0 {
self.frames_queued self.frames_queued
.store(frames_queued - 1, Ordering::Relaxed); .store(frames_queued - 1, Ordering::Relaxed);
true true
} else { } else {
let mut next_scheduled_frame = self.scheduled_frame.lock().unwrap(); let mut next_scheduled_frame = self.scheduled_frame.lock().unwrap();
if let Some(scheduled_frame) = *next_scheduled_frame { if let Some(scheduled_frame) = *next_scheduled_frame {
if scheduled_frame < Instant::now() { if scheduled_frame < Instant::now() {
*next_scheduled_frame = None; *next_scheduled_frame = None;

@ -134,12 +134,14 @@ impl CursorVfx for PointHighlight {
if self.t == 1.0 { if self.t == 1.0 {
return; return;
} }
let mut paint = Paint::new(skulpin::skia_safe::colors::WHITE, None); let mut paint = Paint::new(skulpin::skia_safe::colors::WHITE, None);
paint.set_blend_mode(BlendMode::SrcOver); paint.set_blend_mode(BlendMode::SrcOver);
let base_color: Color = cursor.background(&colors).to_color(); let base_color: Color = cursor.background(&colors).to_color();
let alpha = ease(ease_in_quad, settings.vfx_opacity, 0.0, self.t) as u8; let alpha = ease(ease_in_quad, settings.vfx_opacity, 0.0, self.t) as u8;
let color = Color::from_argb(alpha, base_color.r(), base_color.g(), base_color.b()); let color = Color::from_argb(alpha, base_color.r(), base_color.g(), base_color.b());
paint.set_color(color); paint.set_color(color);
let size = 3.0 * font_size.1; let size = 3.0 * font_size.1;

@ -215,6 +215,7 @@ impl CursorRenderer {
.enumerate() .enumerate()
.map(|(i, corner)| { .map(|(i, corner)| {
let (x, y) = STANDARD_CORNERS[i]; let (x, y) = STANDARD_CORNERS[i];
Corner { Corner {
relative_position: match cursor_shape { relative_position: match cursor_shape {
CursorShape::Block => (x, y).into(), CursorShape::Block => (x, y).into(),
@ -261,8 +262,10 @@ impl CursorRenderer {
let editor = EDITOR.lock(); let editor = EDITOR.lock();
let (_, grid_y) = cursor.position; let (_, grid_y) = cursor.position;
let (_, previous_y) = self.previous_position; let (_, previous_y) = self.previous_position;
if grid_y == editor.grid.height - 1 && previous_y != grid_y { if grid_y == editor.grid.height - 1 && previous_y != grid_y {
self.command_line_delay += 1; 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
} else { } else {
@ -342,23 +345,29 @@ impl CursorRenderer {
// The cursor is made up of four points, so I create a path with each of the four // The cursor is made up of four points, so I create a path with each of the four
// corners. // corners.
let mut path = Path::new(); let mut path = Path::new();
path.move_to(self.corners[0].current_position); path.move_to(self.corners[0].current_position);
path.line_to(self.corners[1].current_position); path.line_to(self.corners[1].current_position);
path.line_to(self.corners[2].current_position); path.line_to(self.corners[2].current_position);
path.line_to(self.corners[3].current_position); path.line_to(self.corners[3].current_position);
path.close(); path.close();
canvas.draw_path(&path, &paint); canvas.draw_path(&path, &paint);
// Draw foreground // Draw foreground
paint.set_color(cursor.foreground(&default_colors).to_color()); paint.set_color(cursor.foreground(&default_colors).to_color());
canvas.save(); canvas.save();
canvas.clip_path(&path, None, Some(false)); canvas.clip_path(&path, None, Some(false));
let blobs = &shaper.shape_cached(&character, false, false); let blobs = &shaper.shape_cached(&character, false, false);
for blob in blobs.iter() { for blob in blobs.iter() {
canvas.draw_text_blob(&blob, destination, &paint); canvas.draw_text_blob(&blob, destination, &paint);
} }
canvas.restore(); canvas.restore();
if let Some(vfx) = self.cursor_vfx.as_ref() { if let Some(vfx) = self.cursor_vfx.as_ref() {
vfx.render( vfx.render(
&settings, &settings,

@ -215,6 +215,7 @@ impl Renderer {
&default_style, &default_style,
); );
} }
for command in draw_commands.iter() { for command in draw_commands.iter() {
self.draw_foreground( self.draw_foreground(
&mut canvas, &mut canvas,
@ -234,10 +235,10 @@ impl Renderer {
window_size.width as f32, window_size.width as f32,
window_size.height as f32, window_size.height as f32,
); );
gpu_canvas.draw_image_rect(image, None, &image_destination, &self.paint); gpu_canvas.draw_image_rect(image, None, &image_destination, &self.paint);
self.surface = Some(surface); self.surface = Some(surface);
self.cursor_renderer.draw( self.cursor_renderer.draw(
cursor, cursor,
&default_style.colors, &default_style.colors,

@ -206,6 +206,7 @@ impl Settings {
pub async fn read_initial_values(&self, nvim: &Neovim<Compat<ChildStdin>>) { pub async fn read_initial_values(&self, nvim: &Neovim<Compat<ChildStdin>>) {
let keys: Vec<String> = self.listeners.read().keys().cloned().collect(); let keys: Vec<String> = self.listeners.read().keys().cloned().collect();
for name in keys { for name in keys {
let variable_name = format!("neovide_{}", name.to_string()); let variable_name = format!("neovide_{}", name.to_string());
match nvim.get_var(&variable_name).await { match nvim.get_var(&variable_name).await {
@ -223,6 +224,7 @@ impl Settings {
pub async fn setup_changed_listeners(&self, nvim: &Neovim<Compat<ChildStdin>>) { pub async fn setup_changed_listeners(&self, nvim: &Neovim<Compat<ChildStdin>>) {
let keys: Vec<String> = self.listeners.read().keys().cloned().collect(); let keys: Vec<String> = self.listeners.read().keys().cloned().collect();
for name in keys { for name in keys {
let vimscript = format!( let vimscript = format!(
concat!( concat!(

@ -97,6 +97,7 @@ pub fn window_geometry() -> Result<(u64, u64), String> {
.map_err(|msg| msg.to_owned()) .map_err(|msg| msg.to_owned())
}) })
} }
pub fn window_geometry_or_default() -> (u64, u64) { pub fn window_geometry_or_default() -> (u64, u64) {
window_geometry().unwrap_or(INITIAL_DIMENSIONS) window_geometry().unwrap_or(INITIAL_DIMENSIONS)
} }
@ -218,11 +219,13 @@ impl WindowWrapper {
} }
} }
} }
self.fullscreen = !self.fullscreen; self.fullscreen = !self.fullscreen;
} }
pub fn synchronize_settings(&mut self) { pub fn synchronize_settings(&mut self) {
let editor_title = { EDITOR.lock().title.clone() }; let editor_title = { EDITOR.lock().title.clone() };
if self.title != editor_title { if self.title != editor_title {
self.title = editor_title; self.title = editor_title;
self.window self.window
@ -231,6 +234,7 @@ impl WindowWrapper {
} }
let transparency = { SETTINGS.get::<WindowSettings>().transparency }; let transparency = { SETTINGS.get::<WindowSettings>().transparency };
if let Ok(opacity) = self.window.opacity() { if let Ok(opacity) = self.window.opacity() {
if opacity != transparency { if opacity != transparency {
self.window.set_opacity(transparency).ok(); self.window.set_opacity(transparency).ok();
@ -239,6 +243,7 @@ impl WindowWrapper {
} }
let fullscreen = { SETTINGS.get::<WindowSettings>().fullscreen }; let fullscreen = { SETTINGS.get::<WindowSettings>().fullscreen };
if self.fullscreen != fullscreen { if self.fullscreen != fullscreen {
self.toggle_fullscreen(); self.toggle_fullscreen();
} }
@ -268,6 +273,7 @@ impl WindowWrapper {
pub fn handle_pointer_motion(&mut self, x: i32, y: i32) { pub fn handle_pointer_motion(&mut self, x: i32, y: i32) {
let previous_position = self.mouse_position; let previous_position = self.mouse_position;
if let Ok(new_mouse_position) = LogicalSize::from_physical_size_tuple( if let Ok(new_mouse_position) = LogicalSize::from_physical_size_tuple(
( (
(x as f32 / self.renderer.font_width) as u32, (x as f32 / self.renderer.font_width) as u32,
@ -276,6 +282,7 @@ impl WindowWrapper {
&self.window, &self.window,
) { ) {
self.mouse_position = new_mouse_position; self.mouse_position = new_mouse_position;
if self.mouse_down && previous_position != self.mouse_position { if self.mouse_down && previous_position != self.mouse_position {
BRIDGE.queue_command(UiCommand::Drag( BRIDGE.queue_command(UiCommand::Drag(
self.mouse_position.width, self.mouse_position.width,
@ -357,6 +364,7 @@ impl WindowWrapper {
if let Ok(new_dpis) = dpis(&self.window) { if let Ok(new_dpis) = dpis(&self.window) {
if self.previous_dpis != new_dpis { if self.previous_dpis != new_dpis {
let physical_size = PhysicalSize::new(&self.window); let physical_size = PhysicalSize::new(&self.window);
self.window self.window
.set_size( .set_size(
(physical_size.width as f32 * new_dpis.0 / self.previous_dpis.0) as u32, (physical_size.width as f32 * new_dpis.0 / self.previous_dpis.0) as u32,
@ -368,9 +376,12 @@ impl WindowWrapper {
} }
debug!("Render Triggered"); debug!("Render Triggered");
let current_size = self.previous_size; let current_size = self.previous_size;
if REDRAW_SCHEDULER.should_draw() || SETTINGS.get::<WindowSettings>().no_idle { if REDRAW_SCHEDULER.should_draw() || SETTINGS.get::<WindowSettings>().no_idle {
let renderer = &mut self.renderer; let renderer = &mut self.renderer;
if self if self
.skulpin_renderer .skulpin_renderer
.draw(&self.window, |canvas, coordinate_system_helper| { .draw(&self.window, |canvas, coordinate_system_helper| {
@ -386,6 +397,7 @@ impl WindowWrapper {
return false; return false;
} }
} }
return true; return true;
} }
} }
@ -424,6 +436,7 @@ pub fn ui_loop() {
.context .context
.event_pump() .event_pump()
.expect("Could not create sdl event pump"); .expect("Could not create sdl event pump");
loop { loop {
let frame_start = Instant::now(); let frame_start = Instant::now();

Loading…
Cancel
Save