diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-07-25 20:27:44 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-07-25 20:28:05 +0530 |
| commit | 81dcf7de91c1866d565f7aa9eb38f7fbd1cd7ad7 (patch) | |
| tree | aa24bcea93d19ce6298ad6aed499d324fac2ceae /lua | |
| parent | 2c7d36b4aa53ffa638a7aa7046767f10e7a152bf (diff) | |
| download | null-browser-81dcf7de91c1866d565f7aa9eb38f7fbd1cd7ad7.tar.gz null-browser-81dcf7de91c1866d565f7aa9eb38f7fbd1cd7ad7.zip | |
Add decoration is_enabled api + allowed specifying win_id for enabled
Diffstat (limited to '')
| -rw-r--r-- | lua/null-browser/api.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lua/null-browser/api.lua b/lua/null-browser/api.lua index e1053b8..f12d127 100644 --- a/lua/null-browser/api.lua +++ b/lua/null-browser/api.lua @@ -281,13 +281,29 @@ function web.view.scroll_to_bottom(view_id) return __internals.view_scroll_to_bo --- Decoration api --- +--- @class DecorationOpts +--- @field win? number +--- +--- @class Decoration +--- @field enable fun(opts?: DecorationOpts): nil +--- @field disable fun(opts?: DecorationOpts): nil +--- @field set_enabled fun(enabled: boolean, opts?: DecorationOpts): nil +--- @field is_enabled fun(opts?: DecorationOpts): boolean +--- --- @alias DecorationType number --- --- @param type DecorationType +--- @return Decoration local function create_decoration_api(type) + local set_enabled = function(enabled, opts) + __internals.decorations_set_enabled(type, enabled, (opts or {}).win) + end; return { - enable = function() __internals.decorations_set_enabled(type, true) end, - disable = function() __internals.decorations_set_enabled(type, false) end, + enable = function(opts) set_enabled(true, opts) end, + disable = function(opts) set_enabled(false, opts) end, + is_enabled = function(opts) + return __internals.decorations_get_enabled(type, (opts or {}).win) + end, } end |
