Esempio n. 1
0
def update_highlighting(event):
    if not get_workbench().ready:
        # don't slow down loading process
        return

    if jedi_utils.get_version_tuple() < (0, 9):
        logging.warning("Jedi version is too old. Disabling name highlighter")
        return

    global tree
    if not tree:
        # using lazy importing to speed up Thonny loading
        tree = jedi_utils.import_python_tree()

    assert isinstance(event.widget, tk.Text)
    text = event.widget

    if not hasattr(text, "name_highlighter"):
        text.name_highlighter = VariablesHighlighter(text)
        # Alternatives:
        # NB! usages() is too slow when used on library names
        # text.name_highlighter = CombinedHighlighter(text)
        # text.name_highlighter = UsagesHighlighter(text)

    text.name_highlighter.schedule_update()
Esempio n. 2
0
def load_plugin():
    if jedi_utils.get_version_tuple() < (0, 9):
        logging.warning("Jedi version is too old. Disabling locals marker")
        return

    wb = get_workbench()
    wb.set_default("view.locals_highlighting", False)
    wb.bind_class("CodeViewText", "<<TextChange>>", update_highlighting, True)
    wb.bind("<<UpdateAppearance>>", update_highlighting, True)
Esempio n. 3
0
def load_plugin():
    if jedi_utils.get_version_tuple() < (0, 9):
        logging.warning("Jedi version is too old. Disabling name highlighter")
        return

    wb = get_workbench()  # type:Workbench
    wb.set_default("view.name_highlighting", True)
    wb.bind_class("CodeViewText", "<<CursorMove>>", update_highlighting, True)
    wb.bind_class("CodeViewText", "<<TextChange>>", update_highlighting, True)
    wb.bind("<<UpdateAppearance>>", update_highlighting, True)
Esempio n. 4
0
def update_highlighting(event):
    if not get_workbench().ready:
        # don't slow down loading process
        return

    if jedi_utils.get_version_tuple() < (0, 9):
        logging.warning("Jedi version is too old. Disabling locals marker")
        return

    assert isinstance(event.widget, tk.Text)
    text = event.widget

    if not hasattr(text, "local_highlighter"):
        text.local_highlighter = LocalsHighlighter(text)

    text.local_highlighter.schedule_update()