Example #1
0
 def is_visible(self):
     """Returns true if the current file is an M-AT file."""
     try:
         return EntitySelector.get_selector_for_view(
             self.view).enable_add_doc()
     except AttributeError:
         return False
Example #2
0
 def is_enabled(self):
     """Returns True if a DocFinder is assigned to the view."""
     try:
         return EntitySelector.get_selector_for_view(
             self.view).enable_doc_link()
     except AttributeError:
         return False
Example #3
0
 def run(self, edit):
     """Calls the show method of the DocFinder assigned to the view."""
     try:
         s = EntitySelector.get_selector_for_view(self.view)
         if s.enable_add_doc():
             s.add_doc(edit)
     except AttributeError:
         pass
Example #4
0
 def description(self):
     """Returns the description for the DocFinder assigned to the view."""
     try:
         es = EntitySelector.get_selector_for_view(self.view)
         if es.enable_add_doc():
             return es.add_doc_description()
     except AttributeError:
         pass
     return 'Add Doc'
Example #5
0
    def run(self, edit, highlighter):
        """Calls the show method of the DocFinder assigned to the view."""
        c = PreemptiveHighlight.get_preemptive_highlighter(highlighter)
        if c is not None:
            ps = c.get_preemptive_highlight_selection(self.view)
            if not ps:
                sublime.status_message('No regions to highlight')
                return

            # Copy current selection, then replace with preemptive selection
            current_selection = self.copy_current_selection()
            self.view.sel().clear()
            self.view.sel().add_all(ps)

            # Get current selector
            current_selector = EntitySelector.get_selector_for_view(self.view)

            # Determine if the highlighter should be enabled
            enabled = c.enable_for_selection(self.view)
            if not enabled:
                sublime.status_message('No regions to highlight')
                self.view.sel().clear()
                self.view.sel().add_all(current_selection)
                return

            # Create the highlighter and highlight
            preemptive_highlighter = c(self.view, **enabled)
            preemptive_highlighter.highlight()

            # Restore the current selection
            self.view.sel().clear()
            self.view.sel().add_all(current_selection)

            # If there were no highlighted regions, remove the highlight
            if not preemptive_highlighter.highlight_regions:
                sublime.status_message('No regions to highlight')
                preemptive_highlighter.remove_highlighter_from_view()

            # Restore the current selector
            if current_selector is None:
                EntitySelector.update_selector_for_view(self.view, None)
            else:
                current_selector.__class__.update_selector_for_view(
                    self.view, current_selector)
Example #6
0
 def is_enabled(self):
     """Returns True if a DocFinder is assigned to the view."""
     try:
         s = EntitySelector.get_selector_for_view(self.view)
         if hasattr(s, 'has_doc'):
             return not s.has_doc()
         else:
             return True
     except AttributeError:
         return False
Example #7
0
    def is_visible(self):
        """Returns true if the current file is an M-AT file."""
        try:
            for s in EntitySelector.get_possible_selectors_for_view(self.view):
                if DocLink in s.__mro__:
                    return True
        except AttributeError:
            pass

        return False
Example #8
0
 def is_enabled(self, cmd):
     """Returns True if a Highlighter is assigned to the view."""
     if cmd == Highlight.HIGHLIGHT_COMMAND:
         try:
             return EntitySelector.get_selector_for_view(
                 self.view).enable_highlight()
         except AttributeError:
             return False
     elif Highlight.get_highlighter_for_view(self.view) is None:
         return False
     else:
         return True
Example #9
0
 def description(self, cmd):
     """Returns the description for the DocFinder assigned to the view."""
     if cmd == Highlight.HIGHLIGHT_COMMAND:
         try:
             return EntitySelector.get_selector_for_view(
                 self.view).highlight_description(cmd)
         except AttributeError:
             return 'Highlight'
     else:
         hl = Highlight.get_highlighter_for_view(self.view)
         if hl is None:
             return 'Highlight'
         return hl.highlight_description(cmd)
Example #10
0
 def is_visible(self, cmd):
     """Returns true if the current file is an M-AT file."""
     if cmd == Highlight.HIGHLIGHT_COMMAND:
         try:
             for s in EntitySelector.get_possible_selectors_for_view(
                     self.view):
                 if Highlight in s.__mro__:
                     return True
         except AttributeError:
             pass
         return False
     elif Highlight.get_highlighter_for_view(self.view) is None:
         return False
     else:
         return True
Example #11
0
 def run(self, edit, cmd):
     """Calls the show method of the DocFinder assigned to the view."""
     if cmd == Highlight.HIGHLIGHT_COMMAND:
         try:
             s = EntitySelector.get_selector_for_view(self.view)
             if s.enable_highlight():
                 s.highlight()
         except AttributeError:
             pass
     else:
         hl = Highlight.get_highlighter_for_view(self.view)
         if hl is None:
             pass
         elif cmd == Highlight.FORWARD_COMMAND:
             hl.move_to_highlight(forward=True)
         elif cmd == Highlight.BACKWARD_COMMAND:
             hl.move_to_highlight(forward=False)
         elif cmd == Highlight.CLEAR_COMMAND:
             hl.remove_highlighter_from_view()
         elif cmd == Highlight.SELECT_ALL_COMMAND:
             hl.select_all_highlights()
         elif cmd == Highlight.SHOW_ALL_COMMAND:
             self.show_all(hl)
Example #12
0
 def on_activated_async(self, view):
     # logger.debug('Running on_activated')
     EntitySelector.match_entity(view)
Example #13
0
 def on_selection_modified_async(self, view):
     # logger.debug('Running on_modified')
     EntitySelector.match_entity(view)