Skip to content

Commit f2ea13e

Browse files
committed
feat!(Window): Set option flags
1 parent dccbb68 commit f2ea13e

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
@@ -387,7 +387,18 @@ def select_layout(self, layout: str | None = None) -> Window:
387387

388388
return self
389389

390-
def set_window_option(self, option: str, value: int | str) -> Window:
390+
def set_window_option(
391+
self,
392+
option: str,
393+
value: int | str,
394+
format: bool | None = None,
395+
unset: bool | None = None,
396+
unset_panes: bool | None = None,
397+
prevent_overwrite: bool | None = None,
398+
suppress_warnings: bool | None = None,
399+
append: bool | None = None,
400+
g: bool | None = None,
401+
) -> Window:
391402
"""Set option for tmux window.
392403
393404
Wraps ``$ tmux set-window-option <option> <value>``.
@@ -405,15 +416,45 @@ def set_window_option(self, option: str, value: int | str) -> Window:
405416
:exc:`exc.OptionError`, :exc:`exc.UnknownOption`,
406417
:exc:`exc.InvalidOption`, :exc:`exc.AmbiguousOption`
407418
"""
419+
flags: list[str] = []
408420
if isinstance(value, bool) and value:
409421
value = "on"
410422
elif isinstance(value, bool) and not value:
411423
value = "off"
412424

425+
if unset is not None and unset:
426+
assert isinstance(unset, bool)
427+
flags.append("-u")
428+
429+
if unset_panes is not None and unset_panes:
430+
assert isinstance(unset_panes, bool)
431+
flags.append("-U")
432+
433+
if format is not None and format:
434+
assert isinstance(format, bool)
435+
flags.append("-F")
436+
437+
if prevent_overwrite is not None and prevent_overwrite:
438+
assert isinstance(prevent_overwrite, bool)
439+
flags.append("-o")
440+
441+
if suppress_warnings is not None and suppress_warnings:
442+
assert isinstance(suppress_warnings, bool)
443+
flags.append("-q")
444+
445+
if append is not None and append:
446+
assert isinstance(append, bool)
447+
flags.append("-a")
448+
449+
if g is not None and g:
450+
assert isinstance(g, bool)
451+
flags.append("-g")
452+
413453
cmd = self.cmd(
414454
"set-window-option",
415455
option,
416456
value,
457+
*flags,
417458
)
418459

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

0 commit comments

Comments
 (0)