Sha256: f26078f3b8e6758767d1c0477be0e2a859cef4e907e0148917f186c95ef90b77

Contents?: true

Size: 1.67 KB

Versions: 1

Compression:

Stored size: 1.67 KB

Contents

class Buby
  module Implants
    # 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.
    #
    module TextEditor
      # This method is used to retrieve the currently displayed text.
      #
      # @return [String] The currently displayed text.
      #
      def getText
        String.from_java_bytes __getText
      end

      # This method is used to obtain the currently selected text.
      #
      # @return [String, nil] The currently selected text, or +nil+ if the user
      #   has not made any selection.
      #
      def getSelectedText
        String.from_java_bytes __getSelectedText
      end

      # Install ourselves into the current +ITextEditor+ java class
      # @param [ITextEditor] editor
      #
      # @todo __persistent__?
      def self.implant(editor)
        unless editor.implanted? || editor.nil?
          pp [:implanting, editor, editor.class] if 
          editor.class.class_exec(editor) do |editor|
            a_methods = %w{
              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
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buby-1.5.0.pre1-java lib/buby/implants/text_editor.rb