From 0cb594aaf2d710c71a6b71195b4b9b4be127d88c Mon Sep 17 00:00:00 2001 From: daubaris Date: Sat, 6 Mar 2021 12:03:12 +0200 Subject: [PATCH] Enable customizing cursor speed (#80) Addresses issue #65 --- data/core/config.lua | 1 + data/core/docview.lua | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/data/core/config.lua b/data/core/config.lua index 7e1ab277..bfe4fb76 100644 --- a/data/core/config.lua +++ b/data/core/config.lua @@ -19,6 +19,7 @@ config.line_limit = 80 config.max_symbols = 4000 config.max_project_files = 2000 config.transitions = true +config.blink_period = 0.8 -- Disable plugin loading setting to false the config entry -- of the same name. diff --git a/data/core/docview.lua b/data/core/docview.lua index d60f07c1..57383da7 100644 --- a/data/core/docview.lua +++ b/data/core/docview.lua @@ -47,8 +47,6 @@ DocView.translate = { end, } -local blink_period = 0.8 - function DocView:new(doc) DocView.super.new(self) @@ -290,9 +288,9 @@ function DocView:update() -- update blink timer if self == core.active_view and not self.mouse_selecting then - local n = blink_period / 2 + local n = config.blink_period / 2 local prev = self.blink_timer - self.blink_timer = (self.blink_timer + 1 / config.fps) % blink_period + self.blink_timer = (self.blink_timer + 1 / config.fps) % config.blink_period if (self.blink_timer > n) ~= (prev > n) then core.redraw = true end @@ -344,7 +342,7 @@ function DocView:draw_line_body(idx, x, y) -- draw caret if it overlaps this line if line == idx and core.active_view == self - and self.blink_timer < blink_period / 2 + and self.blink_timer < config.blink_period / 2 and system.window_has_focus() then local lh = self:get_line_height() local x1 = x + self:get_col_x_offset(line, col)