Sublime Forum

Sublime_lib 1.4 — ActivityIndicator, more enums, and better performance

#1

(Started a new thread because the old one refers to an old version in the title and can’t be edited.)

sublime_lib is a Package Control dependency providing a variety of convenience features for other packages to use. Version 1.4 is now available with a number of new features and bug fixes. Highlights:

ActivityIndicator

A high-quality implementation of the spinner that many packages use:

import sublime_plugin
from sublime_lib import ActivityIndicator

class ExampleCommand(sublime_plugin.WindowCommand):
    def run(self):
        with ActivityIndicator(self.window, 'Example Command'):
            do_expensive_operation()

This will show an animated activity indicator in the window status bar while do_expensive_operation() runs:

Example Command [=         ]
Example Command [ =        ]
Example Command [  =       ]
etc.

(Remember, always run long-running operations in the async thread or in another thread to avoid freezing the interface.)

QueryContextOperator

An enum with an apply method to simplify on_query_context implementations:

import sublime_plugin
from sublime_lib.flags import QueryContextOperator

class MyListener(sublime_plugin.EventListener):
    def on_query_context(self, view, key, operator, operand, match_all):
        if key == "my_example_key":
            value = get_some_value()
            return QueryContextOperator(operator).apply(value, operand)
        else:
            return None

v1.4.0 release notes

Complete API reference

3 Likes