diff options
author | Christopher Kleine <chris@suletuxe.de> | 2021-05-19 11:18:06 +0200 |
---|---|---|
committer | Christopher Kleine <chris@suletuxe.de> | 2021-05-19 11:24:17 +0200 |
commit | ae7c2b3a9151ddfbc04d54a2d90de596813d0525 (patch) | |
tree | d2f8b0ae9dcda117adae88c33eda79fd4bac9a6a /plugins | |
parent | ba4d4ffd72a1c65aae4a68403d64997c75e58430 (diff) | |
download | lite-xl-plugins-ae7c2b3a9151ddfbc04d54a2d90de596813d0525.tar.gz lite-xl-plugins-ae7c2b3a9151ddfbc04d54a2d90de596813d0525.zip |
Changed scale behaviour
The scale was behaving weird.
It went from 100 -> 110 -> 121 -> 109 -> 98
One had to use ctrl+0 get it back to 100
This is fixed in this commit.
It uses an indicator to change the scale.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/scale.lua | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/plugins/scale.lua b/plugins/scale.lua index e93c3c0..658cb98 100644 --- a/plugins/scale.lua +++ b/plugins/scale.lua @@ -11,6 +11,8 @@ local CommandView = require "core.commandview" config.scale_mode = "code" config.scale_use_mousewheel = true +local scale_level = 0 +local scale_steps = 0.1 local font_cache = setmetatable({}, { __mode = "k" }) -- the following should be kept in sync with core.style's default font settings @@ -94,11 +96,26 @@ function RootView:on_mouse_wheel(d, ...) end end +local function res_scale() + scale_level = 0 + set_scale(default) +end + +local function inc_scale() + scale_level = scale_level + 1 + set_scale(default + scale_level * scale_steps) +end + +local function dec_scale() + scale_level = scale_level - 1 + set_scale(default + scale_level * scale_steps) +end + command.add(nil, { - ["scale:reset" ] = function() set_scale(default) end, - ["scale:decrease"] = function() set_scale(current_scale * 0.9) end, - ["scale:increase"] = function() set_scale(current_scale * 1.1) end, + ["scale:reset" ] = function() res_scale() end, + ["scale:decrease"] = function() dec_scale() end, + ["scale:increase"] = function() inc_scale() end, }) keymap.add { |