custom key bindings

1 view
Skip to first unread message

Roger Pack

unread,
Oct 5, 2009, 1:13:56 PM10/5/09
to Arcadia ruby ide
I was thinking that a good way to allow for customizability would be
to allow users to add "code" to their preferences file, ex:

keybindings.ctrl.alt.w = "SearchInFiles.new(self)"

or

keybindings= "bindings['ctrl' + 'alt' + 'w'] = proc {
SearchInFiles.new(self }; bindings['ctrl' + 'w'] = proc {Something}"

Thoughts?

Antonio Galeone

unread,
Oct 5, 2009, 4:00:44 PM10/5/09
to arcadia-...@googlegroups.com
Hi,
I thought to follow the style of user_menu and user_toolbar so we complete
the user interaction ways
ex :

user_keybinding=a,b,c
user_keybinding.a.keys=<CONTROL><ALT>w
user_keybinding.a.event_class=SearchInFilesEvent
user_keybinding.a.event_args={'dir'=>"*LAST"}

user_keybinding.b.keys=<CONTROL><ALT>p
user_keybinding.b.event_class=ActionEvent
user_keybinding.b.event_args={'action'=>"do_something"}

user_keybinding.c.keys=<SHIFT>p
user_keybinding.c.event_class=ActionEvent
user_keybinding.c.event_args={'action'=>"do_otherthing"}


What do you think?
Ant


2009/10/5 Roger Pack <roger...@gmail.com>

Roger Pack

unread,
Oct 5, 2009, 6:14:28 PM10/5/09
to arcadia-...@googlegroups.com
> user_keybinding.c.keys=<SHIFT>p
> user_keybinding.c.event_class=ActionEvent
> user_keybinding.c.event_args={'action'=>"do_otherthing"}

I like it. another option would be
> user_keybinding.ctrl.shift.c="some code"

I almost wish for more flexibility of being able to run your own code
if desired, like
> user_keybinding.ctrl.shift.c=" if File.exist?('a') ActionEvent.new(self); end"

Or perhaps
> user_keybinding.ctrl.shift.c="proc {|handle_to_current_tab| if(File.exist? File.dirname(hand_to_current_tab.filename) + "/../../test/abcdef" RunRubyFile("../test/abcdef"); else..."

But maybe that's overkill?
-r

Roger Pack

unread,
Oct 8, 2009, 11:30:58 AM10/8/09
to arcadia-...@googlegroups.com
> I almost wish for more flexibility of being able to run your own code
> if desired, like
>> user_keybinding.ctrl.shift.c=" if File.exist?('a') ActionEvent.new(self); end"

Ahh I understand now.
You can define

user_keybinding.c.event_class=ActionEvent
user_keybinding.c.event_args={'action'=>"do_otherthing"}

then on_action_event
you can check for state like "what file is being worked on" via
AgMultiEditor.raised # current file

That should be fine. I should probably refactor some of my plugins to
work like that, sometime :)
-r

antonio.galeone

unread,
Oct 8, 2009, 12:01:21 PM10/8/09
to Arcadia ruby ide
ActionEvent is a way to bind a methods of receiver:
see in a-contracts:

class ActionEvent < ArcadiaEvent
attr_accessor :receiver
attr_accessor :action
attr_accessor :action_args
end

a in a-core: ArcadiaActionDispatcher

User in <extension>.conf the receiver is set to extension instance.

This is a way to call a particular method in decoupled way without
create a new Event

angal
Reply all
Reply to author
Forward
0 new messages