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
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 - Allow the user to supply a custom Python function to draw tab bar. See
:opt:`tab_bar_style` :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 - Add support for reporting mouse events with pixel co-ordinates using the
``SGR_PIXEL_PROTOCOL`` introduced in xterm 359 ``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 - Unicode input kitten: Implement scrolling when more results are found than
the available display space (:pull:`4068`) 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] 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. 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 --execute -e
type=bool-set type=bool-set
! !

View File

@@ -339,6 +339,10 @@ def _main() -> None:
opts = create_opts(cli_opts, accumulate_bad_lines=bad_lines) opts = create_opts(cli_opts, accumulate_bad_lines=bad_lines)
init_glfw(opts, cli_opts.debug_keyboard, cli_opts.debug_rendering) init_glfw(opts, cli_opts.debug_keyboard, cli_opts.debug_rendering)
setup_environment(opts, cli_opts) 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: try:
with setup_profiling(cli_opts): with setup_profiling(cli_opts):
# Avoid needing to launch threads to reap zombies # Avoid needing to launch threads to reap zombies

View File

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