snakedye / kile

A layout generator for river
MIT License
18 stars 2 forks source link

[Question] Syntax for BSP style window management #3

Closed ShandoTheKing closed 3 years ago

ShandoTheKing commented 3 years ago

Hey I've been using kile the last few weeks and I'm trying to achive window management that's similar to bpwm but I can't really seem to understand the syntax.

snakedye commented 3 years ago
( layout main_amount main_factor main_index )
       main_amount (int)
           An arbitrary positive integer indicating the amount of main views.

       main_factor (fixed)
           A floating point number indicating the relative size of the area reserved for main views. Note that lay‐
           outs commonly expect values between 0.1 and 0.9.

       main_index (int)
           An arbitrary positive integer indicating the index of the main area in a layout.

{ layout : layout layout ... }
       This layout is the core of every nested layout. It essentially let's you define a layout of layouts or in
       other words the disposition of layouts within one. Since it is itself a layout, fields can be a recursive layouts.

       - views at the top of the stack will be displayed in the main area.

The first layout in the definition of the recursive layout is the outer layout. The idea is that using the outer layout, you create a layout of areas where you can generate other layouts. See recursive as a macro for layouts. It's designed to create exactly as areas much as there is sublayouts, the layouts after :.

The most simple example is this { v: h h }. You want to split an area vertically first so you use the vertical layout as the outer. It will generate two areas where you'll have a horizontal sublayout. When kile receives a layout_demand from river, if you configured your tag, it will generate the layout using these parameters. These are the default.

let mut main_index = 0;
let mut main_amount = 1;
let mut main_factor = 0.6;

main_index determines where the master area is in the layout. main_amount determines how much windows you'll have in the master area. main_factor is the "ratio" of the space occupied by the master. The rest of windows are spread equally in the other slave areas. If main_index is bigger than the amount of sublayouts currently generated or main_amount is 0, there's no master.

The parens "()" are used to specify the parameters of the said layout. ( { v: h h } 2 0.6 0 ) so here you'll have the previous layout definition but now its main_amount is 2, its main_factor is 0.6 and its main_index is 0.

Note:

When this layout is not nested in another, it also serves to set the layout parameters for the tag.

The vertical and horizontal layouts are also influenced by layout values.

When I create a layout, I like to also set the layout parameters of the tag I think are the most appropriate but you are free to do however you want.

If you want a dwindle layout, assuming the first split is vertical, start with this

(
  { ver:
     full,
     ...
  } 1 0.65 0
)

First you split the area vertically. Your main_index is 0, so the master will be on the left and your main_amount is 1 so you'll have one window is that master area.

The reason why I set the layout to full is because it's the simplest layout, any layout would generate one window spanning across the entire area but they'll do slightly more math.

For the second area on the right, you'll have one layout but in that layout, you want to split the area horizontally in 2 again.

Remember what was mentioned previously. Windows are spread evenly across layouts. Since the previous master has one window, this new one will have all the other left, and the master in this layout will have one and the slave all the other left....

Repeat this for as much splits as you want and you're done. For the last split however, you'll have to settle with a non recursive layout. You can't reasonably split indefinitely so recommend setting the layout to deck but it could be horizontal or vertical.

ShandoTheKing commented 3 years ago

Ok, thanks for the explanation. I think I got it.

niksingh710 commented 2 years ago

@ShandoTheKing have you created bspwm layout? if so provide