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

Split panes equally in size #6002

Open
gak opened this issue May 19, 2020 · 18 comments
Open

Split panes equally in size #6002

gak opened this issue May 19, 2020 · 18 comments
Labels
Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Milestone

Comments

@gak
Copy link

gak commented May 19, 2020

Description of the new feature/enhancement

When splitting twice into three panes, I would like the option to split by parent equally.

Instead of:

+-------+---+---+
|       |   |   |
+-------+---+---+

Ideally it would be like this:

+----+----+----+
|    |    |    |
+----+----+----+

Coming from iTerm this makes much more sense to me.

When splitting vertically within a horizontal pane, it would work in the same fashion.

This could be a new shortcut that when splitting, e.g. "split horizontally and keep parent" where all children are resized when a new child is added or removed. (I don't how how it currently works internally, so I'm guessing here.)

@gak gak added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label May 19, 2020
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 19, 2020
@carlos-zamora
Copy link
Member

Love this idea. A few thoughts off the bat.

We could accomplish this by adding a keybinding argument to the splitPane action.

Getting inspiration from TabView's TabWidthBehavior (doc), we could introduce a keybinding argument like splitBehavior with the following possible values:

  • equal: each pane is resized to have the same size (this feature)
  • half: split the space in half for two new panes (current behavior)

I'm guessing we would have to have this same keybinding argument for closePane?

Regardless, we probably need a spec for this so I'll tag it up now.

@carlos-zamora carlos-zamora added Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal. and removed Needs-Tag-Fix Doesn't match tag requirements labels May 19, 2020
@zadjii-msft
Copy link
Member

my napkin spec was { "action": "splitPane", ..., "resizeParents": true }, to walk up the tree and re-adjust splits with the same direction, until we hit a split with a different direction.

Consider creating a bunch of similar splits:

+-----+-----+     +---+---+---+     +--+--+--+--+
|     |     |     |   |   |   |     |  |  |  |  |
|     |     |     |   |   |   |     |  |  |  |  |
|  a  |  b  |     | a | b | c |     |a |b |c |d |
|     |     |     |   |   |   |     |  |  |  |  |
|     |     |     |   |   |   |     |  |  |  |  |
+-----+-----+     +---+---+---+     +--+--+--+--+

This makes sense, each takes not half the parent, but 1/Nth of the whole

Then consider splitting B in the following:

+-----+-----+     +-----------+
|     |  b  |     |     |b |d |
|     |     |     |     |  |  |
|  a  +-----+     |  a  +--+--+
|     |  c  |     |     |  c  |
|     |     |     |     |     |
+-----+-----+     +-----+-----+

We probably don't want to make A, B, D all take 33% width here (leaving C with 66% width)

@zadjii-msft zadjii-msft removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label May 27, 2020
@gnarlygeek
Copy link

gnarlygeek commented May 31, 2020

How about resolving this more generically with 2 new options - SplitHereVertically and SplitHereHorizontally based on mouse/cursor position. This would allow for maximum flexibility of pane sizing, and then the "parent resizing" becomes mandatory.

@niceblue88
Copy link

I definitely second this suggestion, even though it looks like this original suggestion might be "waylaid" by now after a year or so.

Use case here is for research, running multiple simulation, perhaps 8. That means 8 command line windows. It would be really helpful to see progress on all at the same time without switching tabs all the time, i.e. you want equally spread windows (ideally horizontally split). Shift+Alt+- etc. is great, but it's exponentially decreasing in size. Using the mouse to configure the 7 splits manually every time there is a run is not practical. Therefore you want it to automatically adjust the already existing splits to accommodate the new one, OR allow specification of number of splits, like 8, ahead of time so it knows how to split equally in one go.

I'm sure this kind of simulation/research runs are not a corner case for this app, as running multiple old-fashioned command lines is the only other option, where you have auto tile etc available in native Window GUI. This actually can work well. However, if you have any other windows open other than the consoles, it messes up and doesn't work at all.

