helix icon indicating copy to clipboard operation
helix copied to clipboard

Add centered view mode

Open ldubos opened this issue 3 years ago • 4 comments

Resolves #3203

Add a new toggle_centered_view command in Window mode and a centered-views to the editor config, change the behaviour of the recalculate function in Tree to center a View when it has the is_centered set to true to center it in the available space if the View isn't a child of a vertical container with more than 1 children.

I found that is the "standard" behaviour of the "centered mode" in most editors I use.

image

ldubos avatar Jul 29 '22 09:07 ldubos

Nice!

One question though: how is the view width defined? Looking at the diff this isn't immediately obvious to me. I personally would want to specify the width either through a setting or at runtime when calling the command.

CptPotato avatar Jul 29 '22 13:07 CptPotato

@CptPotato for the moment we can't define the width unfortunately I don't really know how I can make it configurable and updatable during a session, it seems really complicated, also I don't take the gutters_offset so the width = the total width not the inner width.

and I calculated the centered width like this: centered_width = min(max(available_width / 2, 120), available_width) that means if the available_width / 2 < 120 we set it to 120 and if the result is greater than the available_width we set it to available_width.

So you always have at least 120 columns (with gutters) in centered mode or the available_width / 2 if you have more space available, and the fallback is just the available space so no centering.

ldubos avatar Jul 29 '22 13:07 ldubos

@ldubos I love this PR, and see that it is currently prevented from being merged by conflicts.

Do you see any chance to resolve them?

ShalokShalom avatar Feb 12 '23 17:02 ShalokShalom

It would be great if someone could take over this pull request, it is so needed!

David-Else avatar Jun 02 '23 10:06 David-Else

closing in favor of https://github.com/helix-editor/helix/pull/9838

pascalkuthe avatar Apr 13 '24 22:04 pascalkuthe