Allow user to specify the number of rows or columns to increase or decrease by when resizing pane via keyboard. #22198

Open
opened 2026-01-31 08:06:16 +00:00 by claunia · 5 comments
Owner

Originally created by @freddiehaddad on GitHub (Sep 1, 2024).

Description of the new feature/enhancement

When resizing panes via keyboard, it would be nice to specify the resize amount. Right now, when you resize the pane, the amount is different depending on pane width, window width, etc. Can we have the ability to resize by X columns or rows (depending on resize direction)?

Proposed technical implementation details (optional)

In the keyboard settings, when assigning a keyboard shortcut for pane resizing, allow a second integer value specifying the number of columns or rows to resize by.

If the user specifies the value 2 for the resize pane action, then if they grow or shrink the pane, it will increase or decrease by 2 rows or columns depending on direction.

Originally created by @freddiehaddad on GitHub (Sep 1, 2024). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement When resizing panes via keyboard, it would be nice to specify the resize amount. Right now, when you resize the pane, the amount is different depending on pane width, window width, etc. Can we have the ability to resize by X columns or rows (depending on resize direction)? <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details (optional) In the keyboard settings, when assigning a keyboard shortcut for pane resizing, allow a second integer value specifying the number of columns or rows to resize by. <!-- A clear and concise description of what you want to happen. --> If the user specifies the value 2 for the resize pane action, then if they grow or shrink the pane, it will increase or decrease by 2 rows or columns depending on direction.
claunia added the Issue-FeatureArea-SettingsProduct-Terminal labels 2026-01-31 08:06:16 +00:00
Author
Owner

@carlos-zamora commented on GitHub (Sep 25, 2024):

Thanks for filing! Yeah, this seems like something we could add in as an action arg for the resize pane action.

@carlos-zamora commented on GitHub (Sep 25, 2024): Thanks for filing! Yeah, this seems like something we could add in as an action arg for the resize pane action.
Author
Owner

@freddiehaddad commented on GitHub (Sep 26, 2024):

@carlos-zamora If you think this could be a good first ticket for me and you have some cycles to provide guidance, I can work on it.

@freddiehaddad commented on GitHub (Sep 26, 2024): @carlos-zamora If you think this could be a good first ticket for me and you have some cycles to provide guidance, I can work on it.
Author
Owner

@carlos-zamora commented on GitHub (Sep 27, 2024):

Sure! I can help a bit. Here's a writeup of what needs to be done. Hope it helps 🙂

  • src/cascadia/TerminalSettingsModel changes
    • this section is responsible for (de)serializing the settings
    • ActionArgs.idl: add the new arg to ResizePaneArgs
    • ActionArgs.h: update RESIZE_PANE_ARGS appropriately
    • ActionArgs.cpp: ResizePaneArgs::GenerateName is used to generate the name for the command palette.
      • 📝 NOTE: RS_() is how we retrieve the localized string from Resources.resw. Be sure to add any new entries to the resw file located in TerminalSettingsModel
      • ⚠️ I strongly suggest you use the editor in Visual Studio to modify the resw file. For some reason, I've noticed that when I modify the file with VS Code, VS won't be able to open the file anymore!
  • src/cascadia/TerminalApp changes
    • this section is responsible for maintaining the app itself. It's the layer between...'
      • WindowsTerminal: handles the windowing and WM events (you'll definitely avoid touching this area)
      • TerminalControl: handles the actual terminal content (i.e. input handling, search box, etc.). But mainly XAML and UI.
        • 📝 NOTE: There's also a TerminalCore layer that's beneath TerminalControl. This handles most of the non-UI terminal related things (i.e. rendering, terminal APIs, text buffer contents, etc.). You probably won't have to touch this, but it's good to know. This has knowledge of the buffer size, so if that's something you end up needing, now you know where to find it.
    • So basically, TerminalApp handles things like tabs, panes (!!), the command palette, etc. App-wide things.
    • AppActionhandlers.cpp: _HandleResizePane() is where we handle the action event. The ResizePaneArgs is the same one you touched in TerminalSettingsModel, so you should be able to access the new property here and do whatever you need to do.
    • Pane.h/cpp: This is where the resize actually happens, so you'll probably have to make some changes here.

References:

  • #15027: This is a relatively recent PR that adds an action arg. You'll want to mainly take a look at src/cascadia/TerminalSettingsModel and src/cascadia/TerminalApp
@carlos-zamora commented on GitHub (Sep 27, 2024): Sure! I can help a bit. Here's a writeup of what needs to be done. Hope it helps 🙂 - `src/cascadia/TerminalSettingsModel` changes - this section is responsible for (de)serializing the settings - [ ] ActionArgs.idl: add the new arg to `ResizePaneArgs` - [ ] ActionArgs.h: update RESIZE_PANE_ARGS appropriately - [ ] ActionArgs.cpp: `ResizePaneArgs::GenerateName` is used to generate the name for the command palette. - 📝 NOTE: `RS_()` is how we retrieve the localized string from Resources.resw. Be sure to add any new entries to the resw file located in `TerminalSettingsModel` - ⚠️ I strongly suggest you use the editor in Visual Studio to modify the resw file. For some reason, I've noticed that when I modify the file with VS Code, VS won't be able to open the file anymore! - `src/cascadia/TerminalApp` changes - this section is responsible for maintaining the app itself. It's the layer between...' - `WindowsTerminal`: handles the windowing and WM events (you'll definitely avoid touching this area) - `TerminalControl`: handles the actual terminal content (i.e. input handling, search box, etc.). But mainly XAML and UI. - 📝 NOTE: There's also a `TerminalCore` layer that's beneath `TerminalControl`. This handles most of the non-UI terminal related things (i.e. rendering, terminal APIs, text buffer contents, etc.). You probably won't have to touch this, but it's good to know. This has knowledge of the buffer size, so if that's something you end up needing, now you know where to find it. - So basically, `TerminalApp` handles things like tabs, panes (!!), the command palette, etc. App-wide things. - [ ] `AppActionhandlers.cpp`: `_HandleResizePane()` is where we handle the action event. The `ResizePaneArgs` is the same one you touched in `TerminalSettingsModel`, so you should be able to access the new property here and do whatever you need to do. - [ ] `Pane.h/cpp`: This is where the resize actually happens, so you'll probably have to make some changes here. References: - #15027: This is a relatively recent PR that adds an action arg. You'll want to mainly take a look at `src/cascadia/TerminalSettingsModel` and `src/cascadia/TerminalApp`
Author
Owner

