lib/key_map.rb
# Associate an input to a command.
Associate an input to a command.
Associate an input to a command .
def add_key(key, command)
    if key.is_a?(Array) then
      char_key = to_ord(key.pop)
      if key.include?(:ctrl) then
        char_key -= 32 if char_key > 96 and char_key < 123
        char_key -= 64
      end
      if key.include?(:alt) then
        @alt_keys[char_key] = CSTE::Command.cmd(command)
      else
        @keys[char_key] = CSTE::Command.cmd(command)
      end
    else
      @keys[to_ord(key)] = CSTE::Command.cmd(command)
    end
    return self
  end
def add_key ( key , command ) if key . is_a? ( Array ) then char_key = to_ord ( key . pop ) if key . include? ( :ctrl ) then char_key -= 32 if char_key > 96 and char_key < 123 char_key -= 64 end if key . include? ( :alt ) then @alt_keys [ char_key ] = CSTE :: Command . cmd ( command ) else @keys [ char_key ] = CSTE :: Command . cmd ( command ) end else @keys [ to_ord ( key ) ] = CSTE :: Command . cmd ( command ) end return self end
Associate an input to a command.
Associate an input to a command .
# A key can be only a char or a char with a combination of modifiers. # The last element must be a char. # Convert to upcase if nescessary. # To apply ctrl to a char we need to subtract 64. # 'Alt' + 'something' send two signals. So, after a signal 27 (esc/alt) # editor waits for the next signal and look for @alt_keys instead of # @keys. # 'Esc' + 'something' works in the same way than 'alt' + 'something'.
key
command