xiota / geanylua-scripts

GeanyLua scripts to add some minor features to Geany. Hide the menubar. Show multiple long-line column markers.
GNU General Public License v2.0
2 stars 0 forks source link

TUTORIAL: auto-sidebar small version, so if switch-views are not used #12

Closed ralf3u closed 4 months ago

ralf3u commented 4 months ago

At the moment there is a big version of auto-sidebar at https://github.com/xiota/geanylua-scripts, in case also switch-views are used.

When switch-views didn't exist, there was only a small version of auto-sidebar. Maybe someone is not interested in switch-views, so the small version of auto-sidebar could be interesting.

In the next comment is the small version of auto-sidebar that existed in the past at https://github.com/xiota/geanylua-scripts.

ralf3u commented 4 months ago

In .config/geany/plugins/geanylua/: Create the folder with this name: events In .config/geany/plugins/geanylua/: Create the document with this name: auto-sidebar.lua The content of auto-sidebar.lua:

--[[
  Show/Hide sidebar based on file types in action_tbl
--]]

function hide_sidebar()
    geany.signal("notebook3", "hide")
  update()
end

function show_sidebar()
    geany.signal("notebook3", "show")
  update()
end

function update()
  geany.signal("notebook1", "style-updated")
end

-- ----------

local action_tbl =
{
  ["HTML"] = show_sidebar,
  ["Markdown"] = show_sidebar,
    ["Fountain"] = show_sidebar,
 }

infotable = geany.fileinfo()

local func = action_tbl[infotable["type"]]
if (func) then
  func()
else
  hide_sidebar()
end

-- uncomment the following line to show the filetype in the status window
-- geany.status(infotable["type"])

In .config/geany/plugins/geanylua/events/: Create the document with this name: activated.lua The content of activated.lua:

local lua_path = geany.appinfo().scriptdir..geany.dirsep

auto_sidebar = loadfile(lua_path.."auto-sidebar.lua")
auto_sidebar()
ralf3u commented 4 months ago

The auto-sidebar small version works also in combination with toggle-menu-bar.

ralf3u commented 4 months ago

@xiota An alternative to this issue is to publish also the old version of auto-sidebar, so auto-sidebar (small version) at https://github.com/xiota/geanylua-scripts and to delete this issue.