Skip to content

Commit 345311a

Browse files
committed
feat!(Window): Set option flags
1 parent eee721b commit 345311a

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/libtmux/window.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,15 @@ def select_layout(self, layout: t.Optional[str] = None) -> "Window":
327327

328328
return self
329329

330-
def set_window_option(self, option: str, value: t.Union[int, str]) -> "Window":
330+
def set_window_option(
331+
self,
332+
option: str,
333+
value: t.Union[int, str],
334+
format: t.Optional[bool] = None,
335+
unset: t.Optional[bool] = None,
336+
unset_panes: t.Optional[bool] = None,
337+
prevent_overwrite: t.Optional[bool] = None,
338+
) -> "Window":
331339
"""Set option for tmux window.
332340
333341
Wraps ``$ tmux set-window-option <option> <value>``.
@@ -345,16 +353,34 @@ def set_window_option(self, option: str, value: t.Union[int, str]) -> "Window":
345353
:exc:`exc.OptionError`, :exc:`exc.UnknownOption`,
346354
:exc:`exc.InvalidOption`, :exc:`exc.AmbiguousOption`
347355
"""
356+
flags: list[str] = []
348357
if isinstance(value, bool) and value:
349358
value = "on"
350359
elif isinstance(value, bool) and not value:
351360
value = "off"
352361

362+
if unset is not None and unset:
363+
assert isinstance(unset, bool)
364+
flags.append("-u")
365+
366+
if unset_panes is not None and unset_panes:
367+
assert isinstance(unset_panes, bool)
368+
flags.append("-U")
369+
370+
if format is not None and format:
371+
assert isinstance(format, bool)
372+
flags.append("-F")
373+
374+
if prevent_overwrite is not None and prevent_overwrite:
375+
assert isinstance(prevent_overwrite, bool)
376+
flags.append("-o")
377+
353378
cmd = self.cmd(
354379
"set-window-option",
355380
f"-t{self.session_id}:{self.window_index}",
356381
option,
357382
value,
383+
*flags,
358384
)
359385

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

0 commit comments

Comments
 (0)