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
Classes: Buffer, Socket, Stdio
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.
25 26 27 28 29 30 31 |
# File 'lib/rex/ui/text/input.rb', line 25 def initialize self.eof = false @config = { :color => :auto, # true, false, :auto } super end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
88 89 90 |
# File 'lib/rex/ui/text/input.rb', line 88 def config @config end |
#eof ⇒ Object
Returns the value of attribute eof.
112 113 114 |
# File 'lib/rex/ui/text/input.rb', line 112 def eof @eof end |
#prompt ⇒ Object
Returns the value of attribute prompt.
112 113 114 |
# File 'lib/rex/ui/text/input.rb', line 112 def prompt @prompt end |
#prompt_char ⇒ Object
Returns the value of attribute prompt_char.
112 113 114 |
# File 'lib/rex/ui/text/input.rb', line 112 def prompt_char @prompt_char end |
Instance Method Details
#auto_color ⇒ Object
100 101 102 103 |
# File 'lib/rex/ui/text/input.rb', line 100 def auto_color return if not @config @config[:color] = :auto end |
#disable_color ⇒ Object
90 91 92 93 |
# File 'lib/rex/ui/text/input.rb', line 90 def disable_color return if not @config @config[:color] = false end |
#enable_color ⇒ Object
95 96 97 98 |
# File 'lib/rex/ui/text/input.rb', line 95 def enable_color return if not @config @config[:color] = true end |
#eof? ⇒ Boolean
Has the input medium reached end-of-file?
63 64 65 |
# File 'lib/rex/ui/text/input.rb', line 63 def eof? return eof end |
#fd ⇒ Object
Returns a pollable file descriptor that is associated with this input medium.
71 72 73 |
# File 'lib/rex/ui/text/input.rb', line 71 def fd raise NotImplementedError end |
#gets ⇒ Object
Gets a line of input
56 57 58 |
# File 'lib/rex/ui/text/input.rb', line 56 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.
80 81 82 |
# File 'lib/rex/ui/text/input.rb', line 80 def intrinsic_shell? false end |
#reset_color ⇒ Object
109 110 |
# File 'lib/rex/ui/text/input.rb', line 109 def reset_color end |
#reset_tab_completion ⇒ Object
Stub for tab completion reset
43 44 |
# File 'lib/rex/ui/text/input.rb', line 43 def reset_tab_completion end |
#supports_readline ⇒ Object
Whether or not the input medium supports readline.
36 37 38 |
# File 'lib/rex/ui/text/input.rb', line 36 def supports_readline true end |
#sysread(len) ⇒ Object
Calls the underlying system read.
49 50 51 |
# File 'lib/rex/ui/text/input.rb', line 49 def sysread(len) raise NotImplementedError end |
#update_prompt(prompt) ⇒ Object
84 85 86 |
# File 'lib/rex/ui/text/input.rb', line 84 def update_prompt(new_prompt = '', new_prompt_char = '') self.prompt = new_prompt + new_prompt_char end |