aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--plugins/scale.lua142
-rw-r--r--plugins/scalestatus.lua4
3 files changed, 3 insertions, 145 deletions
diff --git a/README.md b/README.md
index 7fc2d7a..fffecad 100644
--- a/README.md
+++ b/README.md
@@ -110,7 +110,7 @@ Plugin | Description
[`rainbowparen`](plugins/rainbowparen.lua?raw=1) | Show nesting of parentheses with rainbow colours
[`restoretabs`](plugins/restoretabs.lua?raw=1) | Keep a list of recently closed tabs, and restore the tab in order on cntrl+shift+t.
[`regexreplaceplugin`](plugins/regexreplaceplugin.lua?raw=1) | Allows for you to write a regex and its replacement in one go, and live preview the results.
-*[`scale`](plugins/scale.lua?raw=1)* | Provides support for dynamically adjusting the scale of the code font / UI (`ctrl+-`, `ctrl+=`)
+~~`scale`~~ | Integrated in lite-xl with improvements ~~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))*
[`smallclock`](plugins/smallclock.lua?raw=1) | Displays the current time in the corner of the status view
diff --git a/plugins/scale.lua b/plugins/scale.lua
deleted file mode 100644
index 14648fd..0000000
--- a/plugins/scale.lua
+++ /dev/null
@@ -1,142 +0,0 @@
--- mod-version:1 -- lite-xl 1.16
-local core = require "core"
-local common = require "core.common"
-local command = require "core.command"
-local config = require "core.config"
-local keymap = require "core.keymap"
-local style = require "core.style"
-local RootView = require "core.rootview"
-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" })
-
--- default lite fonts
-local regular_font = "font.ttf"
-local monospace_font = "monospace.ttf"
-
--- Set font names properly to work with latest lite-xl changes
-if io.open(DATADIR .. "/fonts/FiraSans-Regular.ttf", "r") then
- regular_font = "FiraSans-Regular.ttf"
-end
-
-if io.open(DATADIR .. "/fonts/JetBrainsMono-Regular.ttf", "r") then
- monospace_font = "JetBrainsMono-Regular.ttf"
-end
-
--- the following should be kept in sync with core.style's default font settings
-font_cache[style.font] = { DATADIR .. "/fonts/" .. regular_font, 13 * SCALE }
-font_cache[style.big_font] = { DATADIR .. "/fonts/" .. regular_font, 40 * SCALE }
-font_cache[style.icon_font] = { DATADIR .. "/fonts/icons.ttf", 14 * SCALE }
-font_cache[style.icon_big_font] = { DATADIR .. "/fonts/icons.ttf", 20 * SCALE }
-font_cache[style.code_font] = { DATADIR .. "/fonts/" .. monospace_font, 13 * SCALE }
-
-
-local load_font = renderer.font.load
-function renderer.font.load(...)
- local res = load_font(...)
- font_cache[res] = { ... }
- return res
-end
-
-
-local function scale_font(font, s)
- local fc = font_cache[font]
- return renderer.font.load(fc[1], fc[2] * s)
-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)
-
- -- save scroll positions
- local scrolls = {}
- for _, view in ipairs(core.root_view.root_node:get_children()) do
- local n = view:get_scrollable_size()
- if n ~= math.huge and not view:is(CommandView) and n > view.size.y then
- scrolls[view] = view.scroll.y / (n - view.size.y)
- end
- end
-
- local s = scale / current_scale
- current_scale = scale
-
- if config.scale_mode == "ui" then
- SCALE = current_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.big_font = scale_font(style.big_font, s)
- style.icon_font = scale_font(style.icon_font, s)
- style.font = scale_font(style.font, s)
- end
-
- style.code_font = scale_font(style.code_font, s)
-
- -- restore scroll positions
- for view, n in pairs(scrolls) do
- view.scroll.y = n * (view:get_scrollable_size() - view.size.y)
- view.scroll.to.y = view.scroll.y
- end
-
- core.redraw = true
-end
-
-
-local on_mouse_wheel = RootView.on_mouse_wheel
-
-function RootView:on_mouse_wheel(d, ...)
- if keymap.modkeys["ctrl"] and config.scale_use_mousewheel then
- if d < 0 then command.perform "scale:decrease" end
- if d > 0 then command.perform "scale:increase" end
- else
- return on_mouse_wheel(self, 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() res_scale() end,
- ["scale:decrease"] = function() dec_scale() end,
- ["scale:increase"] = function() inc_scale() end,
-})
-
-keymap.add {
- ["ctrl+0"] = "scale:reset",
- ["ctrl+-"] = "scale:decrease",
- ["ctrl+="] = "scale:increase",
-}
-
-return { get_scale = get_scale, set_scale = set_scale }
-
diff --git a/plugins/scalestatus.lua b/plugins/scalestatus.lua
index 2981523..e43cdd5 100644
--- a/plugins/scalestatus.lua
+++ b/plugins/scalestatus.lua
@@ -9,7 +9,7 @@
--]]
local scale = require "plugins.scale"
-- make sure plugin is installed and has get_scale field
-if not scale.get_scale then
+if not scale then
local core = require "core"
core.error("Plugin 'scale' needs to be updated, scalestatus inactive.")
return false
@@ -27,7 +27,7 @@ function StatusView:get_items()
local t = {
self.separator,
- string.format(config.scalestatus_format, scale.get_scale() * 100),
+ string.format(config.scalestatus_format, scale.get() * 100),
}
for _, item in ipairs(t) do