Class: Action
- Inherits:
-
Object
- Object
- Action
- Defined in:
- lib/vtparser/parser.rb
Instance Attribute Summary collapse
-
#action_type ⇒ Object
readonly
Returns the value of attribute action_type.
-
#ch ⇒ Object
readonly
Returns the value of attribute ch.
-
#intermediate_chars ⇒ Object
readonly
Returns the value of attribute intermediate_chars.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#private_mode_intermediate_char ⇒ Object
readonly
Returns the value of attribute private_mode_intermediate_char.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(action_type, ch, private_mode_intermediate_char, intermediate_chars, params) ⇒ Action
constructor
A new instance of Action.
- #inspect ⇒ Object
- #to_ansi ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(action_type, ch, private_mode_intermediate_char, intermediate_chars, params) ⇒ Action
Returns a new instance of Action.
8 9 10 11 12 13 14 |
# File 'lib/vtparser/parser.rb', line 8 def initialize(action_type, ch, private_mode_intermediate_char, intermediate_chars, params) @action_type = action_type @ch = ch @intermediate_chars = intermediate_chars @private_mode_intermediate_char = private_mode_intermediate_char @params = params end |
Instance Attribute Details
#action_type ⇒ Object (readonly)
Returns the value of attribute action_type.
6 7 8 |
# File 'lib/vtparser/parser.rb', line 6 def action_type @action_type end |
#ch ⇒ Object (readonly)
Returns the value of attribute ch.
6 7 8 |
# File 'lib/vtparser/parser.rb', line 6 def ch @ch end |
#intermediate_chars ⇒ Object (readonly)
Returns the value of attribute intermediate_chars.
6 7 8 |
# File 'lib/vtparser/parser.rb', line 6 def intermediate_chars @intermediate_chars end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
6 7 8 |
# File 'lib/vtparser/parser.rb', line 6 def params @params end |
#private_mode_intermediate_char ⇒ Object (readonly)
Returns the value of attribute private_mode_intermediate_char.
6 7 8 |
# File 'lib/vtparser/parser.rb', line 6 def private_mode_intermediate_char @private_mode_intermediate_char end |
Class Method Details
.inspect_char(ch) ⇒ Object
28 29 30 |
# File 'lib/vtparser/parser.rb', line 28 def self.inspect_char(ch) "ch: #{ch.inspect.ljust(4)} (ord=#{ch ? ch.ord.to_s.rjust(4) : " "}, hex=0x#{ch ? ("%02x" % ch.ord).rjust(6) : " "})" end |
Instance Method Details
#inspect ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/vtparser/parser.rb', line 20 def inspect "ansi: #{to_ansi.inspect.ljust(16)} " + "action: #{@action_type.to_s.ljust(12)} #{Action.inspect_char(@ch)} " + "private mode: #{"'#{@private_mode_intermediate_char}'".ljust(3)} " + "params: '#{@params.inspect.ljust(20)}' " + "intermediate_chars: '#{@intermediate_chars}'" end |
#to_ansi ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vtparser/parser.rb', line 32 def to_ansi case @action_type when :print, :execute, :put, :osc_put, :ignore # Output the character return @ch if @ch when :hook return "\eP#{@intermediate_chars}" when :esc_dispatch return "\e#{@intermediate_chars}#{@ch}" when :csi_dispatch # Output ESC [ followed by parameters, intermediates, and final character return "\e[#{@private_mode_intermediate_char}#{@params.join(';')}#{@intermediate_chars}#{@ch}" when :osc_start return "\e]" when :osc_end return '' # "\x07" # BEL character to end OSC when :unhook return "" # \e must come from ESCAPE state when :clear # Clear action is called when a command is interrupted by a new command (there is unfinished content in the parser) else raise "Unknown action type: #{@action_type}" end raise end |
#to_s ⇒ Object
16 17 18 |
# File 'lib/vtparser/parser.rb', line 16 def to_s to_ansi end |