Class: Vedeu::Editor::Editor
- Inherits:
-
Object
- Object
- Vedeu::Editor::Editor
- Extended by:
- Forwardable
- Includes:
- Common
- Defined in:
- lib/vedeu/editor/editor.rb
Overview
Handles keypresses for a named document whilst the terminal is in fake mode.
Instance Attribute Summary collapse
- #input ⇒ Symbol|String readonly protected
- #name ⇒ String readonly protected
Class Method Summary collapse
-
.keypress(input:, name:) ⇒ String|Symbol
Send given input to the named document.
Instance Method Summary collapse
-
#document ⇒ Vedeu::Editor::Document
private
Return the document by name from the documents repository.
-
#initialize(input:, name:) ⇒ Vedeu::Editor::Editor
constructor
Returns a new instance of Vedeu::Editor::Editor.
-
#keypress ⇒ String|Symbol
Send given input to the named document.
Methods included from Common
#demodulize, #present?, #snake_case
Constructor Details
#initialize(input:, name:) ⇒ Vedeu::Editor::Editor
Returns a new instance of Vedeu::Editor::Editor.
40 41 42 43 |
# File 'lib/vedeu/editor/editor.rb', line 40 def initialize(input:, name:) @input = input @name = name end |
Instance Attribute Details
#input ⇒ Symbol|String (readonly, protected)
71 72 73 |
# File 'lib/vedeu/editor/editor.rb', line 71 def input @input end |
#name ⇒ String (readonly, protected)
75 76 77 |
# File 'lib/vedeu/editor/editor.rb', line 75 def name @name end |
Class Method Details
.keypress(input:, name:) ⇒ String|Symbol
Send given input to the named document.
31 32 33 |
# File 'lib/vedeu/editor/editor.rb', line 31 def self.keypress(input:, name:) new(input: input, name: name).keypress end |
Instance Method Details
#document ⇒ Vedeu::Editor::Document (private)
Return the document by name from the documents repository.
82 83 84 |
# File 'lib/vedeu/editor/editor.rb', line 82 def document @document ||= Vedeu.documents.by_name(name) end |
#keypress ⇒ String|Symbol
Send given input to the named document.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/vedeu/editor/editor.rb', line 48 def keypress return input unless document case input when :backspace then delete_character when :ctrl_c then Vedeu.trigger(:_exit_) when :down then down when :enter then insert_line when :escape then Vedeu.trigger(:_mode_switch_) when :left then left when :right then right when :tab then execute when :up then up # when '' then delete_line else insert_character(input) end end |