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   59m 47s ⏱️ + 2m 5s
 4 698 tests + 8   4 676 ✅ + 8   22 💤 ±0  0 ❌ ±0 
11 988 runs  +24  11 835 ✅ +24  153 💤 ±0  0 ❌ ±0 

Results for commit a5f5e6a. ± Comparison against base commit 77eecda.

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

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

Comment thread debug/org.eclipse.ui.console/src/org/eclipse/ui/console/ConsolePlugin.java Outdated
@raghucssit
raghucssit force-pushed the console_zoom_support branch from 2f6f049 to dda32dc Compare July 23, 2026 21:16
@raghucssit

Copy link
Copy Markdown
Contributor Author
  1. Now there is a per console page persisted font height(base height + delta). All the pages don't share common height. So If we zoom in ProcessConsole it applies only there and if we go to Stacktrace Console then it has it's own font. If we zoom at Stacktrace Console its zoom is persisted for it.
  2. If User changes the font in preference page then zoomed value is reset to preference value.
  3. persisted values are restored per console type.

@raghucssit
raghucssit force-pushed the console_zoom_support branch 2 times, most recently from 816b946 to 1250be0 Compare July 23, 2026 21:49
@iloveeclipse
iloveeclipse requested a review from Copilot July 24, 2026 13:02

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 5 out of 5 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java:362

  • applyHeight(...) adds FONT_ENFORCER on every zoom application. Because AbstractConsole#addPropertyChangeListener does not deduplicate listeners, repeated zoom steps will register the same listener multiple times, causing redundant onFontChanged(...) invocations and making removePropertyChangeListener on console removal insufficient.
		// make sure this console's font is (still) being watched, in case it was
		// registered before the zoom handler class got loaded, or the listener
		// was otherwise not yet attached
		textConsole.addPropertyChangeListener(FONT_ENFORCER);

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

Looks good.

Please resolve not yet addressed Copilot comments (test, font creation & disposal) and we are good to go.

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 6 out of 6 changed files in this pull request and generated 1 comment.

@raghucssit
raghucssit force-pushed the console_zoom_support branch from 86f9070 to c48c00d Compare July 27, 2026 22:18
* expose its preference key as public API.
*/
private static String getPersistedZoomState() throws ReflectiveOperationException {
Field prefKeyField = ConsoleZoomInHandler.class.getDeclaredField("PREF_ZOOM_FONT_HEIGHTS"); //$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.

Please if you already created helper function getStaticIntField, use it consistently.

But I would ask here instead: remove all the reflection and make all the required constants in ConsoleZoomInHandler public.

public void testRemovingConsoleDisposesZoomFont(TestInfo testInfo) throws Exception {
String type = uniqueConsoleType("disposeOnRemove"); //$NON-NLS-1$

IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

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.

The code which opens console view below repeats in every test. Please extract method for that.

handlerService.executeCommand("org.eclipse.ui.console.command.fontZoomIn", null); //$NON-NLS-1$
TestUtil.processUIEvents();

assertEquals(naturalHeight + 1, getFontHeight(console),

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.

The second command (zoom out) is not verified, but should

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.

And while writing this above, I've asked myself why do we need two handler classes at all, where second one doesn't do anything but just redirects to the first one with a different step?

Instead, we should have one ConsoleZoomHandler handler and parametrize that. Please check patch below which provides minimal changes (without rename to ConsoleZoomHandler for simplicity). Please apply it and rename the one handler to ConsoleZoomHandler & update Console tests to the new name.

diff --git a/debug/org.eclipse.ui.console/plugin.xml b/debug/org.eclipse.ui.console/plugin.xml
index 48cd9f4..a6a8aef 100644
--- a/debug/org.eclipse.ui.console/plugin.xml
+++ b/debug/org.eclipse.ui.console/plugin.xml
@@ -214,3 +214,3 @@
       <handler
-            class="org.eclipse.ui.internal.console.ConsoleZoomOutHandler"
+            class="org.eclipse.ui.internal.console.ConsoleZoomInHandler:-1"
             commandId="org.eclipse.ui.console.command.fontZoomOut">
diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java
index b7b2026..c3361fd 100644
--- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java
+++ b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomInHandler.java
@@ -22,2 +22,5 @@
 import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExecutableExtension;
 import org.eclipse.core.runtime.Status;
@@ -41,4 +44,4 @@
 /**
- * Command handler to increase the font size of the console currently shown in
- * the active console view.
+ * Command handler to increase or decrease the font size of the console
+ * currently shown in the active console view.
  * <p>
@@ -50,4 +53,11 @@
  * </p>
+ * <p>
+ * This single class backs both the zoom-in and zoom-out commands: the
+ * direction is supplied as executable extension data in {@code plugin.xml},
+ * e.g. {@code class="...ConsoleZoomInHandler:-1"} for zooming out. Each
+ * {@code <handler>} registration gets its own instance, so there is no shared
+ * mutable state between the two directions.
+ * </p>
  */
-public class ConsoleZoomInHandler extends AbstractHandler {
+public class ConsoleZoomInHandler extends AbstractHandler implements IExecutableExtension {
 
@@ -70,2 +80,10 @@
 	/**
+	 * The zoom direction/step size for this particular handler instance, in
+	 * points; positive to zoom in, negative to zoom out. Set from the
+	 * executable extension data configured in {@code plugin.xml} (defaults to
+	 * {@link #STEP}, i.e. zoom in, if none is provided).
+	 */
+	private int step = STEP;
+
+	/**
 	 * Key used, in the per-type persisted zoom string, for consoles that report a
@@ -269,5 +287,17 @@
 	@Override
+	public void setInitializationData(IConfigurationElement config, String propertyName, Object data)
+			throws CoreException {
+		if (data instanceof String stepData) {
+			try {
+				step = Integer.parseInt(stepData.trim());
+			} catch (NumberFormatException e) {
+				// keep default (zoom in) if the configured data is not a valid integer
+			}
+		}
+	}
+
+	@Override
 	public Object execute(ExecutionEvent event) throws ExecutionException {
 		IWorkbenchPart part = HandlerUtil.getActivePart(event);
-		applyZoom(part, STEP);
+		applyZoom(part, step);
 		return Status.OK_STATUS;
diff --git a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomOutHandler.java b/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomOutHandler.java
deleted file mode 100644
index aef9296..0000000
--- a/debug/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleZoomOutHandler.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2026 Advantest Europe GmbH and others.
- *
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
- * https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * 				Raghunandana Murthappa
- *******************************************************************************/
-package org.eclipse.ui.internal.console;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/**
- * Command handler to decrease the font size of the console currently shown in
- * the active console view.
- *
- * @see ConsoleZoomInHandler
- */
-public class ConsoleZoomOutHandler extends AbstractHandler {
-	private static final int STEP = 1;
-
-	@Override
-	public Object execute(ExecutionEvent event) throws ExecutionException {
-		IWorkbenchPart part = HandlerUtil.getActivePart(event);
-		ConsoleZoomInHandler.applyZoom(part, -STEP);
-		return Status.OK_STATUS;
-	}
-}

IViewPart consoleViewPart = activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW);
IConsoleView consoleView = (IConsoleView) consoleViewPart;

MessageConsole console = new MessageConsole("Zoom Dispose Console", type, null, //$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.

The code which creates and adds console to the manager below repeats in every test, just with different console names. Please extract method for that.

@raghucssit
raghucssit force-pushed the console_zoom_support branch from c48c00d to 2264409 Compare July 28, 2026 15:32
-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 2264409 to a5f5e6a Compare July 28, 2026 16:53
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