From 180b3ebad146e819fecc392e8b322820bc2e15e6 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Fri, 15 Apr 2016 20:59:38 -0400 Subject: Allow `textadept.menu.menubar = nil`; modules/textadept/menu.lua This will hide the menubar, but allow `textadept.menu.select_command()` to keep functioning. --- modules/textadept/menu.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/textadept/menu.lua b/modules/textadept/menu.lua index acec62b3..13d42b83 100644 --- a/modules/textadept/menu.lua +++ b/modules/textadept/menu.lua @@ -456,11 +456,14 @@ end -- to call or a table containing a function with its parameters to call when an -- item is clicked. Menu items may also be sub-menus, ordered lists of menu -- items with an additional `title` key for the sub-menu's title text. --- @param menubar The table of menu tables to create the menubar from. +-- @param menubar The table of menu tables to create the menubar from. If `nil`, +-- clears the menubar from view, but keeps it intact in order for +-- `M.select_command()` to function properly. -- @see ui.menubar -- @see ui.menu local function set_menubar(menubar) - key_shortcuts, menu_actions = {}, {} + if not menubar then ui.menubar = {} return end + key_shortcuts, menu_actions = {}, {} -- reset for key, f in pairs(keys) do key_shortcuts[get_id(f)] = key end local _menubar = {} for i = 1, #menubar do @@ -486,7 +489,7 @@ events.connect(events.INITIALIZED, function() set_menubar(default_menubar) end) -- @see ui.tab_context_menu -- @see ui.menu local function set_contextmenus(buffer_menu, tab_menu) - contextmenu_actions = {} + contextmenu_actions = {} -- reset local menu = buffer_menu or default_context_menu ui.context_menu = ui.menu(read_menu_table(menu, true)) proxies.context_menu = proxy_menu(menu, set_contextmenus) -- cgit v1.2.3