mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 303808: Handle resizing of full GDB console
Note that the TextCanvas used by the terminal widget that powers the full console has a default minimum of 4 lines and 80 columns. We could change those if we feel that is not adequate, or if we don't want to have such minimum values at all. This patch leaves the minimum values as they are by default. Conflicts: dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/GdbTerminalConnector.java Change-Id: Iad6339da1726db1102c123c97589f46ae681ffc7
This commit is contained in:
parent
10381a74e4
commit
28f290e9d0
4 changed files with 48 additions and 14 deletions
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
|||
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
|
||||
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
|
||||
import org.eclipse.cdt.dsf.service.DsfSession;
|
||||
import org.eclipse.cdt.utils.pty.PTY;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
|
@ -49,6 +50,8 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
|||
|
||||
private final DsfSession fSession;
|
||||
private final ILaunch fLaunch;
|
||||
private PTY fGdbPty;
|
||||
|
||||
private Composite fMainComposite;
|
||||
private final IDebuggerConsoleView fView;
|
||||
private final IDebuggerConsole fConsole;
|
||||
|
@ -194,6 +197,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
|||
|
||||
if (backend != null) {
|
||||
if (backend.getProcess() != null) {
|
||||
fGdbPty = backend.getProcessPty();
|
||||
attachTerminal(backend.getProcess());
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +208,7 @@ public class GdbFullCliConsolePage extends Page implements IDebugContextListener
|
|||
}
|
||||
|
||||
protected void attachTerminal(Process process) {
|
||||
fTerminalControl.setConnector(new GdbTerminalConnector(process));
|
||||
fTerminalControl.setConnector(new GdbTerminalConnector(process, fGdbPty));
|
||||
if (fTerminalControl instanceof ITerminalControl) {
|
||||
((ITerminalControl)fTerminalControl).setConnectOnEnterIfClosed(false);
|
||||
((ITerminalControl)fTerminalControl).setVT100LineWrapping(true);
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import org.eclipse.cdt.utils.pty.PTY;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
@ -26,15 +27,18 @@ import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
|
|||
*/
|
||||
public class GdbTerminalConnector extends PlatformObject implements ITerminalConnector {
|
||||
|
||||
private int fTerminalWidth, fTerminalHeight;
|
||||
private ITerminalControl fControl;
|
||||
private final Process fProcess;
|
||||
private final PTY fPty;
|
||||
|
||||
public GdbTerminalConnector(Process process) {
|
||||
public GdbTerminalConnector(Process process, PTY pty) {
|
||||
if (process == null) {
|
||||
throw new IllegalArgumentException("Invalid Process"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
fProcess = process;
|
||||
fPty = pty;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,6 +75,13 @@ public class GdbTerminalConnector extends PlatformObject implements ITerminalCon
|
|||
|
||||
@Override
|
||||
public void setTerminalSize(int newWidth, int newHeight) {
|
||||
if (newWidth != fTerminalWidth || newHeight != fTerminalHeight) {
|
||||
fTerminalWidth = newWidth;
|
||||
fTerminalHeight = newHeight;
|
||||
if (fPty != null) {
|
||||
fPty.setTerminalSize(newWidth, newHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,8 +40,11 @@ import org.eclipse.osgi.util.NLS;
|
|||
*/
|
||||
public class GDBBackend_7_12 extends GDBBackend {
|
||||
|
||||
/** The PTY that is used to enable the full GDB console */
|
||||
private PTY fPty;
|
||||
/** The PTY that is used to create the MI channel */
|
||||
private PTY fMIPty;
|
||||
/** The PTY that is used to create the GDB process in CLI mode */
|
||||
private PTY fCLIPty;
|
||||
|
||||
/** Indicate that we failed to create a PTY. */
|
||||
private boolean fPtyFailure;
|
||||
|
||||
|
@ -68,8 +71,8 @@ public class GDBBackend_7_12 extends GDBBackend {
|
|||
}
|
||||
|
||||
try {
|
||||
fPty = new PTY();
|
||||
fPty.validateSlaveName();
|
||||
fMIPty = new PTY();
|
||||
fMIPty.validateSlaveName();
|
||||
|
||||
// With the PTY the stderr is redirected to the PTY's output stream.
|
||||
// Therefore, return a dummy stream for the error stream.
|
||||
|
@ -80,7 +83,7 @@ public class GDBBackend_7_12 extends GDBBackend {
|
|||
}
|
||||
};
|
||||
} catch (IOException e) {
|
||||
fPty = null;
|
||||
fMIPty = null;
|
||||
fPtyFailure = true;
|
||||
GdbPlugin.log(new Status(
|
||||
IStatus.INFO, GdbPlugin.PLUGIN_ID,
|
||||
|
@ -90,23 +93,23 @@ public class GDBBackend_7_12 extends GDBBackend {
|
|||
|
||||
@Override
|
||||
public OutputStream getMIOutputStream() {
|
||||
if (fPty == null) {
|
||||
if (fMIPty == null) {
|
||||
return super.getMIOutputStream();
|
||||
}
|
||||
return fPty.getOutputStream();
|
||||
return fMIPty.getOutputStream();
|
||||
};
|
||||
|
||||
@Override
|
||||
public InputStream getMIInputStream() {
|
||||
if (fPty == null) {
|
||||
if (fMIPty == null) {
|
||||
return super.getMIInputStream();
|
||||
}
|
||||
return fPty.getInputStream();
|
||||
return fMIPty.getInputStream();
|
||||
};
|
||||
|
||||
@Override
|
||||
public InputStream getMIErrorStream() {
|
||||
if (fPty == null) {
|
||||
if (fMIPty == null) {
|
||||
return super.getMIErrorStream();
|
||||
}
|
||||
return fDummyErrorStream;
|
||||
|
@ -154,7 +157,7 @@ public class GDBBackend_7_12 extends GDBBackend {
|
|||
"--interpreter", "console", //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// Now trigger the new console towards our PTY.
|
||||
"-ex", "new-ui mi " + fPty.getSlaveName(), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
"-ex", "new-ui mi " + fMIPty.getSlaveName(), //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
// Now print the version so the user gets that familiar output
|
||||
"-ex", "show version" //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
@ -180,12 +183,13 @@ public class GDBBackend_7_12 extends GDBBackend {
|
|||
Process proc = null;
|
||||
String[] commandLine = getDebuggerCommandLine();
|
||||
try {
|
||||
fCLIPty = new PTY(Mode.TERMINAL);
|
||||
IPath path = getGDBWorkingDirectory();
|
||||
proc = ProcessFactory.getFactory().exec(
|
||||
commandLine,
|
||||
getGDBLaunch().getLaunchEnvironment(),
|
||||
new File(path != null ? path.toOSString() : ""), //$NON-NLS-1$
|
||||
new PTY(Mode.TERMINAL));
|
||||
fCLIPty);
|
||||
} catch (IOException e) {
|
||||
String message = "Error while launching command: " + StringUtil.join(commandLine, " "); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw new CoreException(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, message, e));
|
||||
|
@ -193,4 +197,9 @@ public class GDBBackend_7_12 extends GDBBackend {
|
|||
|
||||
return proc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PTY getProcessPty() {
|
||||
return fCLIPty;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import java.util.Properties;
|
|||
|
||||
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||
import org.eclipse.cdt.dsf.mi.service.IMIBackend;
|
||||
import org.eclipse.cdt.utils.pty.PTY;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
|
||||
|
@ -173,4 +174,13 @@ public interface IGDBBackend extends IMIBackend {
|
|||
default Process getProcess() {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PTY used when starting the GDB process.
|
||||
* Can be null if no PTY was used.
|
||||
* @since 5.1
|
||||
*/
|
||||
default PTY getProcessPty() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue