Two new event types for watchers

on_title_change and on_set_user_var
This commit is contained in:
Kovid Goyal
2023-10-19 07:54:33 +05:30
parent 4a463f7712
commit 6cfb451ec8
3 changed files with 28 additions and 2 deletions

View File

@@ -68,6 +68,8 @@ Detailed list of changes
- Fix a regression that broke ``kitten update-self`` (:iss:`6729`)
- Two new event types for :ref:`watchers <watchers>`, :code:`on_title_change` and :code:`on_set_user_var`
0.30.1 [2023-10-05]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -133,8 +133,17 @@ functions for the events you are interested in, for example:
def on_close(boss: Boss, window: Window, data: Dict[str, Any])-> None:
# called when window is closed, typically when the program running in
# it exits.
# it exits
def on_set_user_var(boss: Boss, window: Window, data: Dict[str, Any]) -> None:
# called when a "user variable" is set or deleted on a window. Here
# data will contain key and value
def on_title_change(boss: Boss, window: Window, data: Dict[str, Any]) -> None:
# called when the window title is changed on a window. Here
# data will contain title and from_child. from_child will be True
# when a title change was requested via escape code from the program
# running in the terminal
Every callback is passed a reference to the global ``Boss`` object as well as
the ``Window`` object the action is occurring on. The ``data`` object is a dict