Skip to content

Add font zoom functionality to console view#2579

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

Add font zoom functionality to console view#2579
raghucssit wants to merge 1 commit into
eclipse-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

Copilot AI left a comment

Copy link
Copy Markdown

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

github-actions Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ±0      54 suites  ±0   57m 42s ⏱️ +47s
 4 687 tests ±0   4 665 ✅ ±0   22 💤 ±0  0 ❌ ±0 
11 955 runs  ±0  11 802 ✅ ±0  153 💤 ±0  0 ❌ ±0 

Results for commit 2f6f049. ± Comparison against base commit 00a2d52.

♻️ 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

Copilot AI left a comment

Copy link
Copy Markdown

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.

Copilot AI left a comment

Copy link
Copy Markdown

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
@raghucssit
raghucssit force-pushed the console_zoom_support branch from e1d88b4 to 8c76e12 Compare April 12, 2026 22:35

@iloveeclipse iloveeclipse left a comment

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.

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

}
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.

Comment thread debug/org.eclipse.ui.console/plugin.xml
Comment thread debug/org.eclipse.ui.console/plugin.xml
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.

Comment thread debug/org.eclipse.ui.console/plugin.xml

@iloveeclipse iloveeclipse left a comment

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.

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

@iloveeclipse iloveeclipse left a comment

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.

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

@raghucssit
raghucssit force-pushed the console_zoom_support branch from 8c76e12 to 5cc0461 Compare June 22, 2026 07:31
@raghucssit
raghucssit force-pushed the console_zoom_support branch from 5cc0461 to b114c03 Compare July 16, 2026 14:28
@iloveeclipse

Copy link
Copy Markdown
Member

@raghucssit : I don't see changes in the patch itself after last rebase you did?

-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 b114c03 to 2f6f049 Compare July 20, 2026 14:33
@raghucssit

raghucssit commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

I have fixed all the review comments and issues present at last review..
Current changes includes:

  1. Change in font size at one console page is reflected at all the pages that console has ( and also pages that later added to console). This is done with the help of page listener.
  2. Persistence of font between eclipse sessions. This is done using a non UI preference.
  3. Command is restricted using <enabledWhen> tag of the Handler.
  4. Using the async execution is needed because org.eclipse.debug.internal.ui.views.console.ProcessConsoleManager.launchChanged(ILaunch) starts a new ordinary Job(Not UIJob) which creates a new Console and add it to ConsoleManager. And ConsoleManager notifies listeners in the same non UI thread.

@raghucssit

Copy link
Copy Markdown
Contributor Author

Regarding bug that activates editor content on selection of Stacktrace Console has the below fix. I will create a separate issue at jdt debug repo and contribute below patch.

diff --git a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/console/JavaStackTracePageParticipant.java b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/console/JavaStackTracePageParticipant.java
index a46005d..ffe5977 100644
--- a/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/console/JavaStackTracePageParticipant.java
+++ b/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/console/JavaStackTracePageParticipant.java
@@ -24,8 +24,6 @@
 import org.eclipse.ui.console.IConsoleConstants;
 import org.eclipse.ui.console.IConsolePageParticipant;
 import org.eclipse.ui.console.actions.CloseConsoleAction;
-import org.eclipse.ui.contexts.IContextActivation;
-import org.eclipse.ui.contexts.IContextService;
 import org.eclipse.ui.handlers.IHandlerActivation;
 import org.eclipse.ui.handlers.IHandlerService;
 import org.eclipse.ui.part.IPageBookViewPage;
@@ -38,7 +36,6 @@
     private CloseConsoleAction fCloseAction;
     private FormatStackTraceActionDelegate fFormatAction;
     private IHandlerActivation fHandlerActivation;
