diff options
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | plugins/scale.lua | 13 | ||||
-rw-r--r-- | plugins/scalestatus.lua | 41 |
3 files changed, 54 insertions, 1 deletions
@@ -67,6 +67,7 @@ Plugin | Description [`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 code font / UI (`ctrl+-`, `ctrl+=`) +[`scalestatus`](plugins/scalestatus.lua?raw=1) | Displays current scale (zoom) in status view (depends on scale plugin) [`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 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 + |