Class: Rereline::Terminal
- Inherits:
-
Object
- Object
- Rereline::Terminal
- Defined in:
- lib/rereline/terminal.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#editor ⇒ Object
readonly
Returns the value of attribute editor.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#key_actor ⇒ Object
readonly
Returns the value of attribute key_actor.
-
#key_stroke ⇒ Object
readonly
Returns the value of attribute key_stroke.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(prompt, use_history) ⇒ Terminal
constructor
A new instance of Terminal.
- #readline ⇒ Object
Constructor Details
#initialize(prompt, use_history) ⇒ Terminal
Returns a new instance of Terminal.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rereline/terminal.rb', line 25 def initialize(prompt, use_history) @editor = LineEditor.new do |editor| editor.prompt = prompt end @key_stroke = KeyStroke.new(KeyActor::MAPPING) @key_actor = KeyActor.new(editor) @input = $stdin @output = $stdout @input_key_buffer = [] end |
Instance Attribute Details
#editor ⇒ Object (readonly)
Returns the value of attribute editor.
23 24 25 |
# File 'lib/rereline/terminal.rb', line 23 def editor @editor end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
23 24 25 |
# File 'lib/rereline/terminal.rb', line 23 def input @input end |
#key_actor ⇒ Object (readonly)
Returns the value of attribute key_actor.
23 24 25 |
# File 'lib/rereline/terminal.rb', line 23 def key_actor @key_actor end |
#key_stroke ⇒ Object (readonly)
Returns the value of attribute key_stroke.
23 24 25 |
# File 'lib/rereline/terminal.rb', line 23 def key_stroke @key_stroke end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
23 24 25 |
# File 'lib/rereline/terminal.rb', line 23 def output @output end |
Instance Method Details
#readline ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/rereline/terminal.rb', line 36 def readline renader_editor loop do input_key(getkey) end rescue Finish => e output.write "\n" e. end |