From 84045ac15c2d634e5c89c410e7648a573175649b Mon Sep 17 00:00:00 2001 From: marcsosduma <31162117+marcsosduma@users.noreply.github.com> Date: Sat, 2 Dec 2023 08:21:27 -0300 Subject: [PATCH] Multiple terminals --- README.md | 7 ------- package.json | 4 ++++ src/mi2.ts | 40 +++++++++++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index e660ef0..66d381d 100644 --- a/README.md +++ b/README.md @@ -180,13 +180,6 @@ Add `gdbtty` property to your `launch.json`. Here’s an example: ``` ![GdbTTY](gdbttydisplay.png) -* Linux Requirements: `xterm` - -How to install xterm on Ubuntu: -``` -sudo apt-get install xterm -``` - On Linux you can see the output of the application in Vs Code itself. Add `gdbtty` property with `vscode` value to your `launch.json`. Here is an example: ```json { diff --git a/package.json b/package.json index 52e6542..91205c9 100644 --- a/package.json +++ b/package.json @@ -144,6 +144,10 @@ true, false, "vscode", + "xterm", + "gnome-terminal", + "xfce4-terminal", + "konsole", "external" ] } diff --git a/src/mi2.ts b/src/mi2.ts index 8602297..e0f509f 100644 --- a/src/mi2.ts +++ b/src/mi2.ts @@ -1066,7 +1066,7 @@ export class MI2 extends EventEmitter implements IDebugger { try_find++; if (xterm_device != "") break; } - if (xterm_device === "") this.log("stderr", "tty: Install 'xterm' to use gdb's tty option\n"); + if (xterm_device === "") this.log("stderr", "tty: Install a terminal to use gdb's tty option\n"); } if (xterm_device.includes("pts")) { this.gdbArgs.push("--tty=" + xterm_device); @@ -1194,15 +1194,37 @@ export class MI2 extends EventEmitter implements IDebugger { // Opens a terminal to show the application screen - gdbtty createTerminal(gdbtty, sleepVal, target) { + let findTerminal = true; if (gdbtty != "vscode") { - if(this.isTerminalInstalled("xterm")){ - this.createXtermTerminal(sleepVal, target); - }else if(this.isTerminalInstalled("gnome-terminal")){ - this.createGNOMETerminal(sleepVal, target); - }else if(this.isTerminalInstalled("konsole")){ - this.createKDETerminal(sleepVal, target); - }else if(this.isTerminalInstalled("xfce4-terminal")){ - this.createXFCETerminal(sleepVal, target); + if (typeof gdbtty === 'string' && gdbtty!="external") { + if(this.isTerminalInstalled(gdbtty)){ + findTerminal = false; + switch (gdbtty) { + case "xterm": + this.createXtermTerminal(sleepVal, target); + break; + case "gnome-terminal": + this.createGNOMETerminal(sleepVal, target); + break; + case "konsole": + this.createKDETerminal(sleepVal, target); + break; + case "xfce4-terminal": + this.createXFCETerminal(sleepVal, target); + break; + } + } + } + if(findTerminal){ + if(this.isTerminalInstalled("xterm")){ + this.createXtermTerminal(sleepVal, target); + }else if(this.isTerminalInstalled("gnome-terminal")){ + this.createGNOMETerminal(sleepVal, target); + }else if(this.isTerminalInstalled("konsole")){ + this.createKDETerminal(sleepVal, target); + }else if(this.isTerminalInstalled("xfce4-terminal")){ + this.createXFCETerminal(sleepVal, target); + } } } else { let terminal = this.selectTerminal();