Class: Amun::MajorModes::Fundamental
- Inherits:
-
Object
- Object
- Amun::MajorModes::Fundamental
- Includes:
- Behaviours::Emacs
- Defined in:
- lib/amun/major_modes/fundamental.rb
Overview
Basic mode that show any IO
Instance Method Summary collapse
- #event_handler(event) ⇒ Object
-
#initialize(buffer) ⇒ Fundamental
constructor
A new instance of Fundamental.
- #render(window) ⇒ Object
- #trigger(event) ⇒ Object
Methods included from Behaviours::Emacs
#backward_char, #backward_delete_char, #backward_kill_word, #beginning_of_line, #delete_char, #emacs_behaviour_initialize, #end_of_line, #forward_char, #forward_delete_char, #kill_line, #kill_word, #next_line, #previous_line
Constructor Details
#initialize(buffer) ⇒ Fundamental
Returns a new instance of Fundamental.
10 11 12 13 14 15 16 17 18 |
# File 'lib/amun/major_modes/fundamental.rb', line 10 def initialize(buffer) @buffer = buffer @events = EventManager.new @events.bind_all self, :event_handler emacs_behaviour_initialize(@events) read_io if buffer.text.nil? end |
Instance Method Details
#event_handler(event) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/amun/major_modes/fundamental.rb', line 37 def event_handler(event) return true unless event.is_a? String return true unless event.length == 1 return true unless event.valid_encoding? case event when /[^[:print:]\n\t]/ true else buffer.text.insert(buffer.point, event) buffer.point += 1 end end |
#render(window) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/amun/major_modes/fundamental.rb', line 24 def render(window) window.clear point = buffer.point window << buffer.text[0...point] window.attron(Helpers::Colors::REVERSE) at_point = buffer.text[point] window << (at_point == "\n" || at_point.nil? ? " \n" : at_point) window.attroff(Helpers::Colors::REVERSE) window << buffer.text[(point + 1)..-1] end |
#trigger(event) ⇒ Object
20 21 22 |
# File 'lib/amun/major_modes/fundamental.rb', line 20 def trigger(event) EventManager.join(event, @events) end |