Class: Watobo::Gui::SimpleTextView
- Inherits:
-
FXVerticalFrame
- Object
- FXVerticalFrame
- Watobo::Gui::SimpleTextView
- Defined in:
- lib/watobo/gui/request_editor.rb
Direct Known Subclasses
Constant Summary
Constants included from Constants
Constants::AC_GROUP_APACHE, Constants::AC_GROUP_DOMINO, Constants::AC_GROUP_ENUMERATION, Constants::AC_GROUP_FILE_INCLUSION, Constants::AC_GROUP_FLASH, Constants::AC_GROUP_GENERIC, Constants::AC_GROUP_JBOSS, Constants::AC_GROUP_JOOMLA, Constants::AC_GROUP_SAP, Constants::AC_GROUP_SQL, Constants::AC_GROUP_TYPO3, Constants::AC_GROUP_XSS, Constants::AUTH_TYPE_BASIC, Constants::AUTH_TYPE_DIGEST, Constants::AUTH_TYPE_NONE, Constants::AUTH_TYPE_NTLM, Constants::AUTH_TYPE_UNKNOWN, Constants::CHAT_SOURCE_AUTO_SCAN, Constants::CHAT_SOURCE_FUZZER, Constants::CHAT_SOURCE_INTERCEPT, Constants::CHAT_SOURCE_MANUAL, Constants::CHAT_SOURCE_MANUAL_SCAN, Constants::CHAT_SOURCE_PROXY, Constants::CHAT_SOURCE_UNDEF, Constants::DEFAULT_PORT_HTTP, Constants::DEFAULT_PORT_HTTPS, Constants::FINDING_TYPE_HINT, Constants::FINDING_TYPE_INFO, Constants::FINDING_TYPE_UNDEFINED, Constants::FINDING_TYPE_VULN, Constants::FIRST_TIME_FILE, Constants::GUI_REGULAR_FONT_SIZE, Constants::GUI_SMALL_FONT_SIZE, Constants::ICON_PATH, Constants::LOG_DEBUG, Constants::LOG_INFO, Constants::SCAN_CANCELED, Constants::SCAN_FINISHED, Constants::SCAN_PAUSED, Constants::SCAN_STARTED, Constants::TE_CHUNKED, Constants::TE_COMPRESS, Constants::TE_DEFLATE, Constants::TE_GZIP, Constants::TE_IDENTITY, Constants::TE_NONE, Constants::VULN_RATING_CRITICAL, Constants::VULN_RATING_HIGH, Constants::VULN_RATING_INFO, Constants::VULN_RATING_LOW, Constants::VULN_RATING_MEDIUM, Constants::VULN_RATING_UNDEFINED
Instance Attribute Summary collapse
-
#max_len ⇒ Object
Returns the value of attribute max_len.
-
#style ⇒ Object
Returns the value of attribute style.
-
#textbox ⇒ Object
Returns the value of attribute textbox.
Instance Method Summary collapse
- #clear ⇒ Object
- #clearEvents(event) ⇒ Object
- #editable=(e) ⇒ Object
- #editable? ⇒ Boolean
- #filter(pattern) ⇒ Object
- #highlight(pattern) ⇒ Object
-
#initialize(owner, opts) ⇒ SimpleTextView
constructor
A new instance of SimpleTextView.
- #makeMatchVisible(match_index = 0) ⇒ Object
- #numMatches ⇒ Object
- #rawRequest ⇒ Object
- #resetMatches ⇒ Object
- #setFont(font_type = nil, size = nil) ⇒ Object
- #setText(text, prefs = {}) ⇒ Object (also: #setRequest)
- #subscribe(event, &callback) ⇒ Object
- #textStyle ⇒ Object
- #textStyle=(style) ⇒ Object
Methods included from Utils
#addDecoder, #addEncoder, #addStringInfo, #cleanupHTTP, load_plugins, #removeTags, #replace_text
Constructor Details
#initialize(owner, opts) ⇒ SimpleTextView
Returns a new instance of SimpleTextView.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/watobo/gui/request_editor.rb', line 54 def initialize(owner, opts) @logger = (defined? owner.logger) ? owner.logger : nil @pattern_matches = [] @text = "" @event_dispatcher_listeners = Hash.new super(owner, opts) # Construct some hilite styles @style = 1 # default style @max_len = 0 @small_font = FXFont.new(getApp(), "helvetica", GUI_SMALL_FONT_SIZE) @small_font.create @big_font = FXFont.new(getApp(), "helvetica", GUI_REGULAR_FONT_SIZE) @big_font.create = SEL_TYPE_HIGHLIGHT # Construct some hilite styles hs_green = FXHiliteStyle.new hs_green.normalForeColor = FXRGBA(255, 255, 255, 255) #FXColor::Red hs_green.normalBackColor = FXRGBA(0, 255, 0, 1) # FXColor::White hs_green.style = FXText::STYLE_BOLD hs_red = FXHiliteStyle.new hs_red.normalForeColor = FXRGBA(255, 255, 255, 255) #FXColor::Red hs_red.normalBackColor = FXRGBA(255, 0, 0, 1) # FXColor::White hs_red.style = FXText::STYLE_BOLD # @req_builder = FXText.new(req_editor, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y) @textbox = FXText.new(self, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y) @textbox.extend Watobo::Mixins::RequestParser # Enable the style buffer for this text widget @textbox.styled = true # Set the styles @textbox.hiliteStyles = [hs_green, hs_red] @textbox.editable = false @textbox.textStyle |= TEXT_WORDWRAP @textbox.connect(SEL_RIGHTBUTTONRELEASE) do |sender, sel, event| unless event.moved? FXMenuPane.new(self) do || pos = @textbox.selStartPos len = @textbox.selEndPos - pos selection = @textbox.extractText(pos, len) addStringInfo(, sender) addDecoder(, sender) addEncoder(, sender) if @textbox.editable? FXMenuSeparator.new() FXMenuCaption.new(, "- Copy -") FXMenuSeparator.new() copyText = FXMenuCommand.new(, "copy text: #{selection}", nil, @textbox, FXText::ID_COPY_SEL) FXMenuSeparator.new() FXMenuCaption.new(, "- Transcoder -") FXMenuSeparator.new() send2transcoder = FXMenuCommand.new(, "send to transcoder") send2transcoder.connect(SEL_COMMAND) { t = TranscoderWindow.new(FXApp.instance, selection) t.create t.show(Fox::PLACEMENT_SCREEN) } FXMenuSeparator.new() target = FXMenuCheck.new(, "word wrap") target.check = (@textbox.textStyle & TEXT_WORDWRAP > 0) ? true : false target.connect(SEL_COMMAND) { @textbox.textStyle ^= TEXT_WORDWRAP } target = FXMenuCheck.new(, "big font") target.check = (@textbox.font == @small_font) ? false : true target.connect(SEL_COMMAND) { |ts, tsel, titem| if ts.checked? @textbox.font = @big_font else @textbox.font = @small_font end } .create .popup(nil, event.root_x, event.root_y) app.runModalWhileShown() end end end end |
Instance Attribute Details
#max_len ⇒ Object
Returns the value of attribute max_len.
8 9 10 |
# File 'lib/watobo/gui/request_editor.rb', line 8 def max_len @max_len end |
#style ⇒ Object
Returns the value of attribute style.
7 8 9 |
# File 'lib/watobo/gui/request_editor.rb', line 7 def style @style end |
#textbox ⇒ Object
Returns the value of attribute textbox.
6 7 8 |
# File 'lib/watobo/gui/request_editor.rb', line 6 def textbox @textbox end |
Instance Method Details
#clear ⇒ Object
42 43 44 |
# File 'lib/watobo/gui/request_editor.rb', line 42 def clear @textbox.setText('') end |
#clearEvents(event) ⇒ Object
18 19 20 |
# File 'lib/watobo/gui/request_editor.rb', line 18 def clearEvents(event) @event_dispatcher_listener[event].clear end |
#editable=(e) ⇒ Object
152 153 154 |
# File 'lib/watobo/gui/request_editor.rb', line 152 def editable=(e) @textbox.editable = e end |
#editable? ⇒ Boolean
156 157 158 |
# File 'lib/watobo/gui/request_editor.rb', line 156 def editable?() @textbox.editable? end |
#filter(pattern) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/watobo/gui/request_editor.rb', line 170 def filter(pattern) #dummy = @textbox.to_s.split(/\n/) dummy = @text.split(/\n/) @textbox.setText('') filtered = [] dummy.each do |line| begin if line =~ /#{pattern}/i then filtered.push line end rescue => bang puts puts bang pattern = Regexp.quote(pattern) retry end end showText(filtered.join("\n")) end |
#highlight(pattern) ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/watobo/gui/request_editor.rb', line 190 def highlight(pattern) sindex = nil eindex = nil dummy = @textbox.to_s #remove previous highlighting @textbox.setText(dummy) matchPattern(pattern) # puts "* found pattern #{pattern} #{@pattern_matches.length} times" @pattern_matches.each do |start, len| begin @textbox.changeStyle(start, len, @style) rescue => bang puts "outch" puts bang end end return @pattern_matches.length end |
#makeMatchVisible(match_index = 0) ⇒ Object
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/watobo/gui/request_editor.rb', line 213 def makeMatchVisible(match_index=0) return true if @pattern_matches.empty? return false if match_index > (@pattern_matches.length - 1) if @pattern_matches[match_index] then pos = @pattern_matches[match_index][0] len =@pattern_matches[match_index][1] @textbox.setCenterLine(pos) # @textbox.makePositionVisible(pos + len) @textbox.makePositionVisible(@textbox.lineEnd(pos)) @textbox.makePositionVisible(pos) @textbox.setCursorPos(pos) end return true end |
#numMatches ⇒ Object
30 31 32 |
# File 'lib/watobo/gui/request_editor.rb', line 30 def numMatches() @pattern_matches.length end |
#rawRequest ⇒ Object
26 27 28 |
# File 'lib/watobo/gui/request_editor.rb', line 26 def rawRequest() @textbox.text end |
#resetMatches ⇒ Object
22 23 24 |
# File 'lib/watobo/gui/request_editor.rb', line 22 def resetMatches() @pattern_matches.clear end |
#setFont(font_type = nil, size = nil) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/watobo/gui/request_editor.rb', line 46 def setFont(font_type=nil, size=nil) new_size = size.nil? ? GUI_REGULAR_FONT_SIZE : size new_font_type = font_type.nil? ? "helvetica" : font_type new_font = FXFont.new(getApp(), new_font_type, new_size) new_font.create @textbox.font = new_font end |
#setText(text, prefs = {}) ⇒ Object Also known as: setRequest
161 162 163 164 165 166 |
# File 'lib/watobo/gui/request_editor.rb', line 161 def setText(text, prefs={}) @text = normalizeText(text) showText(@text) true end |
#subscribe(event, &callback) ⇒ Object
14 15 16 |
# File 'lib/watobo/gui/request_editor.rb', line 14 def subscribe(event, &callback) (@event_dispatcher_listeners[event] ||= []) << callback end |
#textStyle ⇒ Object
38 39 40 |
# File 'lib/watobo/gui/request_editor.rb', line 38 def textStyle() @textbox.textStyle end |
#textStyle=(style) ⇒ Object
34 35 36 |
# File 'lib/watobo/gui/request_editor.rb', line 34 def textStyle=(style) @textbox.textStyle = style end |