plugins/edit_view/lib/edit_view.rb in redcar-0.3.3 vs plugins/edit_view/lib/edit_view.rb in redcar-0.3.4

- old
+ new

@@ -1,8 +1,9 @@ require "edit_view/actions/arrow_keys" require "edit_view/actions/deletion" +require "edit_view/actions/esc" require "edit_view/actions/tab" require "edit_view/command" require "edit_view/document" require "edit_view/document/command" require "edit_view/document/controller" @@ -68,10 +69,14 @@ def self.delete_handlers [Actions::DeleteHandler] end + def self.esc_handlers + [Actions::EscapeHandler] + end + def self.all_tab_handlers all_handlers(:tab) end def self.all_esc_handlers @@ -93,11 +98,12 @@ def self.all_backspace_handlers all_handlers(:backspace) end def handle_key(handlers, modifiers) - handlers.detect do |h| + sorted_handlers = handlers.sort_by {|h| (h.respond_to?(:priority) and h.priority) || 0 }.reverse + sorted_handlers.detect do |h| begin h.handle(self, modifiers) rescue => e puts "*** Error in key handler: #{e.class} #{e.message}" puts e.backtrace.map {|l| " - " + l } @@ -280,8 +286,11 @@ self.grammar = data[:grammar] document.text = data[:contents] self.cursor_offset = data[:cursor_offset] end + def delay_parsing + controller.delay_parsing { yield } + end end end