sublime_plugin.ViewEventListener

ST3

A class that provides similar event handling to EventListener, but bound to a specific view. Provides class method-based filtering to control what views objects are created for.

The view is passed as a single parameter to the constructor. The default implementation makes the view available via self.view.



applies_to_primary_view_only ST3

ST3 applies_to_primary_view_only() # => bool

A @classmethod that should return a bool indicating if this class applies only to the primary view for a file. A view is considered primary if it is the only, or first, view into a file.



is_applicable ST3

ST3 is_applicable(settings) # => bool

A @classmethod that receives a Settings object and should return a bool indicating if this class applies to a view with those settings



on_activated ST3

ST3 on_activated() # => None

Called when a view gains input focus.



on_activated_async ST3

ST3 on_activated_async() # => None

Called when the view gains input focus. Runs in a separate thread, and does not block the application.



on_deactivated ST3

ST3 on_deactivated() # => None

Called when the view loses input focus.



on_deactivated_async ST3

ST3 on_deactivated_async() # => None

Called when the view loses input focus. Runs in a separate thread, and does not block the application.



on_hover ST3

ST3 on_hover(point, hover_zone) # => None

Called when the user's mouse hovers over the view for a short period.

point is the closest point in the view to the mouse location. The mouse may not actually be located adjacent based on the value of hover_zone:

  • sublime.HOVER_TEXT: When the mouse is hovered over text.
  • sublime.HOVER_GUTTER: When the mouse is hovered over the gutter.
  • sublime.HOVER_MARGIN: When the mouse is hovered in whitespace to the right of a line.



on_modified ST3

ST3 on_modified() # => None

Called after changes have been made to the view.



on_modified_async ST3

ST3 on_modified_async() # => None

Called after changes have been made to the view. Runs in a separate thread, and does not block the application.



on_query_completions ST3

ST3 on_query_completions(prefix, locations) # => list, tuple or None

Called whenever completions are to be presented to the user. The prefix is a unicode string of the text to complete.

locations is a list of points. Since this method is called for all completions no matter the syntax, self.view.match_selector(point, relevant_scope) should be called to determine if the point is relevant.

The return value must be one of the following formats:

  • None: no completions are provided

    return None
  • A list of 2-element lists/tuples. The first element is a unicode string of the completion trigger, the second is the unicode replacement text.

    return [["me1", "method1()"], ["me2", "method2()"]]

    The trigger may contain a tab character (\t) followed by a hint to display in the right-hand side of the completion box.

    return [
        ["me1\tmethod", "method1()"],
        ["me2\tmethod", "method2()"]
    ]

    The replacement text may contain dollar-numeric fields such as a snippet does, e.g. $0, $1.

    return [
        ["fn", "def ${1:name}($2) { $0 }"],
        ["for", "for ($1; $2; $3) { $0 }"]
    ]
  • A 2-element tuple with the first element being the list format documented above, and the second element being bit flags from the following list:

    • sublime.INHIBIT_WORD_COMPLETIONS: prevent Sublime Text from showing completions based on the contents of the view
    • sublime.INHIBIT_EXPLICIT_COMPLETIONS: prevent Sublime Text from showing completions based on .sublime-completions files

    return (
        [
            ["me1", "method1()"],
            ["me2", "method2()"]
        ],
        sublime.INHIBIT_WORD_COMPLETIONS | sublime.INHIBIT_EXPLICIT_COMPLETIONS
    )



on_query_context ST3

ST3 on_query_context(key, operator, operand, match_all) # => bool or None

Called when determining to trigger a key binding with the given context key. If the plugin knows how to respond to the context, it should return either True of False. If the context is unknown, it should return None.

operator is one of:

  • sublime.OP_EQUAL: Is the value of the context equal to the operand?
  • sublime.OP_NOT_EQUAL: Is the value of the context not equal to the operand?
  • sublime.OP_REGEX_MATCH: Does the value of the context match the regex given in operand?
  • sublime.OP_NOT_REGEX_MATCH: Does the value of the context not match the regex given in operand?
  • sublime.OP_REGEX_CONTAINS: Does the value of the context contain a substring matching the regex given in operand?
  • sublime.OP_NOT_REGEX_CONTAINS: Does the value of the context not contain a substring matching the regex given in operand?

match_all should be used if the context relates to the selections: does every selection have to match (match_all == True), or is at least one matching enough (match_all == False)?



on_selection_modified ST3

ST3 on_selection_modified() # => None

Called after the selection has been modified in the view.



on_selection_modified_async ST3

ST3 on_selection_modified_async() # => None

Called after the selection has been modified in the view. Runs in a separate thread, and does not block the application.




Generated from the official documentation on Sat Oct 29 20:16:53 EEST 2016 by Leonid Shevtsov.