From ff764eed4ca67cff8016d971f07de696cfbc3ff4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Wed, 30 Sep 2026 13:12:14 +0200 Subject: support feature detection for vis ui styling API In builds of vis packaged without a git tree (such as openSUSE OBS RPM builds), vis.API defaults to 0. Checking `vis.API > 3215` therefore fails even when the new vis.ui styling API is present. Check for the existence of `vis.ui.style_define` and `vis.ui.style_push` directly, and accept an optional window object in util.style_define for backward compatibility with older versions. --- util.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'util.lua') diff --git a/util.lua b/util.lua index c4894c8..7b57231 100644 --- a/util.lua +++ b/util.lua @@ -412,11 +412,13 @@ end --- Wrapper to define a style in vis. -- @param id The style id -- @param style The style description -function util.style_define(id, style) - if vis.API and vis.API > 3215 then +-- @param win The optional window object for older vis versions +function util.style_define(id, style, win) + if (vis.API and vis.API > 3215) or (vis.ui and vis.ui.style_define) then return vis.ui:style_define(id, style) else - return vis.win:style_define(id, style) + local w = win or vis.win + return w and w:style_define(id, style) end end -- cgit v1.2.3