Class: Rex::Ui::Text::Input
- Inherits:
-
Object
- Object
- Rex::Ui::Text::Input
- Includes:
- Text::Color
- Defined in:
- lib/rex/ui/text/input.rb
Overview
This class acts as a base for all input mediums. It defines the interface that will be used by anything that wants to interact with a derived class.
Direct Known Subclasses
Defined Under Namespace
Classes: Buffer, Socket, Stdio
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#eof ⇒ Object
Returns the value of attribute eof.
-
#prompt ⇒ Object
Returns the value of attribute prompt.
-
#prompt_char ⇒ Object
Returns the value of attribute prompt_char.
Instance Method Summary collapse
- #auto_color ⇒ Object
- #disable_color ⇒ Object
- #disable_readline ⇒ Object
- #enable_color ⇒ Object
- #enable_readline ⇒ Object
-
#eof? ⇒ Boolean
Has the input medium reached end-of-file?.
-
#fd ⇒ Object
Returns a pollable file descriptor that is associated with this input medium.
-
#gets ⇒ Object
Gets a line of input.
-
#initialize ⇒ Input
constructor
A new instance of Input.
-
#intrinsic_shell? ⇒ Boolean
Indicates whether or not this input medium is intrinsicly a shell provider.
- #reset_color ⇒ Object
-
#reset_tab_completion ⇒ Object
Stub for tab completion reset.
-
#supports_readline ⇒ Object
Whether or not the input medium supports readline.
-
#sysread(len) ⇒ Object
Calls the underlying system read.
- #update_prompt(prompt) ⇒ Object
Constructor Details
#initialize ⇒ Input
Returns a new instance of Input.
20 21 22 23 24 25 26 27 |
# File 'lib/rex/ui/text/input.rb', line 20 def initialize self.eof = false @config = { :readline => true, # true, false :color => :auto, # true, false, :auto } super end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
86 87 88 |
# File 'lib/rex/ui/text/input.rb', line 86 def config @config end |
#eof ⇒ Object
Returns the value of attribute eof.
120 121 122 |
# File 'lib/rex/ui/text/input.rb', line 120 def eof @eof end |
#prompt ⇒ Object
Returns the value of attribute prompt.
120 121 122 |
# File 'lib/rex/ui/text/input.rb', line 120 def prompt @prompt end |
#prompt_char ⇒ Object
Returns the value of attribute prompt_char.
120 121 122 |
# File 'lib/rex/ui/text/input.rb', line 120 def prompt_char @prompt_char end |
Instance Method Details
#auto_color ⇒ Object
108 109 110 111 |
# File 'lib/rex/ui/text/input.rb', line 108 def auto_color return if not @config @config[:color] = :auto end |
#disable_color ⇒ Object
98 99 100 101 |
# File 'lib/rex/ui/text/input.rb', line 98 def disable_color return if not @config @config[:color] = false end |
#disable_readline ⇒ Object
88 89 90 91 |
# File 'lib/rex/ui/text/input.rb', line 88 def disable_readline return if not @config @config[:readline] = false end |
#enable_color ⇒ Object
103 104 105 106 |
# File 'lib/rex/ui/text/input.rb', line 103 def enable_color return if not @config @config[:color] = true end |
#enable_readline ⇒ Object
93 94 95 96 |
# File 'lib/rex/ui/text/input.rb', line 93 def enable_readline return if not @config @config[:readline] = true end |
#eof? ⇒ Boolean
Has the input medium reached end-of-file?
61 62 63 |
# File 'lib/rex/ui/text/input.rb', line 61 def eof? return eof end |
#fd ⇒ Object
Returns a pollable file descriptor that is associated with this input medium.
69 70 71 |
# File 'lib/rex/ui/text/input.rb', line 69 def fd raise NotImplementedError end |
#gets ⇒ Object
Gets a line of input
54 55 56 |
# File 'lib/rex/ui/text/input.rb', line 54 def gets raise NotImplementedError end |
#intrinsic_shell? ⇒ Boolean
Indicates whether or not this input medium is intrinsicly a shell provider. This would indicate whether or not it already expects to have a prompt.
78 79 80 |
# File 'lib/rex/ui/text/input.rb', line 78 def intrinsic_shell? false end |
#reset_color ⇒ Object
117 118 |
# File 'lib/rex/ui/text/input.rb', line 117 def reset_color end |
#reset_tab_completion ⇒ Object
Stub for tab completion reset
41 42 |
# File 'lib/rex/ui/text/input.rb', line 41 def reset_tab_completion end |
#supports_readline ⇒ Object
Whether or not the input medium supports readline.
32 33 34 35 36 |
# File 'lib/rex/ui/text/input.rb', line 32 def supports_readline return true if not @config config[:readline] == true end |
#sysread(len) ⇒ Object
Calls the underlying system read.
47 48 49 |
# File 'lib/rex/ui/text/input.rb', line 47 def sysread(len) raise NotImplementedError end |
#update_prompt(prompt) ⇒ Object
82 83 84 |
# File 'lib/rex/ui/text/input.rb', line 82 def update_prompt(new_prompt = '', new_prompt_char = '') self.prompt = new_prompt + new_prompt_char end |