better cursor animation speed and clipping text to grid region

macos-click-through
Keith Simmons 5 years ago
parent 38b90136c8
commit cd35e33877

1
.ok

@ -0,0 +1 @@
install: cargo build --release; rm c:/dev/tools/neovide.* -ErrorAction SilentlyContinue; cp ./target/release/neovide.exe c:/dev/tools/neovide.exe

@ -5,7 +5,7 @@ use skulpin::skia_safe::{Canvas, Paint, Path, Point};
use crate::renderer::{CachingShaper, FontLookup};
use crate::editor::{Colors, Cursor, CursorShape, Editor};
const AVERAGE_MOTION_PERCENTAGE: f32 = 0.6;
const AVERAGE_MOTION_PERCENTAGE: f32 = 0.7;
const MOTION_PERCENTAGE_SPREAD: f32 = 0.5;
const DEFAULT_CELL_PERCENTAGE: f32 = 1.0 / 8.0;

@ -116,14 +116,17 @@ impl Renderer {
Renderer { editor, surface, paint, fonts_lookup, shaper, font_width, font_height, cursor_renderer }
}
fn draw_background(&mut self, canvas: &mut Canvas, text: &str, grid_pos: (u64, u64), size: u16, style: &Option<Style>, default_colors: &Colors) {
fn compute_text_region(&self, text: &str, grid_pos: (u64, u64), size: u16) -> Rect {
let (grid_x, grid_y) = grid_pos;
let x = grid_x as f32 * self.font_width;
let y = grid_y as f32 * self.font_height;
let width = text.chars().count() as f32 * self.font_width * size as f32;
let height = self.font_height * size as f32;
let region = Rect::new(x, y, x + width, y + height);
Rect::new(x, y, x + width, y + height)
}
fn draw_background(&mut self, canvas: &mut Canvas, text: &str, grid_pos: (u64, u64), size: u16, style: &Option<Style>, default_colors: &Colors) {
let region = self.compute_text_region(text, grid_pos, size);
let style = style.clone().unwrap_or(Style::new(default_colors.clone()));
self.paint.set_color(style.background(default_colors).to_color());
@ -138,6 +141,12 @@ impl Renderer {
let style = style.clone().unwrap_or(Style::new(default_colors.clone()));
canvas.save();
let region = self.compute_text_region(text, grid_pos, size);
canvas.clip_rect(region, None, Some(false));
if style.underline || style.undercurl {
let (_, metrics) = self.fonts_lookup.size(size).get(&style).metrics();
let line_position = metrics.underline_position().unwrap();
@ -152,6 +161,8 @@ impl Renderer {
let blob = self.shaper.shape_cached(text.to_string(), size, self.fonts_lookup.size(size).get(&style));
canvas.draw_text_blob(blob, (x, y), &self.paint);
}
canvas.restore();
}
pub fn draw(&mut self, gpu_canvas: &mut Canvas, coordinate_system_helper: &CoordinateSystemHelper) -> bool {

Loading…
Cancel
Save