Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions debug/org.eclipse.ui.console/plugin.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ command.copy_without_escapes.name = Copy Text Without ANSI Escapes
command.copy_without_escapes.description = Copy the console content to clipboard, removing the escape sequences
command.enable_disable.name = Enable / Disable ANSI Support
command.enable_disable.description = Enable / disable ANSI Support
command.console.fontZoomIn.name = Zoom In Console Font
command.console.fontZoomIn.description = Increase the console font size
command.console.fontZoomOut.name = Zoom Out Console Font
command.console.fontZoomOut.description = Decrease the console font size
53 changes: 53 additions & 0 deletions debug/org.eclipse.ui.console/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,36 @@ M4 = Platform-specific fourth key
sequence="M1+M2+Insert">
</key>
-->
<key
commandId="org.eclipse.ui.console.command.fontZoomIn"
contextId="org.eclipse.ui.console.ConsoleView"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+=">
</key>
<key
commandId="org.eclipse.ui.console.command.fontZoomIn"
contextId="org.eclipse.ui.console.ConsoleView"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+Plus">
</key>
<key
commandId="org.eclipse.ui.console.command.fontZoomIn"
contextId="org.eclipse.ui.console.ConsoleView"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
Comment on lines +104 to +109
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
sequence="M1+Plus">
</key>
<key
commandId="org.eclipse.ui.console.command.fontZoomIn"
contextId="org.eclipse.ui.console.ConsoleView"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"

Copilot uses AI. Check for mistakes.
sequence="M1+NUMPAD_ADD">
</key>
<key
commandId="org.eclipse.ui.console.command.fontZoomOut"
contextId="org.eclipse.ui.console.ConsoleView"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+-">
</key>
<key
commandId="org.eclipse.ui.console.command.fontZoomOut"
contextId="org.eclipse.ui.console.ConsoleView"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+NUMPAD_SUBTRACT">
</key>
</extension>

<extension
Expand Down Expand Up @@ -157,6 +187,29 @@ M4 = Platform-specific fourth key
id="org.eclipse.ui.commands.toggleState">
</state>
</command>
<command
id="org.eclipse.ui.console.command.fontZoomIn"
name="%command.console.fontZoomIn.name"
description="%command.console.fontZoomIn.description"
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">
Comment on lines +194 to +200
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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">

Copilot uses AI. Check for mistakes.
</command>
</extension>

<extension point="org.eclipse.ui.handlers">
<handler
class="org.eclipse.ui.console.ConsoleZoomInHandler"
commandId="org.eclipse.ui.console.command.fontZoomIn">
</handler>
<handler
class="org.eclipse.ui.console.ConsoleZoomOutHandler"
commandId="org.eclipse.ui.console.command.fontZoomOut">
</handler>
</extension>

<extension point="org.eclipse.ui.preferencePages">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*******************************************************************************
* 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.console;

import org.eclipse.core.commands.AbstractHandler;
Comment on lines +14 to +16
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Display;

/**
* Command handler to increase the font size of the focused console StyledText.
*
* @since 3.17
*/
public class ConsoleZoomInHandler extends AbstractHandler {
private static final String ZOOM_FONT_KEY = TextConsolePage.class.getName() + ".zoomFont"; //$NON-NLS-1$
private static final String DEBUG_CONSOLE_FONT_REGISTRY_KEY = "org.eclipse.debug.ui.consoleFont"; //$NON-NLS-1$
private static final int MIN_FONT_SIZE = 6;
private static final int MAX_FONT_SIZE = 72;
private static final int STEP = 1;

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
changeFocusedFont(STEP);
return null;
}

private void changeFocusedFont(int delta) {
Comment on lines +37 to +43
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
Display display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
Display d = display;
d.asyncExec(() -> {
Comment on lines +44 to +49
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
StyledText st = d.getFocusControl() instanceof StyledText ? (StyledText) d.getFocusControl() : null;
if (st == null || st.isDisposed()) {
return;
}
Font current = st.getFont();
if (current == null || current.isDisposed()) {
return;
}
FontData[] fontData = current.getFontData();
if (fontData == null || fontData.length == 0) {
return;
}
int currentHeight = fontData[0].getHeight();
int newHeight = Math.max(MIN_FONT_SIZE, Math.min(MAX_FONT_SIZE, currentHeight + delta));
if (newHeight == currentHeight) {
return;
}
FontData[] newFontData = fontData.clone();
for (FontData fd : newFontData) {
if (fd != null)
fd.setHeight(newHeight);
}

Font oldZoom = (Font) st.getData(ZOOM_FONT_KEY);
Font newZoom = new Font(st.getDisplay(), newFontData);
st.setFont(newZoom);
st.setData(ZOOM_FONT_KEY, newZoom);
if (oldZoom == null) {
st.addDisposeListener(e -> {
Font z = (Font) st.getData(ZOOM_FONT_KEY);
if (z != null && !z.isDisposed())
z.dispose();
});
}
if (oldZoom != null && !oldZoom.isDisposed()) {
oldZoom.dispose();
}

// Update shared JFace registry so other listeners can observe the change
JFaceResources.getFontRegistry().put(DEBUG_CONSOLE_FONT_REGISTRY_KEY, newFontData);
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*******************************************************************************
* 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.console;

import org.eclipse.core.commands.AbstractHandler;
Comment on lines +14 to +16
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.Display;

/**
* Command handler to decrease the font size of the focused console StyledText.
*
* @since 3.17
*/
public class ConsoleZoomOutHandler extends AbstractHandler {
private static final String ZOOM_FONT_KEY = TextConsolePage.class.getName() + ".zoomFont"; //$NON-NLS-1$
private static final String DEBUG_CONSOLE_FONT_REGISTRY_KEY = "org.eclipse.debug.ui.consoleFont"; //$NON-NLS-1$
private static final int MIN_FONT_SIZE = 6;
private static final int MAX_FONT_SIZE = 72;
private static final int STEP = 1;

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
changeFocusedFont(-STEP);
return null;
}

private void changeFocusedFont(int 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;
Comment on lines +44 to +50
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
if (st == null || st.isDisposed()) {
return;
}
Font current = st.getFont();
if (current == null || current.isDisposed()) {
return;
}
FontData[] fontData = current.getFontData();
if (fontData == null || fontData.length == 0) {
return;
}
int currentHeight = fontData[0].getHeight();
int newHeight = Math.max(MIN_FONT_SIZE, Math.min(MAX_FONT_SIZE, currentHeight + delta));
if (newHeight == currentHeight) {
return;
}
FontData[] newFontData = fontData.clone();
for (FontData fd : newFontData) {
if (fd != null)
fd.setHeight(newHeight);
}

Font oldZoom = (Font) st.getData(ZOOM_FONT_KEY);
Font newZoom = new Font(st.getDisplay(), newFontData);
st.setFont(newZoom);
st.setData(ZOOM_FONT_KEY, newZoom);
if (oldZoom == null) {
st.addDisposeListener(e -> {
Font z = (Font) st.getData(ZOOM_FONT_KEY);
if (z != null && !z.isDisposed())
z.dispose();
});
}
if (oldZoom != null && !oldZoom.isDisposed()) {
oldZoom.dispose();
}
// Update shared JFace registry so other listeners can observe the change
JFaceResources.getFontRegistry().put(DEBUG_CONSOLE_FONT_REGISTRY_KEY, newFontData);
});
}
}
Loading