-    private IContextActivation fContextActivation;
 
     /* (non-Javadoc)
      * @see org.eclipse.ui.console.IConsolePageParticipant#init(org.eclipse.ui.part.IPageBookViewPage, org.eclipse.ui.console.IConsole)
@@ -87,9 +84,11 @@
         };
 
         fHandlerActivation = handlerService.activateHandler("org.eclipse.jdt.ui.edit.text.java.format", formatHandler); //$NON-NLS-1$
-
-        IContextService contextService = workbench.getAdapter(IContextService.class);
-        fContextActivation = contextService.activateContext("org.eclipse.jdt.ui.javaEditorScope"); //$NON-NLS-1$
+        // Note: intentionally not activating the "org.eclipse.jdt.ui.javaEditorScope" context here.
+        // That context is a child of "org.eclipse.ui.textEditorScope", so activating it would make
+        // generic text editor key bindings (e.g. Ctrl+=/Ctrl+- zoom) take priority over this
+        // console's own key bindings (e.g. the console zoom commands) while this page is showing.
+        // The format action remains reachable via its context menu entry and the handler above.
 	}
 
 	/* (non-Javadoc)
@@ -104,11 +103,6 @@
 			handlerService.deactivateHandler(fHandlerActivation);
 			fHandlerActivation = null;
 		}
-        if (fContextActivation != null){
-        	IContextService contextService = workbench.getAdapter(IContextService.class);
-        	contextService.deactivateContext(fContextActivation);
-        	fContextActivation = null;
-        }
 	}
 
 }

@raghucssit

Copy link
Copy Markdown
Contributor Author

Stacktrace of the Exception if we don't use Display UI execution. Async is used to avoid any possible deadlocks.

org.eclipse.swt.SWTException: Unable to create font "org.eclipse.jface.textfont" in a non-UI thread. Using default font instead.
	at org.eclipse.jface.resource.FontRegistry.getFontRecord(FontRegistry.java:700)
	at org.eclipse.jface.resource.FontRegistry.get(FontRegistry.java:631)
	at org.eclipse.jface.resource.JFaceResources.getFont(JFaceResources.java:318)
	at org.eclipse.ui.console.TextConsole.getDefaultFont(TextConsole.java:271)
	at org.eclipse.ui.console.TextConsole.getFont(TextConsole.java:260)
	at org.eclipse.ui.internal.console.ConsoleZoomInHandler.applyHeight(ConsoleZoomInHandler.java:278)
	at org.eclipse.ui.internal.console.ConsoleZoomInHandler$1.consolesAdded(ConsoleZoomInHandler.java:132)
	at org.eclipse.ui.internal.console.ConsoleManager$ConsoleNotifier.run(ConsoleManager.java:151)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.ui.internal.console.ConsoleManager$ConsoleNotifier.notify(ConsoleManager.java:172)
	at org.eclipse.ui.internal.console.ConsoleManager.fireUpdate(ConsoleManager.java:248)
	at org.eclipse.ui.internal.console.ConsoleManager.addConsoles(ConsoleManager.java:215)
	at org.eclipse.debug.internal.ui.views.console.ProcessConsoleManager$ConsoleCreation.run(ProcessConsoleManager.java:80)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

@iloveeclipse iloveeclipse left a comment

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.

Quick review: have not tested yet, but I see some pieces that need to be fixed.

return ConsolePluginImages.getImageDescriptor(key);
}

@Override

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 remove this, just init the ZoomHandler on ConsoleManager startup

* zoom level, instead of resetting to the default size.</li>
* </ul>
*
* @since 3.17

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.

@since is only needed on API. This class is not API.

if (!(console instanceof TextConsole textConsole)) {
return;
}
int baseHeight;

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 check for display here and run any operation whic accesses Font & Co from UI thread only (call asyncExec() as you do it below).

* @param height the font height to apply, in points
*/
private static void applyHeight(TextConsole textConsole, int height) {
Display display = Display.getDefault();

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 this

Display display = Display.getDefault();
if (display.getThread() != Thread.currentThread()) 

please use if (Display.getCurrent() == null), here and in other places

return;
}
Display display = Display.getDefault();
if (display.getThread() != Thread.currentThread()) {

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 start the method with this check.

* Key used to remember, on the console itself, the custom font created for
* zooming, so it can be reused/replaced and eventually disposed.
*/
static final String ZOOM_FONT_ATTRIBUTE = ConsoleZoomInHandler.class.getName() + ".zoomFont"; //$NON-NLS-1$

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 would not store the "global" zoom font size but the zoomStep value as delta, and/or store the delta value per console type.

Every console can define its own font & size, and font sizes defined by different consoles may differ. Consoles may have individual font preferences settings which can be configured.

Current proposal increases font size for all consoles and sets it to the font size defined by the current console +- zoom step value. Also it enforces last zoomed value even if user changes console font size in preferences.

This all resuls in an unexpected behavior:

  1. If the current console has "unusual" font size and/or other consoles font size differ from the current one and if the user only wanted to change font size in the current console only. Here I would expect that if we apply zoom, we apply zoom delta (+-1 step) to the currently set font size in each console.
  2. If the user changes Console font size for some console to "20" in preferences but we already had "zoomed" to font size "10", it will stay at 10. I would expect that we rezet zoom delta once user changes the font size via preferences, so that whatever is chosen by user in preferences "wins".

return;
}
sZoomHeight = Integer.valueOf(newHeight);
persistZoomHeight(newHeight);

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.

Actually the code above can be removed entirely and we can simply iterate over all consoles below, applying the zoom step to each console font size (not the font size of the current console)

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