microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.63k stars 8.32k forks source link

Split panes equally in size #6002

Open gak opened 4 years ago

gak commented 4 years ago

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.)

carlos-zamora commented 4 years ago

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:

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.

zadjii-msft commented 4 years ago

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)

gnarlygeek commented 4 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

I second this request. I need it too. Thanks.

nicbiggs commented 3 years ago

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 commented 3 years ago

@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 commented 3 years ago

The problem with the percentage solution is that if you've got a dynamic list of splits to do, it becomes a bit challenging to manage the percentages correctly.

reinux commented 2 years ago

I've just been opening new windows.

carlos-zamora commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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

https://github.com/MicrosoftDocs/Console-Docs/issues/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 commented 11 months ago

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 commented 9 months ago

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 commented 1 month ago

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