diff --git a/pyproject.toml b/pyproject.toml index 953a65175e..b26e53c689 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -88,6 +88,9 @@ dev-dependencies = [ "types-PyYAML", ] +[tool.uv.sources] +libtmux = { git = "https://github.com/tmux-python/libtmux.git", branch = "improved-options" } + [dependency-groups] docs = [ "aafigure", diff --git a/src/tmuxp/workspace/builder.py b/src/tmuxp/workspace/builder.py index fa4f8330f2..e2940d11d6 100644 --- a/src/tmuxp/workspace/builder.py +++ b/src/tmuxp/workspace/builder.py @@ -349,7 +349,7 @@ def iter_create_windows( Generator yielding :class:`libtmux.Window` by iterating through ``session_config['windows']``. - Applies ``window_options`` to window. + Applies ``options`` to window. Parameters ---------- @@ -433,7 +433,7 @@ def iter_create_windows( dict, ): for key, val in window_config["options"].items(): - window.set_window_option(key, val) + window.set_option(key, val) if window_config.get("focus"): window.select() @@ -464,7 +464,7 @@ def iter_create_panes( """ assert isinstance(window, Window) - pane_base_index_str = window.show_window_option("pane-base-index", g=True) + pane_base_index_str = window._show_option("pane-base-index", _global=True) assert pane_base_index_str is not None pane_base_index = int(pane_base_index_str) @@ -585,7 +585,7 @@ def config_after_window( dict, ): for key, val in window_config["options_after"].items(): - window.set_window_option(key, val) + window.set_option(key, val) def find_current_attached_session(self) -> Session: """Return current attached session.""" diff --git a/src/tmuxp/workspace/freezer.py b/src/tmuxp/workspace/freezer.py index e782ccec2c..5923fc9395 100644 --- a/src/tmuxp/workspace/freezer.py +++ b/src/tmuxp/workspace/freezer.py @@ -70,7 +70,7 @@ def freeze(session: Session) -> t.Dict[str, t.Any]: for window in session.windows: window_config: t.Dict[str, t.Any] = { - "options": window.show_window_options(), + "options": window._show_options(), "window_name": window.name, "layout": window.window_layout, "panes": [], diff --git a/tests/workspace/test_builder.py b/tests/workspace/test_builder.py index 801b462d5a..0942ebcabe 100644 --- a/tests/workspace/test_builder.py +++ b/tests/workspace/test_builder.py @@ -47,9 +47,8 @@ def test_split_windows(session: Session) -> None: window_count = len(session.windows) # current window count assert len(session.windows) == window_count for w, wconf in builder.iter_create_windows(session): - for p in builder.iter_create_panes(w, wconf): + for _ in builder.iter_create_panes(w, wconf): w.select_layout("tiled") # fix glitch with pane size - p = p assert len(session.windows) == window_count assert isinstance(w, Window) @@ -68,15 +67,14 @@ def test_split_windows_three_pane(session: Session) -> None: window_count = len(session.windows) # current window count assert len(session.windows) == window_count for w, wconf in builder.iter_create_windows(session): - for p in builder.iter_create_panes(w, wconf): + for _ in builder.iter_create_panes(w, wconf): w.select_layout("tiled") # fix glitch with pane size - p = p assert len(session.windows) == window_count assert isinstance(w, Window) assert len(session.windows) == window_count window_count += 1 - w.set_window_option("main-pane-height", 50) + w.set_option("main-pane-height", 50) w.select_layout(wconf["layout"]) @@ -94,9 +92,9 @@ def test_focus_pane_index(session: Session) -> None: assert session.active_window.name == "focused window" - _pane_base_index = session.active_window.show_window_option( + _pane_base_index = session.active_window._show_option( "pane-base-index", - g=True, + _global=True, ) assert isinstance(_pane_base_index, int) pane_base_index = int(_pane_base_index) @@ -230,11 +228,11 @@ def test_session_options(session: Session) -> None: builder = WorkspaceBuilder(session_config=workspace, server=session.server) builder.build(session=session) - _default_shell = session.show_option("default-shell") + _default_shell = session._show_option("default-shell") assert isinstance(_default_shell, str) assert "/bin/sh" in _default_shell - _default_command = session.show_option("default-command") + _default_command = session._show_option("default-command") assert isinstance(_default_command, str) assert "/bin/sh" in _default_command @@ -249,10 +247,10 @@ def test_global_options(session: Session) -> None: builder = WorkspaceBuilder(session_config=workspace, server=session.server) builder.build(session=session) - _status_position = session.show_option("status-position", _global=True) + _status_position = session._show_option("status-position", _global=True) assert isinstance(_status_position, str) assert "top" in _status_position - assert session.show_option("repeat-time", _global=True) == 493 + assert session._show_option("repeat-time", _global=True) == 493 def test_global_session_env_options( @@ -275,11 +273,11 @@ def test_global_session_env_options( builder = WorkspaceBuilder(session_config=workspace, server=session.server) builder.build(session=session) - _visual_silence = session.show_option("visual-silence", _global=True) - assert isinstance(_visual_silence, str) - assert visual_silence in _visual_silence - assert repeat_time == session.show_option("repeat-time") - assert main_pane_height == session.active_window.show_window_option( + _visual_silence = session._show_option("visual-silence", _global=True) + assert isinstance(_visual_silence, bool) + assert _visual_silence is True + assert repeat_time == session._show_option("repeat-time") + assert main_pane_height == session.active_window._show_option( "main-pane-height", ) @@ -301,14 +299,13 @@ def test_window_options( window_count = len(session.windows) # current window count assert len(session.windows) == window_count for w, wconf in builder.iter_create_windows(session): - for p in builder.iter_create_panes(w, wconf): + for _ in builder.iter_create_panes(w, wconf): w.select_layout("tiled") # fix glitch with pane size - p = p assert len(session.windows) == window_count assert isinstance(w, Window) - assert w.show_window_option("main-pane-height") == 5 + assert w._show_option("main-pane-height") == 5 if has_gte_version("2.3"): - assert w.show_window_option("pane-border-format") == " #P " + assert w._show_option("pane-border-format") == " #P " assert len(session.windows) == window_count window_count += 1 @@ -513,7 +510,7 @@ def check_window_name_mismatch() -> bool: assert retry_until(check_window_name_mismatch, 5, interval=0.25) def check_window_name_match() -> bool: - assert w.show_window_option("automatic-rename") == "on" + assert w._show_option("automatic-rename") return w.name in { pathlib.Path(os.getenv("SHELL", "bash")).name, portable_command, @@ -714,8 +711,10 @@ def test_pane_order(session: Session) -> None: window_count += 1 for w in session.windows: - pane_base_index = w.show_window_option("pane-base-index", g=True) + pane_base_index = w._show_option("pane-base-index", _global=True) + assert isinstance(pane_base_index, int) for p_index, p in enumerate(w.panes, start=pane_base_index): + assert p.index is not None assert int(p_index) == int(p.index) # pane-base-index start at base-index, pane_paths always start diff --git a/uv.lock b/uv.lock index 726a78bf9f..7a3a84eb6c 100644 --- a/uv.lock +++ b/uv.lock @@ -364,12 +364,8 @@ wheels = [ [[package]] name = "libtmux" -version = "0.39.0" -source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/72/c4/e35564de320c876c6c370b8b9303a31ca2fcd632051aa8ac14a2d4700b68/libtmux-0.39.0.tar.gz", hash = "sha256:59346aeef3c0d6017f3bc5e23248d43cdf50f32b775b9cb5d9ff5e2e5f3059f4", size = 314810 } -wheels = [ - { url = "https://files.pythonhosted.org/packages/82/f8/afdcf3715c7388962c1eef39c7ba415a170f6772808ad83f60f8fdfdc6d0/libtmux-0.39.0-py3-none-any.whl", hash = "sha256:6b6e338be2727f67aa6b7eb67fa134368fa3c3eac5df27565396467692891c1e", size = 56219 }, -] +version = "0.38.1" +source = { git = "https://github.com/tmux-python/libtmux.git?branch=improved-options#5415d2595dde9bea2e6a0526e8522d793b94a1aa" } [[package]] name = "linkify-it-py" @@ -1121,7 +1117,7 @@ testing = [ [package.metadata] requires-dist = [ { name = "colorama", specifier = ">=0.3.9" }, - { name = "libtmux", specifier = "~=0.39.0" }, + { name = "libtmux", git = "https://github.com/tmux-python/libtmux.git?branch=improved-options" }, { name = "pyyaml", specifier = ">=6.0" }, ]