Sha256: 32b3546c5293e3775f25b94990c3d8a07076788b8f1d6e7c843f11da18262984

Contents?: true

Size: 1.6 KB

Versions: 13

Compression:

Stored size: 1.6 KB

Contents

require "outline_view/commands"

module Redcar
  class OutlineView
    
    def self.menus
      Menu::Builder.build do
        sub_menu "View" do
          item "Current Document Outline", OutlineView::OpenOutlineViewCommand
        end
      end
    end
    
    def self.keymaps
      linwin = Keymap.build("main", [:linux, :windows]) do
        link "Ctrl+I", OutlineView::OpenOutlineViewCommand
      end
      osx = Keymap.build("main", [:osx]) do
        link "Cmd+I", OutlineView::OpenOutlineViewCommand
      end
      [linwin, osx]
    end
    
    class OutlineViewDialog < FilterListDialog
      include Redcar::Model
      include Redcar::Observable
      
      attr_accessor :document
      attr_accessor :last_list
      
      def initialize(document)
        self.controller = Redcar::OutlineViewSWT.new(self)
        @document = document
        @last_list = {}
      end
      
      def close
        super
      end
      
      def update_list(filter)
        file = Declarations::File.new(@document.path)
        file.add_tags_for_paths([@document.path])
        re = make_regex(filter)
        @last_list.clear
        result = {}
        file.tags.each do |name, _, match|
          if name =~ re
            @last_list[match] = name
            result[match] = {:name => name, :kind => Declarations.match_kind(@document.path, match)}
          end
        end
        result
      end
      
      def selected(match, closing=true)
        if @last_list
          DocumentSearch::FindNextRegex.new(Regexp.new(Regexp.quote(match)), true).run
          close if closing
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
redcar-0.6.1 plugins/outline_view/lib/outline_view.rb
redcar-0.6 plugins/outline_view/lib/outline_view.rb
redcar-0.6.1dev plugins/outline_view/lib/outline_view.rb
redcar-0.5.1 plugins/outline_view/lib/outline_view.rb
redcar-0.5 plugins/outline_view/lib/outline_view.rb
redcar-0.5.6dev plugins/outline_view/lib/outline_view.rb
redcar-0.5.5dev plugins/outline_view/lib/outline_view.rb
redcar-0.5.4dev plugins/outline_view/lib/outline_view.rb
redcar-0.5.3dev plugins/outline_view/lib/outline_view.rb
redcar-0.5.2dev plugins/outline_view/lib/outline_view.rb
redcar-0.5.1dev plugins/outline_view/lib/outline_view.rb
redcar-0.4.1 plugins/outline_view/lib/outline_view.rb
redcar-0.4 plugins/outline_view/lib/outline_view.rb