Skip to content

Add font zoom functionality to console view#2579

Open
raghucssit wants to merge 1 commit intoeclipse-platform:masterfrom
raghucssit:console_zoom_support
Open

Add font zoom functionality to console view#2579
raghucssit wants to merge 1 commit intoeclipse-platform:masterfrom
raghucssit:console_zoom_support

Conversation

@raghucssit
Copy link
Copy Markdown
Contributor

-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

Copilot AI review requested due to automatic review settings March 18, 2026 21:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 StyledText to 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.

Comment thread debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 18, 2026

Test Results

    54 files  ±0      54 suites  ±0   34m 37s ⏱️ - 1m 23s
 4 558 tests ±0   4 535 ✅ +1   23 💤 ±0  0 ❌  - 1 
12 270 runs  ±0  12 111 ✅ +1  159 💤 ±0  0 ❌  - 1 

Results for commit 8c76e12. ± Comparison against base commit 0eda9f4.

♻️ This comment has been updated with latest results.

@raghucssit raghucssit force-pushed the console_zoom_support branch from 74720eb to 21d419f Compare March 19, 2026 15:57
Comment thread debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java Outdated
@iloveeclipse
Copy link
Copy Markdown
Member

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 IConsole.getType() as part of the key.

@raghucssit raghucssit force-pushed the console_zoom_support branch from 21d419f to c051ad1 Compare March 24, 2026 08:49
@raghucssit
Copy link
Copy Markdown
Contributor Author

@trancexpress Please check this PR.

@trancexpress
Copy link
Copy Markdown
Contributor

With:

Eclipse SDK
Version: 2026-06 (4.40)
Build id: I20260323-1800

The Console view can be zoomed when I'm in the Java editor and I press: Ctrl and =

The change here makes me press Ctrl+ though, i.e. Ctrl and Shift and =. That seems odd. For Ctrl - its the same.

The Java editor zoom in / zoom out resets whatever the zoom level was in the console, which is probably OK.

Comment thread debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 StyledText to 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.

Comment thread debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java Outdated
Comment thread debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java Outdated
Comment thread debug/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java Outdated
@raghucssit raghucssit force-pushed the console_zoom_support branch 2 times, most recently from cb6dbf0 to 0c77159 Compare March 25, 2026 16:04
@raghucssit raghucssit force-pushed the console_zoom_support branch 3 times, most recently from 9dd0a16 to e1d88b4 Compare April 7, 2026 23:51
@raghucssit
Copy link
Copy Markdown
Contributor Author

@iloveeclipse Please check this PR.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment thread debug/org.eclipse.ui.console/src/org/eclipse/ui/console/ConsoleZoomInHandler.java Outdated
Comment thread debug/org.eclipse.ui.console/src/org/eclipse/ui/console/ConsoleZoomInHandler.java Outdated
Comment thread debug/org.eclipse.ui.console/plugin.xml Outdated
Comment thread debug/org.eclipse.ui.console/plugin.xml Outdated
-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
@raghucssit raghucssit force-pushed the console_zoom_support branch from e1d88b4 to 8c76e12 Compare April 12, 2026 22:35
Copy link
Copy Markdown
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

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

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();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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:

  1. Run a simple Java code that outputs some stack trace - this will be the first console.
  2. Copy/paste this trace to "Java stack trace" console - second one.
  3. Open "Host OSGI Console" and type "help" there - third one.

Now open a text editor (Java code or just any plain txt file).

  1. If you "Ctrl +" or "Ctrl+-" in the process output console, it works fine and editor is not affected.
  2. If you "Ctrl +" or "Ctrl+-" in Java Stack Trace console, it automatically increases/decreases editor font size.
  3. If you "Ctrl +" or "Ctrl+-" in "Host OSGI Console", it increases font size in the process output console too, but not otherwise.
  4. And so on, just try with different consoles.
  5. 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:

  1. 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.
  2. 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));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

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

Note: before pushing fixes, please rebase on master first.

Copy link
Copy Markdown
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

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

Note: before pushing fixes, please rebase on master first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants