diff options
author | SwissalpS <Luke@SwissalpS.ws> | 2020-06-28 16:34:59 +0200 |
---|---|---|
committer | SwissalpS <Luke@SwissalpS.ws> | 2020-06-28 16:34:59 +0200 |
commit | 13f78570ff15f5516e049cd838d8b01081dd7cdd (patch) | |
tree | cc7637b260985cb2a7232ad173e4fea716b792f6 | |
parent | 2c60383840f23335b9bc2c91351aeb532389719b (diff) | |
download | lite-xl-plugins-13f78570ff15f5516e049cd838d8b01081dd7cdd.tar.gz lite-xl-plugins-13f78570ff15f5516e049cd838d8b01081dd7cdd.zip |
add scalestatus
-rw-r--r-- | README.md | 1 | ||||
-rw-r--r-- | plugins/scalestatus.lua | 39 |
2 files changed, 40 insertions, 0 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/scalestatus.lua b/plugins/scalestatus.lua new file mode 100644 index 0000000..24f3956 --- /dev/null +++ b/plugins/scalestatus.lua @@ -0,0 +1,39 @@ +--[[ + scalestatus.lua + displays current scale (zoom) in status view + version: 20200628_155804 + originally by SwissalpS + + Depends on plugin scale.lua version >= 20200628_154010 +--]] +local core = require "core" +local scale = require "plugins.scale" +core.log_quiet(type(scale.get_scale)) +-- make sure plugin is installed and has get_scale field +if not scale.get_scale then 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 + |