diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | plugins/scale.lua | 43 |
2 files changed, 26 insertions, 19 deletions
@@ -57,7 +57,7 @@ Plugin | Description [`motiontrail`](plugins/motiontrail.lua?raw=1) | Adds a motion-trail to the caret *([screenshot](https://user-images.githubusercontent.com/3920290/83256814-085ccb00-a1ab-11ea-9e35-e6633cbed1a9.gif))* [`openfilelocation`](plugins/openfilelocation.lua?raw=1) | Opens the parent directory of the current file in the file manager [`openselected`](plugins/openselected.lua?raw=1) | Opens the selected filename or url -[`scale`](plugins/scale.lua?raw=1) | Provides support for dynamically adjusting the scale of the UI (`ctrl+-`, `ctrl+=`) +[`scale`](plugins/scale.lua?raw=1) | Provides support for dynamically adjusting the scale of the code font / UI (`ctrl+-`, `ctrl+=`) [`selectionhighlight`](plugins/selectionhighlight.lua?raw=1) | Highlights regions of code that match the current selection *([screenshot](https://user-images.githubusercontent.com/3920290/80710883-5f597c80-8ae7-11ea-97f0-76dfacc08439.png))* [`sort`](plugins/sort.lua?raw=1) | Sorts selected lines alphabetically [`spellcheck`](plugins/spellcheck.lua?raw=1) | Underlines misspelt words *([screenshot](https://user-images.githubusercontent.com/3920290/79923973-9caa7400-842e-11ea-85d4-7a196a91ca50.png))* *— note: on Windows a [`words.txt`](https://github.com/dwyl/english-words/blob/master/words.txt) dictionary file must be placed beside the exe* diff --git a/plugins/scale.lua b/plugins/scale.lua index 4fd82cc..6b3444a 100644 --- a/plugins/scale.lua +++ b/plugins/scale.lua @@ -1,8 +1,10 @@ local core = require "core" local command = require "core.command" +local config = require "core.config" local keymap = require "core.keymap" local style = require "core.style" +config.scale_mode = "code" local font_cache = setmetatable({}, { __mode = "k" }) @@ -27,32 +29,37 @@ local function scale_font(font, s) end +local current_scale = SCALE +local default = current_scale + local function set_scale(scale) - local s = scale / SCALE - - style.padding.x = style.padding.x * s - style.padding.y = style.padding.y * s - style.divider_size = style.divider_size * s - style.scrollbar_size = style.scrollbar_size * s - style.caret_width = style.caret_width * s - style.tab_width = style.tab_width * s - - style.font = scale_font(style.font, s) - style.big_font = scale_font(style.big_font, s) - style.icon_font = scale_font(style.icon_font, s) + local s = scale / current_scale + + if config.scale_mode == "ui" then + style.padding.x = style.padding.x * s + style.padding.y = style.padding.y * s + style.divider_size = style.divider_size * s + style.scrollbar_size = style.scrollbar_size * s + style.caret_width = style.caret_width * s + style.tab_width = style.tab_width * s + + style.big_font = scale_font(style.big_font, s) + style.icon_font = scale_font(style.icon_font, s) + style.font = scale_font(style.font, s) + SCALE = current_scale + end + style.code_font = scale_font(style.code_font, s) - SCALE = scale + current_scale = scale core.redraw = true end -local default = SCALE - command.add(nil, { - ["scale:reset" ] = function() set_scale(default) end, - ["scale:decrease"] = function() set_scale(SCALE * 0.9) end, - ["scale:increase"] = function() set_scale(SCALE * 1.1) end, + ["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, }) keymap.add { |