On Sat, Nov 1, 2008 at 1:46 AM, Nit Khair <sentinel.2001 / gmx.com> wrote: > Michael Fellinger wrote: > >> >> http://github.com/manveru/ver >> >> esp: >> http://github.com/manveru/ver/tree/master/lib/ver/keyboard.rb >> http://github.com/manveru/ver/tree/master/lib/ver/window.rb >> http://github.com/manveru/ver/tree/master/lib/ver/ncurses.rb >> >> I wrote a rougelike in ruby+ncurses, but the source isn't online >> anymore, i can send you if you like :) >> >> ^ manveru > > Thanks manveru - could you tell me what keyboard.rb does in a nutshell. > I simply bind keys using the "?\C-a" kind of notation to symbols or > procs. It allows me to make any object the receiver of keystrokes, simply by doing Keyboard.focus = something the object has to respond to the #key method and take the name of the key (as string) as argument. So, in my code, once i show or hide a window/pane/view that is interactive, i simply let it take over the focus of Keyboard and don't have separate dispatching or some kind of main loop. keybindings are handled by http://github.com/manveru/ver/tree/master/lib/ver/keymap.rb but that's a lot more complicated, building a tree structure and descends down into it until a matching keybinding is found. that allows emacs-like keybindings like [C-x C-c]. > I read your comment in window.rb of the bug that doesnt let you subclass > window. I had a long discussion on this here, i was trying to subclass > Form, iirc. Finally, someone said that the constructor was "shadowed", > so one cannot make another one (I cannot recall the exact words), or > maybe it was private. So i too had wrapped and delegated like you have. Yeah, it was quite a pain... ncurses.rb already does method_missing, and then this wrapping introduces another layer, not very nice at all.