diff --git a/poetry.lock b/poetry.lock index 950dd69f63..42f1921ebd 100644 --- a/poetry.lock +++ b/poetry.lock @@ -391,11 +391,15 @@ name = "libtmux" version = "0.37.0" description = "Typed library that provides an ORM wrapper for tmux, a terminal multiplexer." optional = false -python-versions = "<4.0,>=3.8" -files = [ - {file = "libtmux-0.37.0-py3-none-any.whl", hash = "sha256:7e8cbab30b033d132b6fca5dddb575bb7f6a1fd802328e7174f9b49023556376"}, - {file = "libtmux-0.37.0.tar.gz", hash = "sha256:21955c5dce6332db41abad5e26ae8c4062ef2b9a89099bd57a36f52be1d5270f"}, -] +python-versions = "^3.8" +files = [] +develop = false + +[package.source] +type = "git" +url = "https://github.com/tmux-python/libtmux.git" +reference = "improved-options" +resolved_reference = "d67070df29bb5a03e2bbf86b38b5937b47268288" [[package]] name = "linkify-it-py" @@ -1428,4 +1432,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "33fa6932973c2bfce8acdc57fcb1a5f2fef9692925f3b424b9d89bff5aacd57b" +content-hash = "e38e7f4736a315c47fc72a1c5bd5e4021a4ccadffb6516d4d641896bc38bd801" diff --git a/pyproject.toml b/pyproject.toml index c7532798af..5d3b513c35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -47,7 +47,7 @@ tmuxp = 'tmuxp:cli.cli' [tool.poetry.dependencies] python = "^3.8" -libtmux = "~0.37.0" +libtmux = {git = "https://github.com/tmux-python/libtmux.git", rev = "improved-options"} colorama = ">=0.3.9" PyYAML = "^6.0" diff --git a/src/tmuxp/workspace/builder.py b/src/tmuxp/workspace/builder.py index 0b341dd58c..e9c35c5089 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