Sha256: d6f683dcc4dcfd008b7eb48e5f3f8a56f05dddf2e2e708e04f96d7ab136fcd9a

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

module Redcar
  # This class is your plugin. Try adding new commands in here
  # and putting them in the menus.
  class MyPlugin
  
    # This method is run as Redcar is booting up.
    def self.menus
      # Here's how the plugin menus are drawn. Try adding more
      # items or sub_menus.
      Menu::Builder.build do
        sub_menu "Plugins" do
          sub_menu "My Plugin" do
            item "Hello World!", HelloWorldCommand
            item "Edit My Plugin", EditMyPluginCommand
          end
        end
      end
    end

    # Example command: showing a dialog box.
    class HelloWorldCommand < Redcar::Command
      def execute
        Application::Dialog.message_box("Hello World!")
      end
    end

    # Command to open a new window, make the project my_plugin
    # and open this file.
    class EditMyPluginCommand < Redcar::Command
      def execute
        # Open the project in a new window
        Project::Manager.open_project_for_path("plugins/my_plugin")
        
        # Create a new edittab
        tab  = Redcar.app.focussed_window.new_tab(Redcar::EditTab)
        
        # A FileMirror's job is to wrap up the file in an interface that the Document understands.
        mirror = Project::FileMirror.new(File.join(Redcar.root, "plugins", "my_plugin", "lib", "my_plugin.rb"))
        tab.edit_view.document.mirror = mirror

        # Make sure the tab is focussed and the user can't undo the insertion of the document text
        tab.edit_view.reset_undo
        tab.focus
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
redcar-0.3.8.4 plugins/my_plugin/lib/my_plugin.rb
redcar-0.3.8.3 plugins/my_plugin/lib/my_plugin.rb
redcar-0.3.8.2 plugins/my_plugin/lib/my_plugin.rb
redcar-0.3.8.1 plugins/my_plugin/lib/my_plugin.rb
redcar-0.3.8 plugins/my_plugin/lib/my_plugin.rb
redcar-0.3.7.1 plugins/my_plugin/lib/my_plugin.rb
redcar-0.3.7 plugins/my_plugin/lib/my_plugin.rb
redcar-0.3.6 plugins/my_plugin/lib/my_plugin.rb
redcar-0.3.5 plugins/my_plugin/lib/my_plugin.rb