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.
74720eb to
21d419f
Compare
|
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. |
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.
cb6dbf0 to
0c77159
Compare
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.
-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
e1d88b4 to
8c76e12
Compare
iloveeclipse
left a comment
There was a problem hiding this comment.
Note: before pushing fixes, please rebase on master first.
|
|
||
| public static void applyZoom(Display display, int delta) { | ||
| // Capture the focused control. | ||
| Control focus = display.getFocusControl(); |
There was a problem hiding this comment.
I don't know if display.getFocusControl() is not working as expected, but I consistently see various issues with various consoles.
Try to play with 3 diffeent consoles:
- Run a simple Java code that outputs some stack trace - this will be the first console.
- Copy/paste this trace to "Java stack trace" console - second one.
- Open "Host OSGI Console" and type "help" there - third one.
Now open a text editor (Java code or just any plain txt file).
- If you "Ctrl +" or "Ctrl+-" in the process output console, it works fine and editor is not affected.
- If you "Ctrl +" or "Ctrl+-" in Java Stack Trace console, it automatically increases/decreases editor font size.
- If you "Ctrl +" or "Ctrl+-" in "Host OSGI Console", it increases font size in the process output console too, but not otherwise.
- And so on, just try with different consoles.
- If I open a second Console view, font sizes seem to be properly updated in all consoles, however "Java Stack Trace" page seem to also always change font size in the editor.
My expectations are:
- The editor font size should never change if we change font in Console via "Ctrl +" or "Ctrl+-". I guess the problem is that the Java Stack Trace does not properly sets the context and the handler "thinks" it is the editor context. This can7should be fixed in a separated JDT UI fix.
- The changes inside different Console pages should ideally work per page only, or (not so nice but acceptable) in all pages, but then at same time, and not via some random logic. So if I change the font size in the Console view, it is always applied consistently to either one or to all opened pages. I guess that switching Console pages doesn't always take the font size change into account if showing the previously hidden page.
| if (display == null) { | ||
| return; | ||
| } | ||
| display.syncExec(() -> applyZoom(display, delta)); |
There was a problem hiding this comment.
if Display.getCurrent() != null we are in UI thread already. Why do we need syncExec() then?
| } | ||
|
|
||
| // Update shared JFace registry so other listeners can observe the change | ||
| JFaceResources.getFontRegistry().put(DEBUG_CONSOLE_FONT_REGISTRY_KEY, newFontData); |
There was a problem hiding this comment.
This line is responsible for really awkward behavior of different consoles I've observed.
I've tested few consoles and they all behave differently. Looks like consoles from Platform are OK and consistent (process console & ant), but JDT is different (it reads the font set for Console but it also changes the font for the editor) and the Host OSGI Console (PDE) doesn't care at all about default console font, same as SpotBugs (not from eclipse.org).
On one side it makes sense, every contributed console can have their own font defined, on the other side, they could derive their font from the base one.
So ideally we should fix JDT console (which propagates font changes to the editor), and the PDE (which should derive the font from Console preferences). It would make sense to check if CDT build console need some fix and fix that too, but first let fix the platform.
All other 3rd party plugins should fix their code by themselves.
| } | ||
| FontData[] newFontData = fontData.clone(); | ||
| for (FontData fd : newFontData) { | ||
| if (fd != null) |
There was a problem hiding this comment.
Please always use blocks for if/for/while statements, independently how many lines are inside.
| } | ||
| FontData[] newFontData = fontData.clone(); | ||
| for (FontData fd : newFontData) { | ||
| if (fd != null) |
There was a problem hiding this comment.
Please always use blocks for if/for/while statements, independently how many lines are inside.
| private static final int STEP = 1; | ||
|
|
||
| @Override | ||
| public Object execute(ExecutionEvent event) throws ExecutionException { |
There was a problem hiding this comment.
Instead of overriding two methods, you can specify protected int getStep() in the super class and only override it here, or do what AbstractTextZoomHandler is doing and have an abstract class that does the job and two strivial handler classes specifying the increment in the constructor.
Also I wonder if the code similar to code in org.eclipse.ui.texteditor.AbstractTextZoomHandler.execute(ExecutionEvent) can be used here (instead of directly modifying StyledText`)?
| id="org.eclipse.ui.commands.toggleState"> | ||
| </state> | ||
| </command> | ||
| <command |
There was a problem hiding this comment.
These commands can be executed via "Ctrl+3", and guess what ... They change editor font, if it is currently active, or "Debug Shell" view font etc.
We need <enabledWhen> on the handler to restrict it to Console view only.
| id="org.eclipse.ui.commands.toggleState"> | ||
| </state> | ||
| </command> | ||
| <command |
There was a problem hiding this comment.
These commands can be executed via "Ctrl+3", and guess what ... They change current editor font, if editor is currently active, or "Debug Shell" view font etc.
We need <enabledWhen> on the handler to restrict it to Console view only.
| id="org.eclipse.ui.commands.toggleState"> | ||
| </state> | ||
| </command> | ||
| <command |
There was a problem hiding this comment.
These commands can be executed via "Ctrl+3", and guess what ... They change current editor font, if editor is currently active, or "Debug Shell" view font etc.
We need <enabledWhen> on the handler to restrict it to Console view only.
| id="org.eclipse.ui.commands.toggleState"> | ||
| </state> | ||
| </command> | ||
| <command |
There was a problem hiding this comment.
These commands can be executed via "Ctrl+3", and guess what ... They change current editor font, if editor is currently active, or "Debug Shell" view font etc.
We need <enabledWhen> on the handler to restrict it to Console view only.
iloveeclipse
left a comment
There was a problem hiding this comment.
Note: before pushing fixes, please rebase on master first.
iloveeclipse
left a comment
There was a problem hiding this comment.
Note: before pushing fixes, please rebase on master first.
-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