Re: [code] [Textadept] menu suggestion

From: Mitchell <m.att.foicica.com>
Date: Thu, 12 Jan 2017 22:14:06 -0500 (EST)

Hi Gabriel,

On Thu, 12 Jan 2017, Gabriel Dubatti wrote:

> El 06/01/2017 a las 10:49, Mitchell escribió:
>> Hi Gabriel,
>>
>> On Thu, 5 Jan 2017, Gabriel Dubatti wrote:
>>
>>> Hi Mitchell,
>>>
>>> I tried to replace the menu module with my own version in
>>> ~/modules/textadept/menu.lua
>>> and found that this module is tightly coupled with the keys module, so
>>> this module should also be replaced if you want to roll your own menu.
>>>
>>> I'm referring to code like this:
>>>
>>> menu.lua:
>>> {_L['Select to _Matching Brace'], function()
>>> textadept.editing.match_brace('select') end},
>>>
>>> keys.lua:
>>> local m_sel = m_edit[_L['_Select']]
>>> keys[GUI and 'cM' or 'mM'] = m_sel[_L['Select to _Matching
>>> Brace']][2]
>>>
>>> Using their own functions, like in:
>>> {_L['_Highlight Word'], textadept.editing.highlight_word},
>>> keys[not OSX and 'caH' or 'mH'] = textadept.editing.highlight_word
>>>
>>> Is much cleaner, decoupled and easy to call this commands from scripts
>>> (after all, they have a menu and an accelerator, so they are really useful
>>> commands).
>>>
>>> There are near 70 functions in this situation....
>>>
>>> Just my two cents.
>>
>> Yes, if you want to totally replace the menu and have your keybindings
>> accurately reflected in the menu accelerators, you'll have to update some
>> of your keybindings to reference the same functions that the menus do
>> (anonymous functions in particular). Note that the menu accelerators are
>> for informative purposes only -- even if there is no accelerator shown, a
>> keybinding will still work.
>>
>> Cheers,
>> Mitchell
>
> Hi Mitchell,
>
> I finally replaced menu.lua and keys.lua locally adding what I call "actions"
> (commands that can be run from menues and/or buttons).
>
> [snip]

Wow, you've put a lot of work into this. I'm glad it works for you. Thanks
for sharing!

Cheers,
Mitchell

-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Thu 12 Jan 2017 - 22:14:06 EST

This archive was generated by hypermail 2.2.0 : Fri 13 Jan 2017 - 06:41:43 EST