@freddiehaddad commented on GitHub (Sep 27, 2024):

After a few minutes looking through the code, I see the default behavior is to resize the pane in 5% increments based on the focused pane's dimensions. This explains the peculiar resize behavior (i.e. 5% of 500px pane vs 5% of a 1000px pane).

Questions:

  1. In order to resize by rows or columns, we need to know font dimensions, correct?
  2. If the answer to question 1 is yes, then how do we query the row/col dimensions of the font being displayed in the pane?
  3. Would it be easier to just resize by a user-specified number of pixels?
@freddiehaddad commented on GitHub (Sep 27, 2024): After a few minutes looking through the code, I see the default behavior is to resize the pane in 5% increments based on the focused pane's dimensions. This explains the peculiar resize behavior (i.e. 5% of 500px pane vs 5% of a 1000px pane). Questions: 1. In order to resize by rows or columns, we need to know font dimensions, correct? 2. If the answer to question 1 is yes, then how do we query the row/col dimensions of the font being displayed in the pane? 3. Would it be easier to just resize by a user-specified number of pixels?
Author
Owner

@carlos-zamora commented on GitHub (Sep 27, 2024):

  1. In order to resize by rows or columns, we need to know font dimensions, correct?
  2. If the answer to question 1 is yes, then how do we query the row/col dimensions of the font being displayed in the pane?

Hmm, looks like Pane::_CreateRowColDefinitions() uses _desiredSplitPosition to determine where the split is (in percentage units). So, I guess if you can figure out a way to update that appropriately, yeah. You'd have to use the font size to figure out how much a row/column is and update that appropriately?

📝 Keep in mind, different terminals/panes may be using different font sizes (though I think you'll be fine; you'll just have to retrieve the font dimensions from the current pane/terminal and use that).

Looks like the font dimensions are exposed on TermControl::CharacterDimensions (check the units on that). So you'll have to go from Pane --> IPaneContent (check that it's a TerminalPaneContent) --> TermControl.

📝 Hmm... if the current pane isn't a terminal, what should we do to resize? I think it would still be good to resize as opposed to just preventing the action from happening, but it'll probably be something to play with to see how it feels "right".

  1. Would it be easier to just resize by a user-specified number of pixels?

Oh totally. I have a personal dislike for pixels as a unit though haha. Maybe percentage? That would avoid all of the extra work I mentioned above, and you'd really just modify the amount variable in Pane::_Resize(). I imagine that would solve your feature request adequately too.

Oh, I also found this PR: https://github.com/microsoft/terminal/pull/16895. Seems pretty relevant to you 🙂.

@carlos-zamora commented on GitHub (Sep 27, 2024): > 1. In order to resize by rows or columns, we need to know font dimensions, correct? > 2. If the answer to question 1 is yes, then how do we query the row/col dimensions of the font being displayed in the pane? Hmm, looks like `Pane::_CreateRowColDefinitions()` uses `_desiredSplitPosition` to determine where the split is (in percentage units). So, I guess if you can figure out a way to update that appropriately, yeah. You'd have to use the font size to figure out how much a row/column is and update that appropriately? 📝 Keep in mind, different terminals/panes may be using different font sizes (though I think you'll be fine; you'll just have to retrieve the font dimensions from the current pane/terminal and use that). Looks like the font dimensions are exposed on `TermControl::CharacterDimensions` (check the units on that). So you'll have to go from Pane --> `IPaneContent` (check that it's a `TerminalPaneContent`) --> `TermControl`. 📝 Hmm... if the current pane isn't a terminal, what should we do to resize? I think it would still be good to resize as opposed to just preventing the action from happening, but it'll probably be something to play with to see how it feels "right". > 3. Would it be easier to just resize by a user-specified number of pixels? Oh totally. I have a personal dislike for pixels as a unit though haha. Maybe percentage? That would avoid all of the extra work I mentioned above, and you'd really just modify the `amount` variable in `Pane::_Resize()`. I imagine that would solve your feature request adequately too. Oh, I also found this PR: https://github.com/microsoft/terminal/pull/16895. Seems pretty relevant to you 🙂.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22198