Add font zoom functionality to console view#2579
Add font zoom functionality to console view#2579raghucssit wants to merge 1 commit intoeclipse-platform:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Ctrl +/- (including numpad +/-) zoom support to the Eclipse Console view to align behavior with text editors (Issue #2578).
Changes:
- Installs a key listener on the console’s
StyledTextto detect Ctrl+Plus / Ctrl+Minus. - Implements font resizing logic with min/max bounds and a step size, creating a derived SWT
Font. - Disposes the created font on view disposal.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java
Outdated
Show resolved
Hide resolved
74720eb to
21d419f
Compare
|
|
||
| // Install font zoom key listener on the StyledText widget | ||
| StyledText textWidget = null; | ||
| if (page instanceof TextConsolePage textPage) { |
There was a problem hiding this comment.
I did not do full review, but looking at this palce here wonder if the code change should be done in TextConsolePage and all init in createControl() there? Because all other pages are irrelevant for the new code.
|
Have you thought about persisting the current zoom over the current session? That will be likely next immediate customer request after using this feature for the first time & IDE restart. Assuming the code moved to the page (from the console), we would always know "where we are" and should be able to persist the zoom in the preference store by using the |
21d419f to
c051ad1
Compare
|
@trancexpress Please check this PR. |
|
With: The Console view can be zoomed when I'm in the Java editor and I press: The change here makes me press The Java editor zoom in / zoom out resets whatever the zoom level was in the console, which is probably OK. |
| * @param delta the amount to change the font size (positive to increase, | ||
| * negative to decrease) | ||
| */ | ||
| private void changeFontSize(int delta) { |
There was a problem hiding this comment.
It seems odd that I can do this from the Java editor without this code. Can you check if some existing code can be re-used here?
There was a problem hiding this comment.
Pull request overview
Adds Ctrl +/- key handling to the Console view’s text widget to support zooming the console font size, addressing the usability gap described in #2578.
Changes:
- Add a key listener on the console
StyledTextto zoom font size on Ctrl + / Ctrl - (including numpad +/-). - Implement per-console-type font persistence via the console plug-in preference store and restore it on page creation.
- Minor whitespace adjustment in
ConsoleView.dispose().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java | Minor formatting-only change in dispose(). |
| debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java | Adds zoom key listener, font resizing logic, and preference-based font load/save for console pages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java
Outdated
Show resolved
Hide resolved
debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java
Outdated
Show resolved
Hide resolved
debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java
Outdated
Show resolved
Hide resolved
cb6dbf0 to
0c77159
Compare
d794c2b to
9dd0a16
Compare
-Add key listener on text widget of console view which listens ctrl plus and control minus(including numpad +/-) -Zoom in/out of the console view text in steps based on the keys pressed. see eclipse-platform#2578
9dd0a16 to
e1d88b4
Compare
|
@iloveeclipse Please check this PR. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Display display = Display.getCurrent(); | ||
| if (display == null) { | ||
| display = Display.getDefault(); | ||
| } | ||
| Display d = display; | ||
| d.asyncExec(() -> { |
There was a problem hiding this comment.
execute() for command handlers is normally invoked on the UI thread. Using Display#asyncExec here makes the operation race with focus changes (the focused control may no longer be the console StyledText when the runnable runs), causing zoom to apply to the wrong control or do nothing. Prefer running the logic immediately when Display.getCurrent() is non-null, and only fall back to syncExec when invoked off the UI thread; also capture getFocusControl() once instead of calling it multiple times.
| package org.eclipse.ui.console; | ||
|
|
||
| import org.eclipse.core.commands.AbstractHandler; |
There was a problem hiding this comment.
These handler implementation classes are in the exported API package org.eclipse.ui.console and are public, which effectively commits them as API. Since handlers are internal implementation details, consider moving them to an internal package (e.g., org.eclipse.ui.internal.console) and updating plugin.xml accordingly to avoid unintended API surface.
| @Override | ||
| public Object execute(ExecutionEvent event) throws ExecutionException { | ||
| changeFocusedFont(STEP); | ||
| return null; | ||
| } | ||
|
|
||
| private void changeFocusedFont(int delta) { |
There was a problem hiding this comment.
ConsoleZoomInHandler and ConsoleZoomOutHandler are nearly identical (only the delta differs). This duplication increases the chance of the two drifting over time. Consider extracting the shared logic into a common utility/base class, or using a single parameterized handler (e.g., via a command parameter for the delta).
| Display display = Display.getCurrent(); | ||
| if (display == null) { | ||
| display = Display.getDefault(); | ||
| } | ||
| Display d = display; | ||
| d.asyncExec(() -> { | ||
| StyledText st = d.getFocusControl() instanceof StyledText ? (StyledText) d.getFocusControl() : null; |
There was a problem hiding this comment.
Same asyncExec focus-race issue as in ConsoleZoomInHandler: scheduling asynchronously can run after focus has changed, so zoom-out may target the wrong control. Prefer executing immediately on the UI thread (or syncExec when needed) and capture the focus control once.
| package org.eclipse.ui.console; | ||
|
|
||
| import org.eclipse.core.commands.AbstractHandler; |
There was a problem hiding this comment.
This handler implementation is in the exported API package org.eclipse.ui.console and is public, which unintentionally adds API surface. Consider moving it to an internal package and updating the handler declaration in plugin.xml.
| sequence="M1+Plus"> | ||
| </key> | ||
| <key | ||
| commandId="org.eclipse.ui.console.command.fontZoomIn" | ||
| contextId="org.eclipse.ui.console.ConsoleView" | ||
| schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" |
There was a problem hiding this comment.
The key sequence token Plus is not used anywhere else in this repository’s key bindings, and M1+= already covers the common Ctrl+'+' (shift+'=') case while M1+NUMPAD_ADD covers the keypad. If Plus is not a recognized key name, this binding will be ignored at runtime. Consider removing this binding or replacing it with a verified/standard key token.
| sequence="M1+Plus"> | |
| </key> | |
| <key | |
| commandId="org.eclipse.ui.console.command.fontZoomIn" | |
| contextId="org.eclipse.ui.console.ConsoleView" | |
| schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" |
| categoryId="AnsiConsole.command.categoryid"> | ||
| </command> | ||
| <command | ||
| id="org.eclipse.ui.console.command.fontZoomOut" | ||
| name="%command.console.fontZoomOut.name" | ||
| description="%command.console.fontZoomOut.description" | ||
| categoryId="AnsiConsole.command.categoryid"> |
There was a problem hiding this comment.
These new zoom commands are categorized under AnsiConsole.command.categoryid ("ANSI Support Commands"), but zooming the console font is not ANSI-specific. This will make the commands appear under an incorrect/misleading category in the Keys preference page. Consider using a more appropriate category (e.g., org.eclipse.ui.category.edit) or introducing a dedicated Console category.
| categoryId="AnsiConsole.command.categoryid"> | |
| </command> | |
| <command | |
| id="org.eclipse.ui.console.command.fontZoomOut" | |
| name="%command.console.fontZoomOut.name" | |
| description="%command.console.fontZoomOut.description" | |
| categoryId="AnsiConsole.command.categoryid"> | |
| categoryId="org.eclipse.ui.category.edit"> | |
| </command> | |
| <command | |
| id="org.eclipse.ui.console.command.fontZoomOut" | |
| name="%command.console.fontZoomOut.name" | |
| description="%command.console.fontZoomOut.description" | |
| categoryId="org.eclipse.ui.category.edit"> |
-Add key listener on text widget of console view which listens ctrl plus and control minus(including numpad +/-)
-Zoom in/out of the console view text in steps based on the keys pressed.
see #2578