I think that a good way to access GeanyLua plug-ins via the keyboard would be to have one main GeanyLua key binding that you could hit to get GeanyLua to listen for the *next* key and then run the appropriate plug-in for you from there. That is, use a "prefix key". For example, you could use the letter 'r' to reach `reverse.lua`, and get to it by hitting a prefix key combo like, say, Ctrl-!. The whole command would then be: Ctrl-! r (hit Ctrl-!, release, then tap 'r').
The main idea is, I'd rather not play games trying to find unused key combos for every Lua plug-in script that I plan on using regularly. And I want to be able to access these regularly-used plug-ins very quickly via the keyboard.
Can I get the main GeanyLua plug-in to respond to one main key combo like that (ex. Ctrl-!)? And, if so, any recommendations on how I could then make it hand-off to the selected Lua script after I hit the next key?
Thanks, ---John
On Jan 17, 2008 11:25 PM, John Gabriele jmg3000@gmail.com wrote:
I think that a good way to access GeanyLua plug-ins via the keyboard would be to have one main GeanyLua key binding that you could hit to get GeanyLua to listen for the *next* key and then run the appropriate plug-in for you from there.
Hello, John -
There is currently no way that I know of to accomplish this. The closest you could come is with the menu accelerators/mnemonics, e.g. if you create the file:
~/.geany/plugins/geanylua/_hello.lua
- then you could type Alt+T,L,H to get to the script.
Of course that's not an ideal solution, since it means either putting lots of files in the top-level script folder, or adding another key into the chain to activate the sub-menu, e.g.
~/.geany/plugins/geanylua/_greetings/_hello.lua
- would require typing Alt+T,L,G,H
( And this also means you have the menus flashing about, which can be distracting. )
But I do think you have a good idea and I will try to look into it. I am guessing this would have to be done at the lower (GDK) rather than the higher (GTK) level, which is something I'm not too familiar with...
- Jeff
On Jan 18, 2008 6:11 AM, Jeff Pohlmeyer yetanothergeek@gmail.com wrote:
On Jan 17, 2008 11:25 PM, John Gabriele jmg3000@gmail.com wrote:
I think that a good way to access GeanyLua plug-ins via the keyboard would be to have one main GeanyLua key binding that you could hit to get GeanyLua to listen for the *next* key and then run the appropriate plug-in for you from there.
[snip]
There is currently no way that I know of to accomplish this. [snip]
But I do think you have a good idea and I will try to look into it. I am guessing this would have to be done at the lower (GDK) rather than the higher (GTK) level, which is something I'm not too familiar with...
Could Geany simply provide a function that users could set a key binding for?
On Fri, 18 Jan 2008 13:03:59 -0500, "John Gabriele" jmg3000@gmail.com wrote:
On Jan 18, 2008 6:11 AM, Jeff Pohlmeyer yetanothergeek@gmail.com wrote:
On Jan 17, 2008 11:25 PM, John Gabriele jmg3000@gmail.com wrote:
I think that a good way to access GeanyLua plug-ins via the keyboard would be to have one main GeanyLua key binding that you could hit to get GeanyLua to listen for the *next* key and then run the appropriate plug-in for you from there.
[snip]
There is currently no way that I know of to accomplish this. [snip]
But I do think you have a good idea and I will try to look into it. I am guessing this would have to be done at the lower (GDK) rather than the higher (GTK) level, which is something I'm not too familiar with...
Could Geany simply provide a function that users could set a key binding for?
Short answer: Yes.
A little better answer: After the next release we will finally add plugin keybinding support, then keybindings can be assigned for plugin actions. But we want to wait until the upcoming release to not put a couple of new, untested and maybe buggy code into. So, as usual, please be patient ;-).
Once it got implemented, the requested feature should be possible.
Regards, Enrico
On Jan 19, 2008 3:49 AM, Enrico Tröger enrico.troeger@uvena.de wrote:
On Fri, 18 Jan 2008 13:03:59 -0500, "John Gabriele" jmg3000@gmail.com wrote:
Could Geany simply provide a function that users could set a key binding for?
Short answer: Yes.
A little better answer: After the next release we will finally add plugin keybinding support, then keybindings can be assigned for plugin actions. But we want to wait until the upcoming release to not put a couple of new, untested and maybe buggy code into. So, as usual, please be patient ;-).
Once it got implemented, the requested feature should be possible.
That'll be great. Thanks.
Jeff wrote:
I added a new keygrab() function to the Lua plugin,
Sounds like we're soon going to have a very fast and easy way to access plug-in scripts written in Lua. :)
---John
On Jan 17, 2008 11:25 PM, John Gabriele jmg3000@gmail.com wrote:
For example, you could use the letter 'r' to reach `reverse.lua`, and get to it by hitting a prefix key combo like, say, Ctrl-!. The whole command would then be: Ctrl-! r (hit Ctrl-!, release, then tap 'r').
I added a new keygrab() function to the Lua plugin, that when called, it intercepts the next keystroke from Geany, and returns it as a string, like "a" or "Escape".
So like in your example above, you will be able to create a script something like:
-- @ACCEL@ <Control>exclam
key = geany.keygrab()
if key=="r" then dofile("reverse.lua") elseif key=="f" then dofile("forward.lua") elseif ... end
The new release should be available in the next couple of days.
(err, I think I told Enrico that two weeks ago! :)
- Jeff
On Jan 19, 2008 11:49 AM, Jeff Pohlmeyer yetanothergeek@gmail.com wrote:
On Jan 17, 2008 11:25 PM, John Gabriele jmg3000@gmail.com wrote:
For example, you could use the letter 'r' to reach `reverse.lua`, and get to it by hitting a prefix key combo like, say, Ctrl-!. The whole command would then be: Ctrl-! r (hit Ctrl-!, release, then tap 'r').
I added a new keygrab() function to the Lua plugin, that when called, it intercepts the next keystroke from Geany, and returns it as a string, like "a" or "Escape".
Sweet! Thanks Jeff. Works nicely for me, though I had to use full paths to name the scripts that get activated (I put some notes on it in the Plug-ins section of my tiny online Geany notes: http://www.milliwatt-software.com/jmg/notes/geany.html ).
---John
On Jan 23, 2008 12:05 AM, John Gabriele jmg3000@gmail.com wrote:
Sweet! Thanks Jeff.
You're welcome!
Works nicely for me, though I had to use full paths to name the scripts that get activated
Yes, that was just a quick-and-dirty example to give a general idea of how it works. Actually, the "if-then-elseif" construct could get rather unwieldy (and ugly) when you start to add a lot of keys. A more elegant solution would be to use a lookup table:
-------------
local keytable = { l = "examples/edit/lua-replace.lua", p = "examples/edit/proper-case.lua", r = "examples/edit/reverse.lua", t = "examples/edit/right-trim.lua", b = "examples/edit/select-block.lua" }
local key = geany.keygrab()
if key then local filename=keytable[key] if filename then dofile(geany.appinfo().scriptdir.."/"..filename) else geany.message("Key value '"..key.."' not assigned.") end end
-------------
(I put some notes on it in the Plug-ins section of my tiny online Geany notes: http://www.milliwatt-software.com/jmg/notes/geany.html ).
Thanks for the kind words, - Jeff
I just uploaded geanylua-0.6.1, which adds an _optional_ "prompt" argument to the keygrab() function.
Try the script below to see the added coolness...
--------------------------
geany.timeout(60)
local keytable = { l="examples/edit/lua-replace.lua", p="examples/edit/proper-case.lua", r="examples/edit/reverse.lua", t="examples/edit/right-trim.lua", b="examples/edit/select-block.lua" }
local prompt = { "\n Press a key...\n" }
for k,v in pairs(keytable) do table.insert(prompt, " " .. k..': '.. geany.basename(v):gsub("%.lua$", "").." ") end table.insert(prompt, "\n [Esc] to cancel.\n")
local key = geany.keygrab(table.concat(prompt, "\n"))
if key and (key ~="Escape") then local filename = keytable[key] if filename then dofile(geany.appinfo().scriptdir.."/"..filename) else geany.message("Key value '"..key.."' not assigned.") end end
--------------------------
- Jeff