Class: Landescape::Converter::VT100

Inherits:
Base
  • Object
show all
Defined in:
lib/landescape/converter.rb

Constant Summary collapse

CODES =
{
  /^\e\[(\d+)?(?:;(\d+))?[Hf]$/ => {
    name: :cursor_address,
    args: ->(captures) { captures.map(&:to_i) }
  },

  /^\e\[(\d+)?A$/ => {
    name: :cursor_up,
    args: ->(captures) { captures.first.to_i }
  },

  /^\e\[(\d+)?B$/ => {
    name: :cursor_down,
    args: ->(captures) { captures.first.to_i }
  },

  /^\e\[(\d+)?C$/ => {
    name: :cursor_right,
    args: ->(captures) { captures.first.to_i }
  },

  /^\e\[(\d+)?D$/ => {
    name: :cursor_left,
    args: ->(captures) { captures.first.to_i }
  },

  /^\e\[0?m$/ => {name: :exit_attribute_mode},

  /^\e\[([\d;]+)m$/ => {
    name: :set_attributes,
    args: ->(captures) { captures.join.split(/;/).map(&:to_i) }
  },

  /^\e\[(\d+);(\d+)r$/ => {
    name: :change_scroll_region,
    args: ->(captures) { captures.map(&:to_i) }
  },

  /^\e\[s$/   => {name: :save_cursor},
  /^\e\[u$/   => {name: :restore_cursor},
  /^\e\[2?J$/ => {name: :clear_screen},
  /^\e\[K$/   => {name: :clear_eol},

  /^\eD$/ => {name: :scroll_forward},
  /^\eM$/ => {name: :scroll_reverse},

  /^\e\[\?1h$/ => {name: :keypad_xmit},
  /^\e\[\?1l$/ => {name: :keypad_local},

  # cursor_normal is probably not available on vt100
  /^\e\[\?25h$/ => {name: :cursor_visible},
  /^\e\[\?25l$/ => {name: :cursor_invisible},

  # backslashes
  /^\n$/   => {name: :newline},
  /^\r$/   => {name: :carriage_return},
  /^(\a)$/ => {name: :bell},

  # really...? maybe doubt!
  /^\e\\$/ => {name: :carriage_return},

  /^(\u000F|\e.+)$/ => {
    name: :unknown,
    args: ->(captures) { captures.first }
  }
}

Instance Attribute Summary

Attributes inherited from Base

#result, #tokens

Method Summary

Methods inherited from Base

#initialize, start, #start, #stop

Constructor Details

This class inherits a constructor from Landescape::Converter::Base