|
16 | 16 | from libtmux.constants import (
|
17 | 17 | RESIZE_ADJUSTMENT_DIRECTION_FLAG_MAP,
|
18 | 18 | ResizeAdjustmentDirection,
|
| 19 | + WindowDirection, |
19 | 20 | )
|
20 | 21 | from libtmux.neo import Obj, fetch_obj, fetch_objs
|
21 | 22 | from libtmux.pane import Pane
|
@@ -627,6 +628,65 @@ def move_window(
|
627 | 628 |
|
628 | 629 | return self
|
629 | 630 |
|
| 631 | + def new_window( |
| 632 | + self, |
| 633 | + window_name: t.Optional[str] = None, |
| 634 | + start_directory: None = None, |
| 635 | + attach: bool = False, |
| 636 | + window_index: str = "", |
| 637 | + window_shell: t.Optional[str] = None, |
| 638 | + environment: t.Optional[t.Dict[str, str]] = None, |
| 639 | + direction: t.Optional[WindowDirection] = None, |
| 640 | + ) -> "Window": |
| 641 | + """Create new window respective of current window's position. |
| 642 | +
|
| 643 | + See Also |
| 644 | + -------- |
| 645 | + :meth:`Session.new_window()` |
| 646 | +
|
| 647 | + Examples |
| 648 | + -------- |
| 649 | + .. :: |
| 650 | + >>> import pytest |
| 651 | + >>> from libtmux.common import has_lt_version |
| 652 | + >>> if has_lt_version('3.2'): |
| 653 | + ... pytest.skip('This doctest requires tmux 3.2 or newer') |
| 654 | + >>> window_initial = session.new_window(window_name='Example') |
| 655 | + >>> window_initial |
| 656 | + Window(@... 2:Example, Session($1 libtmux_...)) |
| 657 | + >>> window_initial.window_index |
| 658 | + '2' |
| 659 | +
|
| 660 | + >>> window_before = window_initial.new_window( |
| 661 | + ... window_name='Window before', direction=WindowDirection.Before) |
| 662 | + >>> window_initial.refresh() |
| 663 | + >>> window_before |
| 664 | + Window(@... 2:Window before, Session($1 libtmux_...)) |
| 665 | + >>> window_initial |
| 666 | + Window(@... 3:Example, Session($1 libtmux_...)) |
| 667 | +
|
| 668 | + >>> window_after = window_initial.new_window( |
| 669 | + ... window_name='Window after', direction=WindowDirection.After) |
| 670 | + >>> window_initial.refresh() |
| 671 | + >>> window_after.refresh() |
| 672 | + >>> window_after |
| 673 | + Window(@... 4:Window after, Session($1 libtmux_...)) |
| 674 | + >>> window_initial |
| 675 | + Window(@... 3:Example, Session($1 libtmux_...)) |
| 676 | + >>> window_before |
| 677 | + Window(@... 2:Window before, Session($1 libtmux_...)) |
| 678 | + """ |
| 679 | + return self.session.new_window( |
| 680 | + window_name=window_name, |
| 681 | + start_directory=start_directory, |
| 682 | + attach=attach, |
| 683 | + window_index=window_index, |
| 684 | + window_shell=window_shell, |
| 685 | + environment=environment, |
| 686 | + direction=direction, |
| 687 | + target_window=self.window_id, |
| 688 | + ) |
| 689 | + |
630 | 690 | #
|
631 | 691 | # Climbers
|
632 | 692 | #
|
|
0 commit comments