Module: Buby::Implants::TextEditor

Defined in:
lib/buby/implants/text_editor.rb

Overview

This interface is used to provide extensions with an instance of Burp’s raw text editor, for the extension to use in its own UI. Extensions should call Buby#createTextEditor to obtain an instance of this interface.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.implant(editor) ⇒ Object

Install ourselves into the current ITextEditor java class

Parameters:

  • editor (ITextEditor)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/buby/implants/text_editor.rb', line 38

def self.implant(editor)
  unless editor.implanted? || editor.nil?
    pp [:implanting, editor, editor.class] if $DEBUG
    editor.class.class_exec(editor) do |editor|
      a_methods = %w{
        setText
        getText
        getSelectedText
      }
      a_methods.each do |meth|
        alias_method "__"+meth.to_s, meth
      end
      include Buby::Implants::TextEditor
      a_methods.each do |meth|
        java_class.ruby_names_for_java_method(meth).each do |ruby_meth|
          define_method ruby_meth, Buby::Implants::TextEditor.instance_method(meth)
        end
      end
      include Buby::Implants::Proxy
    end
  end
  editor
end

Instance Method Details

#getSelectedTextString?

This method is used to obtain the currently selected text.

Returns:

  • (String, nil)

    The currently selected text, or nil if the user has not made any selection.



31
32
33
# File 'lib/buby/implants/text_editor.rb', line 31

def getSelectedText
  String.from_java_bytes __getSelectedText
end

#getTextString

This method is used to retrieve the currently displayed text.

Returns:

  • (String)

    The currently displayed text.



22
23
24
# File 'lib/buby/implants/text_editor.rb', line 22

def getText
  String.from_java_bytes __getText
end

#setText(txt) ⇒ void

This method returns an undefined value.

This method is used to update the currently displayed text in the editor.

Parameters:

  • txt (String)

    The text to be displayed.



14
15
16
# File 'lib/buby/implants/text_editor.rb', line 14

def setText(txt)
  __setText(txt.to_java_bytes)
end