Restore the --watcher command line option for backwards compat

It is now deprecated but not removed. And it now applies to all windows
not just initially created ones.
This commit is contained in:
Kovid Goyal 2021-09-29 14:18:55 +05:30
parent 166ea9deb9
commit 8be0dd0d8e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 38 additions and 15 deletions

View File

@ -18,11 +18,6 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Allow the user to supply a custom Python function to draw tab bar. See
:opt:`tab_bar_style`
- **Backward incompatibility**: The command line option ``--watcher`` has been
removed in favor of the :opt:`watcher` option in :file:`kitty.conf`. It can be set
from the command line as: ``kitty -o watcher=/path/to/watcher``. It has the
advantage of applying to all windows, not just the initially created ones.
- Add support for reporting mouse events with pixel co-ordinates using the
``SGR_PIXEL_PROTOCOL`` introduced in xterm 359
@ -69,6 +64,11 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
- Unicode input kitten: Implement scrolling when more results are found than
the available display space (:pull:`4068`)
- The command line option ``--watcher`` has been deprecated in favor of the
:opt:`watcher` option in :file:`kitty.conf`. It has the advantage of
applying to all windows, not just the initially created ones. Note that
``--watcher`` now also applies to all windows, not just initially created ones.
0.23.1 [2021-08-17]
----------------------

View File

@ -711,6 +711,10 @@ type=bool-set
Print out information about the selection of fallback fonts for characters not present in the main font.
--watcher
This option is deprecated in favor of the :opt:`watcher` option in kitty.conf and should not be used.
--execute -e
type=bool-set
!

View File

@ -339,6 +339,10 @@ def _main() -> None:
opts = create_opts(cli_opts, accumulate_bad_lines=bad_lines)
init_glfw(opts, cli_opts.debug_keyboard, cli_opts.debug_rendering)
setup_environment(opts, cli_opts)
if cli_opts.watcher:
from .window import global_watchers
global_watchers.set_extra(cli_opts.watcher)
log_error('The --watcher command line option has beed deprecated infavor of using the watcher option in kitty.conf')
try:
with setup_profiling(cli_opts):
# Avoid needing to launch threads to reap zombies

View File

@ -13,7 +13,7 @@ from gettext import gettext as _
from itertools import chain
from typing import (
TYPE_CHECKING, Any, Callable, Deque, Dict, Iterable, List, NamedTuple,
Optional, Pattern, Sequence, Tuple, Union, cast
Optional, Pattern, Sequence, Tuple, Union
)
from .child import ProcessDesc
@ -315,15 +315,30 @@ class EdgeWidths:
return {'left': self.left, 'right': self.right, 'top': self.top, 'bottom': self.bottom}
def global_watchers() -> Watchers:
spec = get_options().watcher
if getattr(global_watchers, 'options_spec', None) == spec:
return cast(Watchers, getattr(global_watchers, 'ans'))
from .launch import load_watch_modules
ans = load_watch_modules(spec) or Watchers()
setattr(global_watchers, 'ans', ans)
setattr(global_watchers, 'options_spec', spec)
return ans
class GlobalWatchers:
def __init__(self) -> None:
self.options_spec: Optional[Dict[str, str]] = None
self.ans = Watchers()
self.extra = ''
def __call__(self) -> Watchers:
spec = get_options().watcher
if spec == self.options_spec:
return self.ans
from .launch import load_watch_modules
if self.extra:
spec = spec.copy()
spec[self.extra] = self.extra
self.ans = load_watch_modules(spec.keys()) or self.ans
self.options_spec = spec.copy()
return self.ans
def set_extra(self, extra: str) -> None:
self.extra = extra
global_watchers = GlobalWatchers()
class Window: