Class: Rex::Ui::Text::Input

Inherits:
Object
  • Object
show all
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

IO::BidirectionalPipe, Buffer, Socket, Stdio

Defined Under Namespace

Classes: Buffer, Socket, Stdio

Constant Summary

Constants included from Color

Color::AnsiAttributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Color

#ansi, #colorize, #do_colorize, #substitute_colors

Constructor Details

#initializeInput

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

#configObject

Returns the value of attribute config.



88
89
90
# File 'lib/rex/ui/text/input.rb', line 88

def config
  @config
end

#eofObject

Returns the value of attribute eof.



112
113
114
# File 'lib/rex/ui/text/input.rb', line 112

def eof
  @eof
end

#promptObject

Returns the value of attribute prompt.



112
113
114
# File 'lib/rex/ui/text/input.rb', line 112

def prompt
  @prompt
end

#prompt_charObject

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_colorObject



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_colorObject



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_colorObject



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?

Returns:

  • (Boolean)


63
64
65
# File 'lib/rex/ui/text/input.rb', line 63

def eof?
  return eof
end

#fdObject

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

#getsObject

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.

Returns:

  • (Boolean)


80
81
82
# File 'lib/rex/ui/text/input.rb', line 80

def intrinsic_shell?
  false
end

#reset_colorObject



109
110
# File 'lib/rex/ui/text/input.rb', line 109

def reset_color
end

#reset_tab_completionObject

Stub for tab completion reset



43
44
# File 'lib/rex/ui/text/input.rb', line 43

def reset_tab_completion
end

#supports_readlineObject

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