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

Add window resize to absolute values #6386

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ershov
Copy link

@ershov ershov commented Jun 22, 2023

This is a proof-of-concept for enabling the 'split' layout to use the 'bias' option and allowing to specify the absolute values for 'resize_window' command.

The 'bias' option was previously ignored by 'splits' layout, now it's possible to do:

enabled_layouts splits:bias=90

Only increments or decrements were previously accepted. 'width' and 'height' are for absolute percentages:

map <KEY>          resize_window width 20
map <KEY>          resize_window height 70

The issue is mentioned here: #6382

Please let me know if this kind of change can potentially be accepted.

@kovidgoyal
Copy link
Owner

By absolute sizes do you mean size in cells or size in bias units?

If you mean size in cells, there are various problems. If you set the
size in cells for multiple windows and they conflict, what happens? What
happens on an OS window resize, when an absolute size cannot be
respected because there isnt enough space?

You could possibly mean "absolute" in the sense that specifying a size
in cells will adjust the corresponding bias to achieve that size, and
that's all. If that's the case I am OK with it.

But note that to be acceptable such a PR has to work for all layouts
not just splits.

@ershov
Copy link
Author

ershov commented Jun 22, 2023

That's by far about an absolute bias value. In the current implementation, there's no way to specify that other than changing the global layout setting which will forcedly reshape all existing windows.

I was looking for something similar to 'resize_window' for one window but in the sense of absolute value (not relative increments/decrements).

The current solution allows to set absolute 'bias' for a window in a split. But I can see a relatively simple solution like adding units suffix (like 'px', 'pt', 'cells', '%') to the number argument. This feature might come later as an incremental improvement after an initial solution.

Regarding all other layouts, I agree that consistency is important. I can see how it can be implemented as a more general case in the base class for all layouts.

Does it also imply adding support for 'bias' option to all layouts or it's a separate thing?

What do you think about this feature?

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jun 22, 2023 via email

@ershov
Copy link
Author

ershov commented Jun 22, 2023

Just cells absolute and relative are fine as far as I am concerned. Indeed since windows only have sizes in cells, you cant really use other units they will get rounded to nearest cells anyway.

Is it ok to start with just bias value (which is equal to percent) and adding cells later as a separate PR?

Yes in order for me to consider a PR it has to be implemented for all layouts.

Sounds good.

Does it also imply adding support for 'bias' option to all layouts or it's a separate thing?

All layouts internally use bias already otherwise they would not be resizeable at all. Except for the stack layout, obviously.

Ah yes, I mean, bias is used internally but not every layout supports the 'bias' option as a parameter to 'enabled_layouts'. Are you also looking to enable it for all layouts too? This also might go as a separate PR as it's an independent feature which would be good for consistency.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jun 23, 2023 via email

@ershov
Copy link
Author

ershov commented Jun 23, 2023

One cannot have bias as a parameter for all layouts, it is meaningless for some layouts such as stack/horiontal/vertical, it only really works for splits/vertical/horizontal. And I dont much see the point of it for splits, why would you want every split you make to start out already biased?

Since I use 'splits' a lot, I can tell that I expected it to be more consistent. If it has the 'bias' parameter, I don't see why it ignores it in options to 'enabled_layouts splits:bias=X'.

One of possible uses is: when I open a secondary window, I might prefer it to be smaller than the main one. One of the ways to achieve it would be to specify the 'bias' parameter.

By the way, the 'Pair' currently doesn't clear its 'bias' when one of windows is closed. It leads to an odd behavior of recalling the last 'bias' on the next split.

To reproduce:

  1. Enable 'splits' layout.
  2. Split the window in two.
  3. Resize one of the windows.
  4. Close one of splits.
  5. Open a split again.

Result: the split ratio is not 1:1 but the same as it was adjusted.

@kovidgoyal
Copy link
Owner

kovidgoyal commented Jun 23, 2023 via email

@ershov
Copy link
Author

ershov commented Jun 23, 2023

Yes, that's by design. If you want a pair of windows biased, I dont see why closing one of them neccessarily means you no longer want the bias.

Ok but the bias is not saved for the next split level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants