mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 303808: Add a Preference page for GDB CLI consoles
In addition, a new "Preferences" Action is available for the GDB CLI consoles so the user can easily find/adjust them. Change-Id: I8d2756683f92ca9b42454906dd600c97e1e07cd2 Signed-off-by: Alvaro Sanchez-Leon <alvsan09@gmail.com>
This commit is contained in:
parent
1cfa38948c
commit
b63adf43db
17 changed files with 277 additions and 73 deletions
|
@ -61,3 +61,6 @@ command.connect.description = Connect to selected processes
|
||||||
command.connect.name = Connect
|
command.connect.name = Connect
|
||||||
command.connect.label = Connect
|
command.connect.label = Connect
|
||||||
command.connect.tooltip = Connect to process
|
command.connect.tooltip = Connect to process
|
||||||
|
|
||||||
|
# GDB CLI Console
|
||||||
|
console.preferences.name = Console
|
|
@ -524,6 +524,12 @@
|
||||||
id="org.eclipse.cdt.dsf.gdb.ui.preferences.reversedebugpreferences"
|
id="org.eclipse.cdt.dsf.gdb.ui.preferences.reversedebugpreferences"
|
||||||
name="%reverseDebugPreferences.name">
|
name="%reverseDebugPreferences.name">
|
||||||
</page>
|
</page>
|
||||||
|
<page
|
||||||
|
category="org.eclipse.cdt.dsf.gdb.ui.preferences"
|
||||||
|
class="org.eclipse.cdt.dsf.gdb.internal.ui.preferences.GdbConsolePreferencePage"
|
||||||
|
id="org.eclipse.cdt.dsf.gdb.ui.preferences.console.GdbConsolePreferencePage"
|
||||||
|
name="%console.preferences.name">
|
||||||
|
</page>
|
||||||
</extension>
|
</extension>
|
||||||
<extension
|
<extension
|
||||||
point="org.eclipse.ui.console.consolePageParticipants">
|
point="org.eclipse.ui.console.consolePageParticipants">
|
||||||
|
|
|
@ -49,6 +49,8 @@ public class ConsoleMessages extends NLS {
|
||||||
public static String ConsoleAutoTerminateAction_name;
|
public static String ConsoleAutoTerminateAction_name;
|
||||||
public static String ConsoleAutoTerminateAction_description;
|
public static String ConsoleAutoTerminateAction_description;
|
||||||
|
|
||||||
|
public static String GdbConsolePreferences_name;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(ConsoleMessages.class.getName(), ConsoleMessages.class);
|
NLS.initializeMessages(ConsoleMessages.class.getName(), ConsoleMessages.class);
|
||||||
|
|
|
@ -41,3 +41,5 @@ ConsoleSelectAllAction_description=Select All available text in the associated c
|
||||||
|
|
||||||
ConsoleAutoTerminateAction_name=Terminate GDB when last process exits
|
ConsoleAutoTerminateAction_name=Terminate GDB when last process exits
|
||||||
ConsoleAutoTerminateAction_description=Automatically terminate GDB when the last process being debugged exits
|
ConsoleAutoTerminateAction_description=Automatically terminate GDB when the last process being debugged exits
|
||||||
|
|
||||||
|
GdbConsolePreferences_name=Preferences...
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2016 Ericsson and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
|
||||||
|
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
|
|
||||||
|
public abstract class GdbAbstractConsolePreferenceListener implements IPropertyChangeListener {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
|
String property = event.getProperty();
|
||||||
|
|
||||||
|
if (property.equals(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB)) {
|
||||||
|
String terminateStr = event.getNewValue().toString();
|
||||||
|
boolean terminate = terminateStr.equals(Boolean.FALSE.toString()) ? false : true;
|
||||||
|
handleAutoTerminatePref(terminate);
|
||||||
|
} else if (property.equals(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS)) {
|
||||||
|
boolean enabled = Platform.getPreferencesService().getBoolean(GdbPlugin.PLUGIN_ID, IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS, IGdbDebugPreferenceConstants.CONSOLE_INVERTED_COLORS_DEFAULT, null);
|
||||||
|
handleInvertColorsPref(enabled);
|
||||||
|
} else if (property.equals(IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES)) {
|
||||||
|
int bufferLines = Platform.getPreferencesService().getInt(GdbPlugin.PLUGIN_ID, IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES, IGdbDebugPreferenceConstants.CONSOLE_BUFFERLINES_DEFAULT, null);
|
||||||
|
handleBufferLinesPref(bufferLines);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void handleAutoTerminatePref(boolean enabled);
|
||||||
|
protected abstract void handleInvertColorsPref(boolean enabled);
|
||||||
|
protected abstract void handleBufferLinesPref(int bufferLines);
|
||||||
|
}
|
|
@ -37,7 +37,13 @@ import org.eclipse.ui.part.IPageBookViewPage;
|
||||||
* towards GDB. It is used whenever {@link IGDBBackend#isFullGdbConsoleSupported()}
|
* towards GDB. It is used whenever {@link IGDBBackend#isFullGdbConsoleSupported()}
|
||||||
* returns false.
|
* returns false.
|
||||||
*/
|
*/
|
||||||
public class GdbBasicCliConsole extends IOConsole implements IDebuggerConsole, IGdbCliConsole {
|
public class GdbBasicCliConsole extends IOConsole implements IDebuggerConsole {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A conversion factor used to resolve number of characters from number of lines
|
||||||
|
*/
|
||||||
|
private final static int CHARS_PER_LINE_AVG = 80;
|
||||||
|
private final static int HIGH_WATERMARK_OFFSET_CHARS = 8000;
|
||||||
|
|
||||||
private final ILaunch fLaunch;
|
private final ILaunch fLaunch;
|
||||||
private final String fLabel;
|
private final String fLabel;
|
||||||
|
@ -45,6 +51,24 @@ public class GdbBasicCliConsole extends IOConsole implements IDebuggerConsole, I
|
||||||
private final IOConsoleOutputStream fOutputStream;
|
private final IOConsoleOutputStream fOutputStream;
|
||||||
private final IOConsoleOutputStream fErrorStream;
|
private final IOConsoleOutputStream fErrorStream;
|
||||||
|
|
||||||
|
private GdbAbstractConsolePreferenceListener fPreferenceListener = new GdbAbstractConsolePreferenceListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleAutoTerminatePref(boolean enabled) {
|
||||||
|
// Nothing to do for this class
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleInvertColorsPref(boolean enabled) {
|
||||||
|
setInvertedColors(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleBufferLinesPref(int bufferLines) {
|
||||||
|
setBufferLineLimit(bufferLines);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public GdbBasicCliConsole(ILaunch launch, String label, Process process) {
|
public GdbBasicCliConsole(ILaunch launch, String label, Process process) {
|
||||||
super("", null, null, false); //$NON-NLS-1$
|
super("", null, null, false); //$NON-NLS-1$
|
||||||
fLaunch = launch;
|
fLaunch = launch;
|
||||||
|
@ -58,8 +82,10 @@ public class GdbBasicCliConsole extends IOConsole implements IDebuggerConsole, I
|
||||||
// Create a lifecycle listener to call init() and dispose()
|
// Create a lifecycle listener to call init() and dispose()
|
||||||
new GdbConsoleLifecycleListener(this);
|
new GdbConsoleLifecycleListener(this);
|
||||||
|
|
||||||
|
GdbUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener);
|
||||||
|
|
||||||
resetName();
|
resetName();
|
||||||
setColors();
|
setDefaults();
|
||||||
|
|
||||||
new InputReadJob().schedule();
|
new InputReadJob().schedule();
|
||||||
new OutputReadJob().schedule();
|
new OutputReadJob().schedule();
|
||||||
|
@ -77,19 +103,22 @@ public class GdbBasicCliConsole extends IOConsole implements IDebuggerConsole, I
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
|
||||||
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setColors() {
|
private void setDefaults() {
|
||||||
// Set the inverted colors option based on the stored preference
|
|
||||||
IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore();
|
IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore();
|
||||||
boolean enabled = store.getBoolean(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS);
|
boolean enabled = store.getBoolean(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS);
|
||||||
|
int bufferLines = store.getInt(IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES);
|
||||||
|
|
||||||
Display.getDefault().asyncExec(() -> {
|
Display.getDefault().asyncExec(() -> {
|
||||||
getInputStream().setColor(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
|
getInputStream().setColor(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
|
||||||
fErrorStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
fErrorStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
|
||||||
|
|
||||||
setInvertedColors(enabled);
|
setInvertedColors(enabled);
|
||||||
|
setBufferLineLimit(bufferLines);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,8 +181,7 @@ public class GdbBasicCliConsole extends IOConsole implements IDebuggerConsole, I
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void setInvertedColors(boolean enable) {
|
||||||
public void setInvertedColors(boolean enable) {
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
|
||||||
fOutputStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
|
fOutputStream.setColor(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
|
||||||
|
@ -163,6 +191,14 @@ public class GdbBasicCliConsole extends IOConsole implements IDebuggerConsole, I
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setBufferLineLimit(int bufferLines) {
|
||||||
|
int chars = bufferLines * CHARS_PER_LINE_AVG;
|
||||||
|
// The buffer will be allowed to grow up-to the high watermark.
|
||||||
|
// When high watermark is passed, it will be trimmed-down to the low watermark.
|
||||||
|
// So here add an extra buffer for high watermark.
|
||||||
|
setWaterMarks(chars, chars + HIGH_WATERMARK_OFFSET_CHARS);
|
||||||
|
}
|
||||||
|
|
||||||
private class InputReadJob extends Job {
|
private class InputReadJob extends Job {
|
||||||
{
|
{
|
||||||
setSystem(true);
|
setSystem(true);
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||||
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||||
import org.eclipse.jface.action.IMenuManager;
|
import org.eclipse.jface.action.IMenuManager;
|
||||||
import org.eclipse.jface.action.IToolBarManager;
|
import org.eclipse.jface.action.IToolBarManager;
|
||||||
|
import org.eclipse.jface.action.Separator;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.ui.console.IConsoleView;
|
import org.eclipse.ui.console.IConsoleView;
|
||||||
import org.eclipse.ui.internal.console.IOConsolePage;
|
import org.eclipse.ui.internal.console.IOConsolePage;
|
||||||
|
@ -29,6 +30,7 @@ public class GdbBasicCliConsolePage extends IOConsolePage implements IDebugConte
|
||||||
|
|
||||||
private GdbConsoleInvertColorsAction fInvertColorsAction;
|
private GdbConsoleInvertColorsAction fInvertColorsAction;
|
||||||
private GdbConsoleTerminateLaunchAction fTerminateLaunchAction;
|
private GdbConsoleTerminateLaunchAction fTerminateLaunchAction;
|
||||||
|
private GdbConsoleShowPreferencesAction fShowPreferencePageAction;
|
||||||
|
|
||||||
public GdbBasicCliConsolePage(GdbBasicCliConsole gdbConsole, IConsoleView view) {
|
public GdbBasicCliConsolePage(GdbBasicCliConsole gdbConsole, IConsoleView view) {
|
||||||
super(gdbConsole, view);
|
super(gdbConsole, view);
|
||||||
|
@ -58,12 +60,15 @@ public class GdbBasicCliConsolePage extends IOConsolePage implements IDebugConte
|
||||||
protected void createActions() {
|
protected void createActions() {
|
||||||
fInvertColorsAction = new GdbConsoleInvertColorsAction();
|
fInvertColorsAction = new GdbConsoleInvertColorsAction();
|
||||||
fTerminateLaunchAction = new GdbConsoleTerminateLaunchAction(fLaunch);
|
fTerminateLaunchAction = new GdbConsoleTerminateLaunchAction(fLaunch);
|
||||||
|
fShowPreferencePageAction = new GdbConsoleShowPreferencesAction(getSite().getShell());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void contextMenuAboutToShow(IMenuManager menuManager) {
|
protected void contextMenuAboutToShow(IMenuManager menuManager) {
|
||||||
menuManager.add(fTerminateLaunchAction);
|
menuManager.add(fTerminateLaunchAction);
|
||||||
menuManager.add(fInvertColorsAction);
|
menuManager.add(fInvertColorsAction);
|
||||||
|
menuManager.add(new Separator());
|
||||||
|
menuManager.add(fShowPreferencePageAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
|
||||||
import org.eclipse.cdt.debug.ui.debuggerconsole.IDebuggerConsole;
|
|
||||||
import org.eclipse.cdt.debug.ui.debuggerconsole.IDebuggerConsoleManager;
|
|
||||||
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
|
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
|
||||||
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
|
||||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||||
|
@ -38,12 +35,5 @@ public class GdbConsoleInvertColorsAction extends Action {
|
||||||
preferences.flush();
|
preferences.flush();
|
||||||
} catch (BackingStoreException e) {
|
} catch (BackingStoreException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
IDebuggerConsoleManager manager = CDebugUIPlugin.getDebuggerConsoleManager();
|
|
||||||
for (IDebuggerConsole console : manager.getConsoles()) {
|
|
||||||
if (console instanceof IGdbCliConsole) {
|
|
||||||
((IGdbCliConsole)console).setInvertedColors(!enabled);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2016 Ericsson AB and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
||||||
|
|
||||||
|
import org.eclipse.jface.action.Action;
|
||||||
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
import org.eclipse.ui.dialogs.PreferencesUtil;
|
||||||
|
|
||||||
|
public class GdbConsoleShowPreferencesAction extends Action {
|
||||||
|
private final static String PREF_PAGE_ID = "org.eclipse.cdt.dsf.gdb.ui.preferences.console.GdbConsolePreferencePage"; //$NON-NLS-1$
|
||||||
|
private final Shell fShell;
|
||||||
|
|
||||||
|
public GdbConsoleShowPreferencesAction(Shell shell) {
|
||||||
|
fShell = shell;
|
||||||
|
setText(ConsoleMessages.GdbConsolePreferences_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
PreferencesUtil.createPreferenceDialogOn(fShell, PREF_PAGE_ID, new String[] { PREF_PAGE_ID }, null).open();
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,7 +36,7 @@ import org.eclipse.ui.part.IPageBookViewPage;
|
||||||
* full-featured CLI interface. This is only supported with GDB >= 7.12
|
* full-featured CLI interface. This is only supported with GDB >= 7.12
|
||||||
* and if IGDBBackend.isFullGdbConsoleSupported() returns true.
|
* and if IGDBBackend.isFullGdbConsoleSupported() returns true.
|
||||||
*/
|
*/
|
||||||
public class GdbFullCliConsole extends AbstractConsole implements IDebuggerConsole, IGdbCliConsole {
|
public class GdbFullCliConsole extends AbstractConsole implements IDebuggerConsole {
|
||||||
private final ILaunch fLaunch;
|
private final ILaunch fLaunch;
|
||||||
private final String fLabel;
|
private final String fLabel;
|
||||||
private final PTY fGdbPty;
|
private final PTY fGdbPty;
|
||||||
|
@ -203,13 +203,6 @@ public class GdbFullCliConsole extends AbstractConsole implements IDebuggerConso
|
||||||
return fConsolePage;
|
return fConsolePage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setInvertedColors(boolean enable) {
|
|
||||||
if (fConsolePage != null) {
|
|
||||||
fConsolePage.setInvertedColors(enable);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IGdbTerminalControlConnector getTerminalControlConnector() {
|
public IGdbTerminalControlConnector getTerminalControlConnector() {
|
||||||
return fTerminalConnector;
|
return fTerminalConnector;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,6 @@ import org.eclipse.jface.action.IToolBarManager;
|
||||||
import org.eclipse.jface.action.MenuManager;
|
import org.eclipse.jface.action.MenuManager;
|
||||||
import org.eclipse.jface.action.Separator;
|
import org.eclipse.jface.action.Separator;
|
||||||
import org.eclipse.jface.preference.IPreferenceStore;
|
import org.eclipse.jface.preference.IPreferenceStore;
|
||||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.layout.FillLayout;
|
import org.eclipse.swt.layout.FillLayout;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
@ -67,8 +65,27 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
private GdbConsoleSelectAllAction fSelectAllAction;
|
private GdbConsoleSelectAllAction fSelectAllAction;
|
||||||
private GdbAutoTerminateAction fAutoTerminateAction;
|
private GdbAutoTerminateAction fAutoTerminateAction;
|
||||||
|
|
||||||
private IPropertyChangeListener fConsolePropertyChangeListener;
|
private GdbConsoleShowPreferencesAction fShowPreferencePageAction;
|
||||||
|
|
||||||
|
private GdbAbstractConsolePreferenceListener fPreferenceListener = new GdbAbstractConsolePreferenceListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleAutoTerminatePref(boolean enabled) {
|
||||||
|
if (fAutoTerminateAction != null) {
|
||||||
|
fAutoTerminateAction.setChecked(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleInvertColorsPref(boolean enabled) {
|
||||||
|
setInvertedColors(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleBufferLinesPref(int bufferLines) {
|
||||||
|
setBufferLineLimit(bufferLines);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public GdbFullCliConsolePage(GdbFullCliConsole gdbConsole, IDebuggerConsoleView view, PTY pty) {
|
public GdbFullCliConsolePage(GdbFullCliConsole gdbConsole, IDebuggerConsoleView view, PTY pty) {
|
||||||
fConsole = gdbConsole;
|
fConsole = gdbConsole;
|
||||||
|
@ -77,18 +94,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
fLaunch = gdbConsole.getLaunch();
|
fLaunch = gdbConsole.getLaunch();
|
||||||
fGdbPty = pty;
|
fGdbPty = pty;
|
||||||
|
|
||||||
fConsolePropertyChangeListener = new IPropertyChangeListener() {
|
GdbUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fPreferenceListener);
|
||||||
@Override
|
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
|
||||||
if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB) && fAutoTerminateAction != null) {
|
|
||||||
String terminateStr = event.getNewValue().toString();
|
|
||||||
boolean terminate = terminateStr.equals(Boolean.FALSE.toString()) ? false : true;
|
|
||||||
fAutoTerminateAction.setChecked(terminate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GdbUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(fConsolePropertyChangeListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -98,8 +104,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
getSite().getWorkbenchWindow()).removeDebugContextListener(this);
|
getSite().getWorkbenchWindow()).removeDebugContextListener(this);
|
||||||
fTerminalControl.disposeTerminal();
|
fTerminalControl.disposeTerminal();
|
||||||
fMenuManager.dispose();
|
fMenuManager.dispose();
|
||||||
|
GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPreferenceListener);
|
||||||
GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fConsolePropertyChangeListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,8 +121,16 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
configureToolBar(getSite().getActionBars().getToolBarManager());
|
configureToolBar(getSite().getActionBars().getToolBarManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setDefaults() {
|
||||||
|
IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore();
|
||||||
|
setInvertedColors(store.getBoolean(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS));
|
||||||
|
setBufferLineLimit(store.getInt(IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES));
|
||||||
|
}
|
||||||
|
|
||||||
private void createTerminalControl() {
|
private void createTerminalControl() {
|
||||||
// Create the terminal control that will be used to interact with GDB
|
// Create the terminal control that will be used to interact with GDB
|
||||||
|
// Don't use common terminal preferences as GDB consoles are having their own
|
||||||
|
boolean useCommonPrefs = false;
|
||||||
fTerminalControl = TerminalViewControlFactory.makeControl(
|
fTerminalControl = TerminalViewControlFactory.makeControl(
|
||||||
new ITerminalListener() {
|
new ITerminalListener() {
|
||||||
@Override public void setState(TerminalState state) {}
|
@Override public void setState(TerminalState state) {}
|
||||||
|
@ -125,7 +138,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
},
|
},
|
||||||
fMainComposite,
|
fMainComposite,
|
||||||
new ITerminalConnector[] {},
|
new ITerminalConnector[] {},
|
||||||
true);
|
useCommonPrefs);
|
||||||
|
|
||||||
fTerminalControl.setConnector(new GdbTerminalPageConnector(fGdbTerminalControlConnector, fGdbPty));
|
fTerminalControl.setConnector(new GdbTerminalPageConnector(fGdbTerminalControlConnector, fGdbPty));
|
||||||
|
|
||||||
|
@ -133,15 +146,11 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
fTerminalControl.setEncoding(Charset.defaultCharset().name());
|
fTerminalControl.setEncoding(Charset.defaultCharset().name());
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fTerminalControl instanceof ITerminalControl) {
|
if (fTerminalControl instanceof ITerminalControl) {
|
||||||
((ITerminalControl)fTerminalControl).setConnectOnEnterIfClosed(false);
|
((ITerminalControl)fTerminalControl).setConnectOnEnterIfClosed(false);
|
||||||
((ITerminalControl)fTerminalControl).setVT100LineWrapping(true);
|
((ITerminalControl)fTerminalControl).setVT100LineWrapping(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the inverted colors option based on the stored preference
|
|
||||||
IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore();
|
|
||||||
setInvertedColors(store.getBoolean(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS));
|
|
||||||
|
|
||||||
// Must use syncExec because the logic within must complete before the rest
|
// Must use syncExec because the logic within must complete before the rest
|
||||||
// of the class methods (specifically getProcess()) is called
|
// of the class methods (specifically getProcess()) is called
|
||||||
|
@ -151,6 +160,10 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
if (fTerminalControl != null && !fTerminalControl.isDisposed()) {
|
if (fTerminalControl != null && !fTerminalControl.isDisposed()) {
|
||||||
fTerminalControl.clearTerminal();
|
fTerminalControl.clearTerminal();
|
||||||
fTerminalControl.connectTerminal();
|
fTerminalControl.connectTerminal();
|
||||||
|
|
||||||
|
// The actual terminal widget initializes its defaults in the line above,
|
||||||
|
// lets override them with our application defaults right after.
|
||||||
|
setDefaults();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -177,6 +190,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
fScrollLockAction = new GdbConsoleScrollLockAction(fTerminalControl);
|
fScrollLockAction = new GdbConsoleScrollLockAction(fTerminalControl);
|
||||||
fSelectAllAction = new GdbConsoleSelectAllAction(fTerminalControl);
|
fSelectAllAction = new GdbConsoleSelectAllAction(fTerminalControl);
|
||||||
fAutoTerminateAction = new GdbAutoTerminateAction();
|
fAutoTerminateAction = new GdbAutoTerminateAction();
|
||||||
|
fShowPreferencePageAction = new GdbConsoleShowPreferencesAction(getSite().getShell());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void configureToolBar(IToolBarManager mgr) {
|
protected void configureToolBar(IToolBarManager mgr) {
|
||||||
|
@ -200,6 +214,9 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
menuManager.add(fTerminateLaunchAction);
|
menuManager.add(fTerminateLaunchAction);
|
||||||
menuManager.add(fInvertColorsAction);
|
menuManager.add(fInvertColorsAction);
|
||||||
menuManager.add(fAutoTerminateAction);
|
menuManager.add(fAutoTerminateAction);
|
||||||
|
menuManager.add(new Separator());
|
||||||
|
|
||||||
|
menuManager.add(fShowPreferencePageAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -212,6 +229,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
fTerminalControl.setFocus();
|
fTerminalControl.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the launch to which the current selection belongs.
|
* Returns the launch to which the current selection belongs.
|
||||||
*
|
*
|
||||||
|
@ -236,7 +254,15 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInvertedColors(boolean enable) {
|
private void setInvertedColors(boolean enable) {
|
||||||
fTerminalControl.setInvertedColors(enable);
|
if (fTerminalControl != null) {
|
||||||
|
fTerminalControl.setInvertedColors(enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBufferLineLimit(int bufferLines) {
|
||||||
|
if (fTerminalControl != null) {
|
||||||
|
fTerminalControl.setBufferLineLimit(bufferLines);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2016 Ericsson and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
|
||||||
|
|
||||||
import org.eclipse.ui.console.IConsole;
|
|
||||||
|
|
||||||
public interface IGdbCliConsole extends IConsole {
|
|
||||||
/**
|
|
||||||
* Enable or disable the inverted color option of the console.
|
|
||||||
*/
|
|
||||||
void setInvertedColors(boolean enable);
|
|
||||||
}
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2016 Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* The Initial version is based on:
|
||||||
|
* org.eclipse.tm.terminal.control/src/org/eclipse/tm/internal/terminal/preferences/TerminalPreferencePage.java
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.gdb.internal.ui.preferences;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
|
||||||
|
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||||
|
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||||
|
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||||
|
import org.eclipse.jface.preference.IntegerFieldEditor;
|
||||||
|
import org.eclipse.ui.IWorkbench;
|
||||||
|
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GDB CLI Console Preference Page.
|
||||||
|
*
|
||||||
|
* @noextend This class is not intended to be subclassed by clients.
|
||||||
|
* @noinstantiate This class is not intended to be instantiated by clients.
|
||||||
|
* @noreference This class is not intended to be referenced by clients.
|
||||||
|
*/
|
||||||
|
public class GdbConsolePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
|
||||||
|
private static final int MIN_BUFFER_LINES = 16; /* minimum of ~1000 chars */
|
||||||
|
// Instead of using a maximum of Integer.MAX_VALUE (which is some obscure number),
|
||||||
|
// let's use a well defined limit e.g. 2 billion lines, which is readable.
|
||||||
|
private static final int MAX_BUFFER_LINES = 2000000000;
|
||||||
|
|
||||||
|
public GdbConsolePreferencePage() {
|
||||||
|
super(GRID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void createFieldEditors() {
|
||||||
|
setupPage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(IWorkbench workbench) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupPage() {
|
||||||
|
setupData();
|
||||||
|
setupEditors();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupData() {
|
||||||
|
setPreferenceStore(GdbUIPlugin.getDefault().getPreferenceStore());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupEditors() {
|
||||||
|
BooleanFieldEditor invertColors = new BooleanFieldEditor(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS,
|
||||||
|
MessagesForPreferences.GdbConsolePreferencePage_InvertColors, getFieldEditorParent());
|
||||||
|
IntegerFieldEditor editorBufferSize = new IntegerFieldEditor(IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES,
|
||||||
|
MessagesForPreferences.GdbConsolePreferencePage_BufferLines, getFieldEditorParent());
|
||||||
|
|
||||||
|
editorBufferSize.setValidRange(MIN_BUFFER_LINES, MAX_BUFFER_LINES);
|
||||||
|
|
||||||
|
addField(invertColors);
|
||||||
|
addField(editorBufferSize);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009, 2012 Ericsson and others.
|
* Copyright (c) 2009, 2016 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -73,6 +73,9 @@ class MessagesForPreferences extends NLS {
|
||||||
public static String ReverseDebugPreferencePage_BranchTrace;
|
public static String ReverseDebugPreferencePage_BranchTrace;
|
||||||
public static String ReverseDebugPreferencePage_ProcessorTrace;
|
public static String ReverseDebugPreferencePage_ProcessorTrace;
|
||||||
|
|
||||||
|
public static String GdbConsolePreferencePage_InvertColors;
|
||||||
|
public static String GdbConsolePreferencePage_BufferLines;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// initialize resource bundle
|
// initialize resource bundle
|
||||||
NLS.initializeMessages(MessagesForPreferences.class.getName(), MessagesForPreferences.class);
|
NLS.initializeMessages(MessagesForPreferences.class.getName(), MessagesForPreferences.class);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Copyright (c) 2009, 2012 Ericsson and others.
|
# Copyright (c) 2009, 2016 Ericsson and others.
|
||||||
# All rights reserved. This program and the accompanying materials
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# which accompanies this distribution, and is available at
|
||||||
|
@ -61,3 +61,6 @@ ReverseDebugPreferencePage_SelectHardwareTracingMethod=Hardware technology for i
|
||||||
ReverseDebugPreferencePage_GDBPreference=Automatic (let GDB choose)
|
ReverseDebugPreferencePage_GDBPreference=Automatic (let GDB choose)
|
||||||
ReverseDebugPreferencePage_BranchTrace=Branch Trace Store
|
ReverseDebugPreferencePage_BranchTrace=Branch Trace Store
|
||||||
ReverseDebugPreferencePage_ProcessorTrace=Intel(R) Processor Trace
|
ReverseDebugPreferencePage_ProcessorTrace=Intel(R) Processor Trace
|
||||||
|
|
||||||
|
GdbConsolePreferencePage_InvertColors = Invert console colors
|
||||||
|
GdbConsolePreferencePage_BufferLines = Console buffer lines:
|
||||||
|
|
|
@ -173,9 +173,27 @@ public interface IGdbDebugPreferenceConstants {
|
||||||
public static final String PREF_REVERSE_TRACE_METHOD_PROCESSOR_TRACE = "UseProcessorTrace"; //$NON-NLS-1$
|
public static final String PREF_REVERSE_TRACE_METHOD_PROCESSOR_TRACE = "UseProcessorTrace"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Boolean preference indicating if the GDB console should be shown using inverted colors. Default is <code>false</code>.
|
* Preference key controlling the coloring of GDB CLI consoles
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
public static final String PREF_CONSOLE_INVERTED_COLORS = PREFIX + "consoleInvertedColors"; //$NON-NLS-1$
|
public static final String PREF_CONSOLE_INVERTED_COLORS = PREFIX + "consoleInvertedColors"; //$NON-NLS-1$
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default preference value for the colors used by GDB CLI consoles
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public static final Boolean CONSOLE_INVERTED_COLORS_DEFAULT = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Preference key controlling the number of buffered lines used by GDB CLI consoles
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public static final String PREF_CONSOLE_BUFFERLINES = PREFIX + "consoleBufferLines"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default preference value for the number of buffered lines used by GDB CLI consoles
|
||||||
|
* @since 5.2
|
||||||
|
*/
|
||||||
|
public static final int CONSOLE_BUFFERLINES_DEFAULT = 1000;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public class GdbPreferenceInitializer extends AbstractPreferenceInitializer {
|
||||||
node.putBoolean(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS, false);
|
node.putBoolean(IGdbDebugPreferenceConstants.PREF_HIDE_RUNNING_THREADS, false);
|
||||||
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER, true);
|
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AGGRESSIVE_BP_FILTER, true);
|
||||||
node.put(IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_HARDWARE, IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_GDB_TRACE);
|
node.put(IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_HARDWARE, IGdbDebugPreferenceConstants.PREF_REVERSE_TRACE_METHOD_GDB_TRACE);
|
||||||
node.putBoolean(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS, false);
|
node.putBoolean(IGdbDebugPreferenceConstants.PREF_CONSOLE_INVERTED_COLORS, IGdbDebugPreferenceConstants.CONSOLE_INVERTED_COLORS_DEFAULT);
|
||||||
|
node.putInt(IGdbDebugPreferenceConstants.PREF_CONSOLE_BUFFERLINES, IGdbDebugPreferenceConstants.CONSOLE_BUFFERLINES_DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue