menu.lua

From: Robert <ro....at.web.de>
Date: Thu, 11 Nov 2010 12:34:50 +0100

Hi,

I modified menu.lua [1] to automatically create the id numbers that
connect menu entries with their actions. This makes it easier to write
the menus as only one table is necessary instead of three (for menu
entries, ids, and actions) and some dynamic menu changes simpler like
Frank's patch to show open buffers in the context menu.
There is a menubar table in menu.lua that consists of tables for each dropdown.
menubar = {
  {
    title = L('_File'),
    { L('gtk-new'), { new_buffer } },
  }
 -- ...
}
The create_menubar function creates numerical ids and connects them
with the action for each menu entry and turns them into
gtkmenus.
By changing the menubar table and recreating the gtkmenus by calling
create_menubar again the menu can be changed.
Some examples that could be placed in init.lua [1]: toggle the menu
bar visibility with alt+f10, change menu contents, dynamic context
menu, and a Language specific menu, that is only visible when e.g.
editing Lua files.
I've been using this for a few days but I don't know if there might be
problems with this approach so if anyone wants to try this out, put
menu.lua in your ~/.textadept/modules/textadept/ and the examples in
your init.lua.

Robert

[1] https://gist.github.com/672362
Received on Thu 11 Nov 2010 - 06:34:50 EST

This archive was generated by hypermail 2.2.0 : Thu 08 Mar 2012 - 11:53:26 EST