class Canis::DefaultKeyHandler
renderer }}} This is the default key handler. It takes care of catching numbers so that vim's movement can use numeric args. That is taken care of by multiplier. Other than that it has the key_map process the key.
Public Class Methods
new(source)
click to toggle source
# File lib/canis/core/widgets/textpad.rb, line 1611 def initialize source @source = source end
Public Instance Methods
handle_key(ch)
click to toggle source
# File lib/canis/core/widgets/textpad.rb, line 1615 def handle_key ch begin case ch when ?0.getbyte(0)..?9.getbyte(0) if ch == ?0.getbyte(0) && $multiplier == 0 @source.cursor_bol @source.bounds_check return 0 end # storing digits entered so we can multiply motion actions $multiplier *= 10 ; $multiplier += (ch-48) return 0 when ?\C-c.getbyte(0) $multiplier = 0 return 0 else # check for bindings, these cannot override above keys since placed at end begin ret = @source.process_key ch, self $multiplier = 0 @source.bounds_check ## If i press C-x > i get an alert from rwidgets which blacks the screen # if i put a padrefresh here it becomes okay but only for one pad, # i still need to do it for all pads. rescue => err $log.error " TEXTPAD ERROR handle_key #{err} " $log.debug(err.backtrace.join("\n")) alert "#{err}" #textdialog ["Error in TextPad: #{err} ", *err.backtrace], :title => "Exception" end # --- NOTE ABOUT BLACK RECT LEFT on SCREEN {{{ ## NOTE if textpad does not handle the event and it goes to form which pops # up a messagebox, then padrefresh does not happen, since control does not # come back here, so a black rect is left on screen # please note that a bounds check will not happen for stuff that # is triggered by form, so you'll have to to it yourself or # call setrowcol explicity if the cursor is not updated # --- }}} return :UNHANDLED if ret == :UNHANDLED end rescue => err $log.error " TEXTPAD ERROR 591 #{err} " $log.debug( err) if err $log.debug(err.backtrace.join("\n")) if err # NOTE: textdialog itself is based on this class. alert "#{err}" #textdialog ["Error in TextPad: #{err} ", *err.backtrace], :title => "Exception" $error_message.value = "" ensure # this means that even unhandled will trigger a refresh @source.padrefresh Ncurses::Panel.update_panels end return 0 end