Skip to content

Commit bfefbb9

Browse files
committed
feat!(Window): Set option flags
1 parent 64658ce commit bfefbb9

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/libtmux/window.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,18 @@ def select_layout(self, layout: str | None = None) -> Window:
436436

437437
return self
438438

439-
def set_window_option(self, option: str, value: int | str) -> Window:
439+
def set_window_option(
440+
self,
441+
option: str,
442+
value: int | str,
443+
format: bool | None = None,
444+
unset: bool | None = None,
445+
unset_panes: bool | None = None,
446+
prevent_overwrite: bool | None = None,
447+
suppress_warnings: bool | None = None,
448+
append: bool | None = None,
449+
g: bool | None = None,
450+
) -> Window:
440451
"""Set option for tmux window.
441452
442453
Wraps ``$ tmux set-window-option <option> <value>``.
@@ -454,15 +465,45 @@ def set_window_option(self, option: str, value: int | str) -> Window:
454465
:exc:`exc.OptionError`, :exc:`exc.UnknownOption`,
455466
:exc:`exc.InvalidOption`, :exc:`exc.AmbiguousOption`
456467
"""
468+
flags: list[str] = []
457469
if isinstance(value, bool) and value:
458470
value = "on"
459471
elif isinstance(value, bool) and not value:
460472
value = "off"
461473

474+
if unset is not None and unset:
475+
assert isinstance(unset, bool)
476+
flags.append("-u")
477+
478+
if unset_panes is not None and unset_panes:
479+
assert isinstance(unset_panes, bool)
480+
flags.append("-U")
481+
482+
if format is not None and format:
483+
assert isinstance(format, bool)
484+
flags.append("-F")
485+
486+
if prevent_overwrite is not None and prevent_overwrite:
487+
assert isinstance(prevent_overwrite, bool)
488+
flags.append("-o")
489+
490+
if suppress_warnings is not None and suppress_warnings:
491+
assert isinstance(suppress_warnings, bool)
492+
flags.append("-q")
493+
494+
if append is not None and append:
495+
assert isinstance(append, bool)
496+
flags.append("-a")
497+
498+
if g is not None and g:
499+
assert isinstance(g, bool)
500+
flags.append("-g")
501+
462502
cmd = self.cmd(
463503
"set-window-option",
464504
option,
465505
value,
506+
*flags,
466507
)
467508

468509
if isinstance(cmd.stderr, list) and len(cmd.stderr):

0 commit comments

Comments
 (0)