Sha256: 2c734f168b4662b6d80642403d15d7db821da4143a48b5e5f97bb93e3f1fcf8e
Contents?: true
Size: 1.54 KB
Versions: 4
Compression:
Stored size: 1.54 KB
Contents
module Vedeu # Captures input from the user via {Vedeu::Terminal#input} and translates # special characters into symbols. # # @api private class Input # @return [String|Symbol] def self.capture new.capture end # Returns a new instance of Input. # # @return [Input] def initialize; end # @return [] def capture Vedeu.trigger(:_keypress_, keypress) end private # @api private # @return [String] def input @_input ||= Terminal.input end # @api private # @return [String|Symbol] def keypress key = input specials.fetch(key, key) end # @api private # @return [Hash] def specials { "\r" => :enter, "\t" => :tab, "\e" => :escape, "\e[A" => :up, "\e[B" => :down, "\e[C" => :right, "\e[D" => :left, "\e[5~" => :page_up, "\e[6~" => :page_down, "\e[H" => :home, "\e[3~" => :delete, "\e[F" => :end, "\e[Z" => :shift_tab, "\eOP" => :f1, "\eOQ" => :f2, "\eOR" => :f3, "\eOS" => :f4, "\e[15~" => :f5, "\e[17~" => :f6, "\e[18~" => :f7, "\e[19~" => :f8, "\e[20~" => :f9, "\e[21~" => :f10, "\e[23~" => :f11, "\e[24~" => :f12, "\e[1;2P" => :print_screen, "\e[1;2Q" => :scroll_lock, "\e[1;2R" => :pause_break, "\u007F" => :backspace, } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vedeu-0.2.2 | lib/vedeu/input/input.rb |
vedeu-0.2.1 | lib/vedeu/input/input.rb |
vedeu-0.2.0 | lib/vedeu/input/input.rb |
vedeu-0.1.19 | lib/vedeu/input/input.rb |