@zadjii-msft
Copy link
Member

This is related to, but different from #4456. #4456 is "After I've got a bunch of splits, I'd like to equalize them", this is "I want to resize equally as I split them"

@daniel0x00

This comment has been minimized.

@nicbiggs
Copy link

I love this suggestion. I think it would also be useful to include this ability to equally size the panes via the command line. I'd love to have the terminal already set up how I want them to be by entering a single command.

@zadjii-msft
Copy link
Member

@nicbiggs fyi you probably don't need to wait for this to get what you want. You could just be clever with the split percentages today:

wt ; sp -s .66 ; sp -s .5

image

@daniel0x00
Copy link

daniel0x00 commented Sep 18, 2021 via email

@zadjii-msft zadjii-msft modified the milestones: Terminal Backlog, Backlog Jan 4, 2022
@reinux
Copy link

reinux commented Jul 4, 2022

I've just been opening new windows.

@carlos-zamora
Copy link
Member

Copying a comment from @brupelo in #14604:

Consider this script foo.cmd

set BD=d:\

wt -w %~n0 ^
nt --title="tab1" --startingDirectory=%BD% ; ^
sp --title="tab2" --startingDirectory=%BD% ; ^
sp --title="tab3" --startingDirectory=%BD% ; ^
sp --title="tab4" --startingDirectory=%BD% ; ^
sp --title="tab5" --startingDirectory=%BD% ; ^
sp --title="tab6" --startingDirectory=%BD% ;

When I run it from the terminal I'll get this:

image

There are few questions here:

  1. You can see how a new tab called "Command Prompt" has been created, is there any way to prevent that?
  2. I'd like to learn how to arrange my 6 panes in something like this:

image

In the above image I did that manually but I'd like to create this sort of arrangement from my script foo.cmd, so how can I modify my script to acomplish that?

Basically my goal is each pane is taking 1/6 of the total client area.

  1. What's the rationale of wt sp --help, wt --help, ... , wt cmd --help creating a window rather than writing to stdout as usual?
  2. Let's say on %BD% there is a virtualenv that i want to activate venv\Scripts\activate so then I can run few scripts python fancy_server, how can I modify my script to do that?

I wasn't sure where to ask these question... although reading the docs I'm still trying to figure out how you could achieve this one.

Maybe having a section

image

would be more convenient?

Thanks in advance!

Ps. Basically the idea here is migrating some old conemu scripts where i'd be able to spin up few microservices like this:

-cur_console:d:d:\microservices\local -cur_console:t:microservice1 cmd /k run_ms1.cmd

-cur_console:ns1T65H -cur_console:d:d:\microservices\local -cur_console:t:microservice2 cmd /k run_ms2.cmd

-cur_console:ns1T50V -cur_console:d:d:\microservices\local -cur_console:t:microservice3 cmd /k run_ms3.cmd

-cur_console:ns2T50V -cur_console:d:d:\microservices\local -cur_console:t:microservice4 cmd /k run_ms4.cmd

-cur_console:ns2T50H -cur_console:d:d:\microservices\local -cur_console:t:microservice5 cmd /k run_ms5.cmd

> -cur_console:ns4T50H -cur_console:d:d:\microservices\local -cur_console:t:microservice6 cmd /k run_ms6.cmd

where each run_ms.cmd would cd/pushd/popd into the microservice directory and call python, docker, whatever... I'd like to learn how to accomplish this (having this in a single standalone script would be great) using windows terminal

@brupelo
Copy link

brupelo commented Jan 20, 2023

Hey guys, so, what do you think the above?

I mean, don't get me wrong, the conemu syntax is quite convoluted and no syntax friendly by all means but at least it solves the general case as it allows to create any sort of layout or arrangment in terms of %. If there was a wt command covering the general case in terms of % that'd open a lot of possibilities to create full "dashboards" with 1 click.

Or maybe I'm missing something and the above 3x2 layout could already be created with the current command syntax https://learn.microsoft.com/en-us/windows/terminal/command-line-arguments?tabs=windows#split-pane-command ?

