aboutsummaryrefslogtreecommitdiff
path: root/plugins/scale.lua
diff options
context:
space:
mode:
authorTakase <20792268+takase1121@users.noreply.github.com>2021-05-31 11:18:12 +0800
committerGitHub <noreply@github.com>2021-05-31 11:18:12 +0800
commit0d87d70140b8c318ca171330658d3a7cf00f5037 (patch)
treeeb333ce5d63f7f393b61ac544124be5398496d3a /plugins/scale.lua
parenta07e30be3827f9444f967ba633171ea8c90cd41e (diff)
parent5b9a3bd28d937d131da5821f075952df80c14040 (diff)
downloadlite-xl-plugins-0d87d70140b8c318ca171330658d3a7cf00f5037.tar.gz
lite-xl-plugins-0d87d70140b8c318ca171330658d3a7cf00f5037.zip
Merge branch 'master' into contextmenu
Diffstat (limited to 'plugins/scale.lua')
-rw-r--r--plugins/scale.lua32
1 files changed, 25 insertions, 7 deletions
diff --git a/plugins/scale.lua b/plugins/scale.lua
index 5dfa699..78dc9e2 100644
--- a/plugins/scale.lua
+++ b/plugins/scale.lua
@@ -1,3 +1,4 @@
+-- mod-version:1 -- lite-xl 1.16
local core = require "core"
local common = require "core.common"
local command = require "core.command"
@@ -10,13 +11,15 @@ 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
-font_cache[style.font] = { EXEDIR .. "/data/fonts/font.ttf", 14 * SCALE }
-font_cache[style.big_font] = { EXEDIR .. "/data/fonts/font.ttf", 34 * SCALE }
-font_cache[style.icon_font] = { EXEDIR .. "/data/fonts/icons.ttf", 14 * SCALE }
-font_cache[style.code_font] = { EXEDIR .. "/data/fonts/monospace.ttf", 13.5 * SCALE }
+font_cache[style.font] = { DATADIR .. "/fonts/font.ttf", 14 * SCALE }
+font_cache[style.big_font] = { DATADIR .. "/fonts/font.ttf", 34 * SCALE }
+font_cache[style.icon_font] = { DATADIR .. "/fonts/icons.ttf", 14 * SCALE }
+font_cache[style.code_font] = { DATADIR .. "/fonts/monospace.ttf", 13.5 * SCALE }
local load_font = renderer.font.load
@@ -93,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 {