diff options
author | rxi <rxi@users.noreply.github.com> | 2020-07-01 09:45:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-01 09:45:19 +0100 |
commit | 7ba4b669a50fb8ac1aac73e7eea7b77f8d241626 (patch) | |
tree | 5fcd180ebda0b812f2763a60fa2c8c0bab88a620 /plugins | |
parent | da0b5f306ccf4f9e1f0f38c6841fcbaad97c76bc (diff) | |
parent | 947f5f96a02ba2c85b09d4176e618589ba1637ad (diff) | |
download | lite-xl-plugins-7ba4b669a50fb8ac1aac73e7eea7b77f8d241626.tar.gz lite-xl-plugins-7ba4b669a50fb8ac1aac73e7eea7b77f8d241626.zip |
Merge pull request #71 from SwissalpS/proposeScaleStatus
Propose scale status
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/scale.lua | 13 | ||||
-rw-r--r-- | plugins/scalestatus.lua | 41 |
2 files changed, 53 insertions, 1 deletions
diff --git a/plugins/scale.lua b/plugins/scale.lua index 95c4009..d3e10e8 100644 --- a/plugins/scale.lua +++ b/plugins/scale.lua @@ -1,3 +1,9 @@ +--[[ + scale.lua + provides support for dynamically adjusting the scale of the code font / UI + version: 20200628_154010 + originally by 6r1d +--]] local core = require "core" local common = require "core.common" local command = require "core.command" @@ -35,6 +41,10 @@ end local current_scale = SCALE local default = current_scale + +local function get_scale() return current_scale end + + local function set_scale(scale) scale = common.clamp(scale, 0.2, 6) @@ -86,4 +96,5 @@ keymap.add { ["ctrl+="] = "scale:increase", } -return { set_scale = set_scale } +return { get_scale = get_scale, set_scale = set_scale } + diff --git a/plugins/scalestatus.lua b/plugins/scalestatus.lua new file mode 100644 index 0000000..03216b5 --- /dev/null +++ b/plugins/scalestatus.lua @@ -0,0 +1,41 @@ +--[[ + scalestatus.lua + displays current scale (zoom) in status view + version: 20200628_155804 + originally by SwissalpS + + Depends on plugin scale.lua version >= 20200628_154010 +--]] +local scale = require "plugins.scale" +-- make sure plugin is installed and has get_scale field +if not scale.get_scale then + local core = require "core" + core.error("Plugin 'scale' needs to be updated, scalestatus inactive.") + return false +end + +local config = require "core.config" +local StatusView = require "core.statusview" + +config.scalestatus_format = '%.0f%%' + +local get_items = StatusView.get_items +function StatusView:get_items() + + local left, right = get_items(self) + + local t = { + self.separator, + string.format(config.scalestatus_format, scale.get_scale() * 100), + } + + for _, item in ipairs(t) do + table.insert(right, item) + end + + return left, right + +end + +return true + |