def on_new_tab(event): # TODO: autocomplete in other kinds of tabs too? tab = event.data_widget if isinstance(tab, tabs.FileTab): completer = _AutoCompleter(tab) utils.bind_tab_key(tab.textwidget, completer.on_tab, add=True) tab.textwidget.bind('<<CursorMoved>>', completer.reset, add=True)
def on_new_tab(event: utils.EventWithData) -> None: tab = event.data_widget() if not isinstance(tab, tabs.FileTab): return tab.settings.add_option('autocomplete_chars', [], type=List[str]) completer = AutoCompleter(tab) # no idea why backspace has to be bound separately utils.bind_with_data(tab.textwidget, '<Key>', completer.on_any_key, add=True) tab.textwidget.bind('<BackSpace>', completer.on_any_key, add=True) utils.bind_tab_key(tab.textwidget, completer.on_tab, add=True) tab.textwidget.bind('<Return>', completer.on_enter, add=True) tab.textwidget.bind('<Escape>', completer.on_escape, add=True) tab.textwidget.bind('<Prior>', completer.popup.on_page_up_down, add=True) tab.textwidget.bind('<Next>', completer.popup.on_page_up_down, add=True) tab.textwidget.bind('<Up>', completer.popup.on_arrow_key_up_down, add=True) tab.textwidget.bind('<Down>', completer.popup.on_arrow_key_up_down, add=True) completer.popup.treeview.bind('<Button-1>', (lambda event: completer._accept()), add=True) # avoid weird corner cases tab.winfo_toplevel().bind('<FocusOut>', (lambda event: completer._reject()), add=True) tab.textwidget.bind( # any mouse button '<Button>', (lambda event: completer._reject()), add=True) tab.bind('<Destroy>', (lambda event: completer.popup.toplevel.destroy()), add=True)
def on_new_tab(tab: tabs.Tab) -> None: if not isinstance(tab, tabs.FileTab): return tab.settings.add_option("autocomplete_chars", [], List[str]) completer = AutoCompleter(tab) # no idea why backspace has to be bound separately utils.bind_with_data(tab.textwidget, "<Key>", completer.on_any_key, add=True) tab.textwidget.bind("<BackSpace>", completer.on_any_key, add=True) utils.bind_tab_key(tab.textwidget, completer.on_tab, add=True) tab.textwidget.bind("<Return>", completer.on_enter, add=True) tab.textwidget.bind("<Escape>", completer.on_escape, add=True) tab.textwidget.bind("<Prior>", completer.popup.on_page_up_down, add=True) tab.textwidget.bind("<Next>", completer.popup.on_page_up_down, add=True) tab.textwidget.bind("<Up>", completer.popup.on_arrow_key_up_down, add=True) tab.textwidget.bind("<Down>", completer.popup.on_arrow_key_up_down, add=True) completer.popup.treeview.bind("<Button-1>", (lambda event: completer._accept()), add=True) # avoid weird corner cases tab.winfo_toplevel().bind("<FocusOut>", (lambda event: completer._reject()), add=True) tab.textwidget.bind( # any mouse button "<Button>", lambda event: completer._reject(), add=True, ) tab.bind("<Destroy>", (lambda event: completer.popup.toplevel.destroy()), add=True)
def on_new_tab(event): if isinstance(event.data_widget, tabs.FileTab): utils.bind_tab_key(event.data_widget.textwidget, on_tab, add=True)
def on_new_tab(event: utils.EventWithData) -> None: tab = event.data_widget() if isinstance(tab, tabs.FileTab): utils.bind_tab_key(tab.textwidget, on_tab_key, add=True)
def on_new_tab(tab: tabs.Tab) -> None: if isinstance(tab, tabs.FileTab): utils.bind_tab_key(tab.textwidget, on_tab_key, add=True)