Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting and Merging panes to/from tabs #1253

Closed
junkblocker opened this issue Oct 23, 2021 · 4 comments
Closed

Splitting and Merging panes to/from tabs #1253

junkblocker opened this issue Oct 23, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@junkblocker
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I'd like the tmux/screen like feature of being able to move a pane out into its own tab and the converse feature of being able to merge a different tab into a new pane in the current tab.

Describe the solution you'd like

An API that looks like

SplitPaneToNewTab
MergePaneFromTab

For reference, the tmux API looks like so

     join-pane [-bdfhv] [-l size] [-s src-pane] [-t dst-pane]
                   (alias: joinp)
             Like split-window, but instead of splitting dst-pane and creating a new pane, split it and move src-pane into the space.  This can be used to reverse break-pane.  The -b option
             causes src-pane to be joined to left of or above dst-pane.

             If -s is omitted and a marked pane is present (see select-pane -m), the marked pane is used rather than the current pane.

    split-window [-bdfhIvP] [-c start-directory] [-e environment] [-l size] [-t target-pane] [shell-command] [-F format]
                  (alias: splitw)
            Create a new pane by splitting target-pane: -h does a horizontal split and -v a vertical split; if neither is specified, -v is assumed.  The -l option specifies the size of the
            new pane in lines (for vertical split) or in columns (for horizontal split); size may be followed by ‘%’ to specify a percentage of the available space.  The -b option causes
            the new pane to be created to the left of or above target-pane.  The -f option creates a new pane spanning the full window height (with -h) or full window width (with -v), in‐
            stead of splitting the active pane.

            An empty shell-command ('') will create a pane with no command running in it.  Output can be sent to such a pane with the display-message command.  The -I flag (if shell-command
            is not specified or empty) will create an empty pane and forward any output from stdin to it.  For example:

                  $ make 2>&1|tmux splitw -dI &

            All other options have the same meaning as for the new-window command.

Describe alternatives you've considered
There are none.

Additional context

@ModProg
Copy link
Contributor

ModProg commented Jan 16, 2022

On top of just moving panes into/from tabs, creating new windows from tabs would also be great.

Maybe also moving tabs between windows.

wez added a commit that referenced this issue May 28, 2022
This commit allows for the SplitPane internal action to use the
pane id of an existing pane as the source of the pane to be added
in the new split target, rather than spawning a new command.

This can be used to move a pane from one tab to another, and is
analagous to tmux's `join-pane` command.

refs: #2043
refs: #1253
wez added a commit that referenced this issue May 28, 2022
This allows moving a pane to a new tab, which can in turn be
created in a new window.

refs: #1253
@wez
Copy link
Owner

wez commented May 28, 2022

In main, wezterm cli split-pane has been extended with easier to understand destination directions (--left, --right), sizes (--cells, --percent) and most relevant to this request: --move-pane-id, which tells it to move an existing pane into the newly created split space:

; wezterm cli split-pane --help
wezterm-cli-split-pane 0.1.0
split the current pane.
Outputs the pane-id for the newly created pane on success

USAGE:
    wezterm cli split-pane [FLAGS] [OPTIONS] [prog]...

FLAGS:
        --bottom        Split vertically, with the new pane on the bottom
    -h, --help          Prints help information
        --horizontal    Equivalent to `--right`. If neither this nor any other direction is specified, the default is
                        equivalent to `--bottom`
        --left          Split horizontally, with the new pane on the left
        --right         Split horizontally, with the new pane on the right
        --top           Split vertically, with the new pane on the top
        --top-level     Rather than splitting the active pane, split the entire window
    -V, --version       Prints version information

OPTIONS:
        --cells <cells>                  The number of cells that the new split should have. If omitted, 50% of the
                                         available space is used
        --cwd <cwd>                      Specify the current working directory for the initially spawned program
        --move-pane-id <move-pane-id>    Instead of spawning a new command, move the specified pane into the newly
                                         created split
        --pane-id <pane-id>              Specify the pane that should be split. The default is to use the current pane
                                         based on the environment variable WEZTERM_PANE
        --percent <percent>              Specify the number of cells that the new split should have, expressed as a
                                         percentage of the available space

ARGS:
    <prog>...    Instead of executing your shell, run PROG. For example: `wezterm cli split-pane -- bash -l` will
                 spawn bash as if it were a login shell

A new command has been added for moving a pane out of its containing tab and into a new tab.
This can also create a new window for that tab:

; wezterm cli move-pane-to-new-tab --help
wezterm-cli-move-pane-to-new-tab 0.1.0
Move a pane into a new tab

USAGE:
    wezterm cli move-pane-to-new-tab [FLAGS] [OPTIONS]

FLAGS:
    -h, --help          Prints help information
        --new-window    Create tab in a new window, rather than the window currently containing the pane
    -V, --version       Prints version information

OPTIONS:
        --pane-id <pane-id>        Specify the pane that should be moved. The default is to use the current pane based
                                   on the environment variable WEZTERM_PANE
        --window-id <window-id>    Specify the window into which the new tab will be created. If omitted, the window
                                   associated with the current pane is used
        --workspace <workspace>    If creating a new window, override the default workspace name with the provided name.
                                   The default name is "default"

@MuhammedZakir
Copy link
Contributor

Maybe remove to-new-tab In move-pane-to-new-tab? As it can move pane to a window too.

Thank you very much for all the work you're doing! :-)

wez added a commit that referenced this issue Jun 16, 2022
@wez wez closed this as completed Jun 16, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants