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 flex resize, focus mode, hard-coded limits for now (clone of #2704) #8546

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

sander777
Copy link

@sander777 sander777 commented Oct 16, 2023

This feature had been implemented in #2704, but PR seams inactive. I really wanted this feature and just copy pasted code from original PR.

Fixes #1176

@sander777 sander777 changed the title Add flex resize, focus mode, hard-coded limits for now (clone of https://github.com/helix-editor/helix/pull/2704) Add flex resize, focus mode, hard-coded limits for now (clone of [#2704](https://github.com/helix-editor/helix/pull/2704)) Oct 16, 2023
@sander777 sander777 changed the title Add flex resize, focus mode, hard-coded limits for now (clone of [#2704](https://github.com/helix-editor/helix/pull/2704)) Add flex resize, focus mode, hard-coded limits for now (clone of #2704) Oct 16, 2023
helix-view/src/tree.rs Outdated Show resolved Hide resolved
@kirawi kirawi added A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer. labels Oct 17, 2023
@the-mikedavis
Copy link
Member

the-mikedavis commented Oct 21, 2023

If you're re-submitting someone else's code it's customary to credit them as a co-author in the commits: https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors

@sander777 sander777 force-pushed the resize-windows branch 5 times, most recently from 1238d49 to 3b59425 Compare October 21, 2023 19:07
@archseer
Copy link
Member

If it's as far as simply rebasing the original work I'd keep the commit authorship as is and either add a Co-authored-by or a separate commit with the fixes

@sander777 sander777 force-pushed the resize-windows branch 3 times, most recently from 2bed1e6 to 982c008 Compare November 3, 2023 15:21
@sander777
Copy link
Author

There was a problem with author's name on old commits. Now everything looks fine

@Termina94 Termina94 mentioned this pull request Dec 11, 2023
@EzekielEnns

This comment was marked as spam.

@sander777 sander777 requested a review from archseer December 27, 2023 15:13
@mattkang
Copy link

Is there anything I can do to help get this PR merged? Would be great to have this feature.

@archseer archseer added this to the next milestone Aug 9, 2024
Comment on lines +29 to +35
"A-w" => { "Alter Window"
"A-h"|"A-left" |"h"|"left" => shrink_buffer_width,
"A-l"|"A-right"|"l"|"right" => grow_buffer_width,
"A-j"|"A-down" |"j"|"down" => shrink_buffer_height,
"A-k"|"A-up" |"k"|"up" => grow_buffer_height,
"A-f"|"f" => toggle_focus_window,
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we need the non-sticky version of this at all? I don't imagine that you would want to make a single edit to the sizes.

I'm also not sure about the keybinding. Instead I think this might fit better as a minor mode under C-w/<space>w specifically for resizing and move the f binding under C-w/<space>w instead

Comment on lines +1900 to +1904
pub fn resize_buffer(&mut self, resize_type: Resize, dimension: Dimension) {
self.tree.resize_buffer(resize_type, dimension);
}

pub fn toggle_focus_window(&mut self) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's some inconsistency here between "buffer" and "window". I would call both of these "view"s to match the internal wording

Comment on lines +815 to +828
fn grow_buffer_width(cx: &mut Context) {
cx.editor.resize_buffer(Resize::Grow, Dimension::Width);
}

fn shrink_buffer_width(cx: &mut Context) {
cx.editor.resize_buffer(Resize::Shrink, Dimension::Width);
}
fn grow_buffer_height(cx: &mut Context) {
cx.editor.resize_buffer(Resize::Grow, Dimension::Height);
}

fn shrink_buffer_height(cx: &mut Context) {
cx.editor.resize_buffer(Resize::Shrink, Dimension::Height);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strikes me as not the right API for resizing. I would expect that commands would hardcode the amount/ratio or take the cx.count() into account to decide how much to resize. With this API it's hard to introduce resizing windows by mouse dragging the separator for example, and we can take the terminals cells into account to give an exact amount. I think @pascalkuthe has similar thoughts here if he'd like to weigh in

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For an example of another pane resizing thing in the wild: in sway/i3 you can create a mode to resize like I have here: https://github.com/the-mikedavis/dotfiles/blob/51d85cb1f258300b6fc90427fe7c1069ff924a64/defaults/sway/default.nix#L255-L271

That's what I'm thinking for the sticky mode and the hardcoding of amounts to resize by

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I think using terminal cells/pixels as aboslute positions instead of these relative slots makes more sense to me

@the-mikedavis the-mikedavis added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from a maintainer. labels Aug 16, 2024
@jakDev003
Copy link

This sure would be a great feature if we could just get that second reviewer so this can be merged that would be great! Please and thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Resize windows
9 participants