@eromoe
Copy link

eromoe commented Apr 7, 2023

I wrote a simple script to generate split command

def create_wt(n, oritation='H'):
    assert oritation in ('H', 'V')
    sizes = np.arange(n-1, 0, -1)/np.arange(n, 1, -1)
    sizes = sizes.round(2)
    cmd = 'wt ;' + ';'.join([f'sp -{oritation} -s {i}' for i in sizes])
    print(cmd)
    
create_wt(5)

wt ;sp -H -s 0.8;sp -H -s 0.75;sp -H -s 0.67;sp -H -s 0.5

@randori-ddejohn
Copy link

my napkin spec was { "action": "splitPane", ..., "resizeParents": true }, to walk up the tree and re-adjust splits with the same direction, until we hit a split with a different direction.

Consider creating a bunch of similar splits:

+-----+-----+     +---+---+---+     +--+--+--+--+
|     |     |     |   |   |   |     |  |  |  |  |
|     |     |     |   |   |   |     |  |  |  |  |
|  a  |  b  |     | a | b | c |     |a |b |c |d |
|     |     |     |   |   |   |     |  |  |  |  |
|     |     |     |   |   |   |     |  |  |  |  |
+-----+-----+     +---+---+---+     +--+--+--+--+

This makes sense, each takes not half the parent, but 1/Nth of the whole

Then consider splitting B in the following:

+-----+-----+     +-----------+
|     |  b  |     |     |b |d |
|     |     |     |     |  |  |
|  a  +-----+     |  a  +--+--+
|     |  c  |     |     |  c  |
|     |     |     |     |     |
+-----+-----+     +-----+-----+

We probably don't want to make A, B, D all take 33% width here (leaving C with 66% width)

I'd love to see some new command palette options to select n panes and resize them evenly, either horizontally or vertically. That way the user could select A and C in your last example and resizePanesVertically to have A and C take 50% each, or select A, B, and D and run the command to get A at 33% and C at 66%, if that's what the user desires.

This way, the pane splitting behavior does not need to be modified, and you're "just" adding new functionality.

@brupelo
Copy link

brupelo commented Oct 27, 2023

Hi guys, I don't why but when I've created a github issue from this repo it was created on a different one... I'm not sure why, anyway, posting in this one as it seems to be the official thread when it comes to pane splitting feature

MicrosoftDocs/Console-Docs#301

@eromoe Interesting function you've created there, maybe could it be adjusted to create a more flexible layout of MxN with equally sized panes?

@math-queiroz
Copy link

math-queiroz commented Dec 12, 2023

Here's a quick and dirty Powershell script for creating evenly spaced pane grids that are at least 2x2:

# Usage ./script.ps1 <rows> <cols>
$h = $args[0]
$w = $args[1]
Start-Process wt -ArgumentList ((";" + (1..($h-1) | % {
	"sp -H -s $(1-1/($h-$_+1));mf previous;" + ((2..$w | % {
		"sp -V -s $(1-1/($w-$_+2))"
	}) -join ";") + ";mf down;"
}) -join "") + ((2..$w | % {"sp -V -s $(1-1/($w-$_+2))"}) -join ";"))

I also have an extended script that allows for smaller grids and handles starting panes with individual commands. Hope it helps!

@Rusinas
Copy link

Rusinas commented Feb 10, 2024

Copying a comment from @brupelo in #14604:

  1. I'd like to learn how to arrange my 6 panes in something like this:

image
In the above image I did that manually but I'd like to create this sort of arrangement from my script foo.cmd, so how can I modify my script to acomplish that?
Basically my goal is each pane is taking 1/6 of the total client area.

I am wondering about the same layout when creating panes inside of a script, now it's a painful experience :(

@songlim327
Copy link

I had created a small tool to do this. By entering multi commands, the tool helps to automatically calculate balanced layout for windows terminal.

https://github.com/songlim327/mpwt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests