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

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

BidirectionalPipe, Buffer, Socket, Stdio

Defined Under Namespace

Classes: Buffer, Socket, Stdio

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeInput

Returns a new instance of Input.


20
21
22
23
24
25
26
# File 'lib/rex/ui/text/input.rb', line 20

def initialize
  self.eof = false
  @config = {
    :color => :auto, # true, false, :auto
  }
  super
end

Instance Attribute Details

#configObject

Returns the value of attribute config


83
84
85
# File 'lib/rex/ui/text/input.rb', line 83

def config
  @config
end

#eofObject

Returns the value of attribute eof


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

def eof
  @eof
end

#promptObject

Returns the value of attribute prompt


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

def prompt
  @prompt
end

#prompt_charObject

Returns the value of attribute prompt_char


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

def prompt_char
  @prompt_char
end

Instance Method Details

#auto_colorObject


95
96
97
98
# File 'lib/rex/ui/text/input.rb', line 95

def auto_color
  return if not @config
  @config[:color] = :auto
end

#disable_colorObject


85
86
87
88
# File 'lib/rex/ui/text/input.rb', line 85

def disable_color
  return if not @config
  @config[:color] = false
end

#enable_colorObject


90
91
92
93
# File 'lib/rex/ui/text/input.rb', line 90

def enable_color
  return if not @config
  @config[:color] = true
end

#eof?Boolean

Has the input medium reached end-of-file?

Returns:

  • (Boolean)

58
59
60
# File 'lib/rex/ui/text/input.rb', line 58

def eof?
  return eof
end

#fdObject

Returns a pollable file descriptor that is associated with this input medium.

Raises:

  • (NotImplementedError)

66
67
68
# File 'lib/rex/ui/text/input.rb', line 66

def fd
  raise NotImplementedError
end

#getsObject

Gets a line of input

Raises:

  • (NotImplementedError)

51
52
53
# File 'lib/rex/ui/text/input.rb', line 51

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)

75
76
77
# File 'lib/rex/ui/text/input.rb', line 75

def intrinsic_shell?
  false
end

#reset_colorObject


104
105
# File 'lib/rex/ui/text/input.rb', line 104

def reset_color
end

#reset_tab_completionObject

Stub for tab completion reset


38
39
# File 'lib/rex/ui/text/input.rb', line 38

def reset_tab_completion
end

#supports_readlineObject

Whether or not the input medium supports readline.


31
32
33
# File 'lib/rex/ui/text/input.rb', line 31

def supports_readline
  true
end

#sysread(len) ⇒ Object

Calls the underlying system read.

Raises:

  • (NotImplementedError)

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

def sysread(len)
  raise NotImplementedError
end

#update_prompt(prompt) ⇒ Object


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

def update_prompt(new_prompt = '', new_prompt_char = '')
  self.prompt = new_prompt + new_prompt_char
end