-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
base: master
Are you sure you want to change the base?
Changes from all commits
64311f7
d8fbff3
e4c9054
6891014
5aaaf13
978c1a1
1d79ba9
5a830c7
7c54c63
036e5c3
7bb4ed2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,22 @@ pub fn default() -> HashMap<Mode, KeyTrie> { | |
"home" => goto_line_start, | ||
"end" => goto_line_end, | ||
|
||
"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, | ||
}, | ||
Comment on lines
+29
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
"A-W" => { "Alter Window" sticky=true | ||
"h"|"left" => shrink_buffer_width, | ||
"l"|"right" => grow_buffer_width, | ||
"j"|"down" => shrink_buffer_height, | ||
"k"|"up" => grow_buffer_height, | ||
"f" => toggle_focus_window, | ||
}, | ||
|
||
"w" => move_next_word_start, | ||
"b" => move_prev_word_start, | ||
"e" => move_next_word_end, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ use crate::{ | |
input::KeyEvent, | ||
register::Registers, | ||
theme::{self, Theme}, | ||
tree::{self, Tree}, | ||
tree::{self, Dimension, Resize, Tree}, | ||
Document, DocumentId, View, ViewId, | ||
}; | ||
use dap::StackFrame; | ||
|
@@ -1897,6 +1897,14 @@ impl Editor { | |
self.tree.transpose(); | ||
} | ||
|
||
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) { | ||
Comment on lines
+1900
to
+1904
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
self.tree.toggle_focus_window(); | ||
} | ||
|
||
pub fn should_close(&self) -> bool { | ||
self.tree.is_empty() | ||
} | ||
|
There was a problem hiding this comment.
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 inThere was a problem hiding this comment.
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
There was a problem hiding this comment.
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