Sha256: 26ffe51b5d7314f6fb160efd9b4b87053c0beffed6cc2db3e22f913f0b640d91

Contents?: true

Size: 1.61 KB

Versions: 14

Compression:

Stored size: 1.61 KB

Contents

require 'repl/internal_mirror'

module Redcar
  class REPL
    def self.sensitivities
      [
        Sensitivity.new(:open_repl_tab, Redcar.app, false, [:tab_focussed]) do |tab|
          tab and 
          tab.is_a?(EditTab) and 
          tab.edit_view.document.mirror.is_a?(REPL::InternalMirror)
        end
      ]
    end

    def self.keymaps
      osx = Keymap.build("main", :osx) do
        link "Cmd+Shift+M", REPL::OpenInternalREPL
        link "Cmd+M",       REPL::CommitREPL
      end
      
      linwin = Keymap.build("main", [:linux, :windows]) do
        link "Ctrl+Shift+M", REPL::OpenInternalREPL
        link "Ctrl+M",       REPL::CommitREPL
      end
      
      [linwin, osx]
    end
    
    def self.menus
      Menu::Builder.build do
        sub_menu "Plugins" do
          sub_menu "REPL" do
            item "Open",    REPL::OpenInternalREPL
            item "Execute", REPL::CommitREPL
          end
        end
      end
    end
    
    class OpenInternalREPL < Command
      
      def execute
        tab = win.new_tab(Redcar::EditTab)
        edit_view = tab.edit_view
        edit_view.document.mirror = REPL::InternalMirror.new
        edit_view.cursor_offset = edit_view.document.length
        tab.focus
      end
    end
    
    class ReplCommand < Command
      sensitize :open_repl_tab
    end
    
    class CommitREPL < ReplCommand
      
      def execute
        edit_view = win.focussed_notebook.focussed_tab.edit_view
        edit_view.document.save!
        edit_view.cursor_offset = edit_view.document.length
        edit_view.scroll_to_line(edit_view.document.line_count)
      end
    end
  end
end


Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
redcar-0.3.8.4 plugins/repl/lib/repl.rb
redcar-0.3.8.3 plugins/repl/lib/repl.rb
redcar-0.3.8.2 plugins/repl/lib/repl.rb
redcar-0.3.8.1 plugins/repl/lib/repl.rb
redcar-0.3.8 plugins/repl/lib/repl.rb
redcar-0.3.7.1 plugins/repl/lib/repl.rb
redcar-0.3.7 plugins/repl/lib/repl.rb
redcar-0.3.6 plugins/repl/lib/repl.rb
redcar-0.3.5 plugins/repl/lib/repl.rb
redcar-0.3.4.3 plugins/repl/lib/repl.rb
redcar-0.3.4.2 plugins/repl/lib/repl.rb
redcar-0.3.4.1 plugins/repl/lib/repl.rb
redcar-0.3.4 plugins/repl/lib/repl.rb
redcar-0.3.3 plugins/repl/lib/repl.rb