diff options
author | jgmdev <jgmdev@gmail.com> | 2022-11-15 17:12:47 -0400 |
---|---|---|
committer | jgmdev <jgmdev@gmail.com> | 2022-11-15 17:12:47 -0400 |
commit | 20cd0e16d2b37586e4946e066cc5b604d3ec4035 (patch) | |
tree | c28a908f71e2d4c6de3509441d5906df5b3daa0d /plugins | |
parent | f3683031fbf4e249f8848490e6ffc5fa209a3aad (diff) | |
download | lite-xl-plugins-20cd0e16d2b37586e4946e066cc5b604d3ec4035.tar.gz lite-xl-plugins-20cd0e16d2b37586e4946e066cc5b604d3ec4035.zip |
settings: apply force_scrollbar_status on the fly
Also added additional flag to support applying the status bar force
state globally and not only to document views.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/settings.lua | 63 |
1 files changed, 51 insertions, 12 deletions
diff --git a/plugins/settings.lua b/plugins/settings.lua index 9c7cd31..89796b1 100644 --- a/plugins/settings.lua +++ b/plugins/settings.lua @@ -5,6 +5,7 @@ local common = require "core.common" local command = require "core.command" local keymap = require "core.keymap" local style = require "core.style" +local DocView = require "core.docview" -- check if widget is installed before proceeding local widget_found, Widget = pcall(require, "widget") @@ -395,6 +396,56 @@ settings.add("User Interface", end }, { + label = "Force Scrollbar Status", + description = "Choose a fixed scrollbar state instead of resizing it on mouse hover.", + path = "force_scrollbar_status", + type = settings.type.SELECTION, + default = false, + values = { + {"Disabled", false}, + {"Expanded", "expanded"}, + {"Contracted", "contracted"} + }, + on_apply = function(value) + local mode = config.force_scrollbar_status_mode or "global" + local globally = mode == "global" + local views = core.root_view.root_node:get_children() + for _, view in ipairs(views) do + if globally or view:extends(DocView) then + view.h_scrollbar:set_forced_status(value) + view.v_scrollbar:set_forced_status(value) + else + view.h_scrollbar:set_forced_status(false) + view.v_scrollbar:set_forced_status(false) + end + end + end + }, + { + label = "Force Scrollbar Status Mode", + description = "Choose between applying globally or document views only.", + path = "force_scrollbar_status_mode", + type = settings.type.SELECTION, + default = "global", + values = { + {"Documents", "docview"}, + {"Globally", "global"} + }, + on_apply = function(value) + local globally = value == "global" + local views = core.root_view.root_node:get_children() + for _, view in ipairs(views) do + if globally or view:extends(DocView) then + view.h_scrollbar:set_forced_status(config.force_scrollbar_status) + view.v_scrollbar:set_forced_status(config.force_scrollbar_status) + else + view.h_scrollbar:set_forced_status(false) + view.v_scrollbar:set_forced_status(false) + end + end + end + }, + { label = "Disable Cursor Blinking", description = "Disables cursor blinking on text input elements.", path = "disable_blink", @@ -542,18 +593,6 @@ settings.add("Editor", path = "scroll_past_end", type = settings.type.TOGGLE, default = true - }, - { - label = "Force Scrollbar Status", - description = "Choose an fixed scrollbar state instead of resizing it on mouse hover.", - path = "force_scrollbar_status", - type = settings.type.SELECTION, - default = false, - values = { - {"Disabled", false}, - {"Expanded", "expanded"}, - {"Contracted", "contracted"} - } } } ) |