Class: Rex::Ui::Text::Input
- Inherits:
-
Object
- Object
- Rex::Ui::Text::Input
- Includes:
- 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
Constant Summary
Constants included from Color
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
- #enable_color ⇒ 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
Methods included from Color
#ansi, #colorize, #do_colorize, #substitute_colors
Constructor Details
#initialize ⇒ Input
Returns a new instance of Input.
24 25 26 27 28 29 30 |
# File 'lib/rex/ui/text/input.rb', line 24 def initialize self.eof = false @config = { :color => :auto, # true, false, :auto } super end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
87 88 89 |
# File 'lib/rex/ui/text/input.rb', line 87 def config @config end |
#eof ⇒ Object
Returns the value of attribute eof.
111 112 113 |
# File 'lib/rex/ui/text/input.rb', line 111 def eof @eof end |
#prompt ⇒ Object
Returns the value of attribute prompt.
111 112 113 |
# File 'lib/rex/ui/text/input.rb', line 111 def prompt @prompt end |
#prompt_char ⇒ Object
Returns the value of attribute prompt_char.
111 112 113 |
# File 'lib/rex/ui/text/input.rb', line 111 def prompt_char @prompt_char end |
Instance Method Details
#auto_color ⇒ Object
99 100 101 102 |
# File 'lib/rex/ui/text/input.rb', line 99 def auto_color return if not @config @config[:color] = :auto end |
#disable_color ⇒ Object
89 90 91 92 |
# File 'lib/rex/ui/text/input.rb', line 89 def disable_color return if not @config @config[:color] = false end |
#enable_color ⇒ Object
94 95 96 97 |
# File 'lib/rex/ui/text/input.rb', line 94 def enable_color return if not @config @config[:color] = true end |
#eof? ⇒ Boolean
Has the input medium reached end-of-file?
62 63 64 |
# File 'lib/rex/ui/text/input.rb', line 62 def eof? return eof end |
#fd ⇒ Object
Returns a pollable file descriptor that is associated with this input medium.
70 71 72 |
# File 'lib/rex/ui/text/input.rb', line 70 def fd raise NotImplementedError end |
#gets ⇒ Object
Gets a line of input
55 56 57 |
# File 'lib/rex/ui/text/input.rb', line 55 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.
79 80 81 |
# File 'lib/rex/ui/text/input.rb', line 79 def intrinsic_shell? false end |
#reset_color ⇒ Object
108 109 |
# File 'lib/rex/ui/text/input.rb', line 108 def reset_color end |
#reset_tab_completion ⇒ Object
Stub for tab completion reset
42 43 |
# File 'lib/rex/ui/text/input.rb', line 42 def reset_tab_completion end |
#supports_readline ⇒ Object
Whether or not the input medium supports readline.
35 36 37 |
# File 'lib/rex/ui/text/input.rb', line 35 def supports_readline true end |
#sysread(len) ⇒ Object
Calls the underlying system read.
48 49 50 |
# File 'lib/rex/ui/text/input.rb', line 48 def sysread(len) raise NotImplementedError end |
#update_prompt(prompt) ⇒ Object
83 84 85 |
# File 'lib/rex/ui/text/input.rb', line 83 def update_prompt(new_prompt = '', new_prompt_char = '') self.prompt = new_prompt + new_prompt_char end |