浏览代码

Add print_rich() support to Debug Console (#792)

* add bbcode support to debug console
* fix output line for Debug Console
* Update debug console output. Add Godot3.6 support.
Saint 5 月之前
父节点
当前提交
b29fbb75a0
共有 4 个文件被更改,包括 17 次插入6 次删除
  1. 6 0
      package-lock.json
  2. 1 0
      package.json
  3. 5 3
      src/debugger/godot3/server_controller.ts
  4. 5 3
      src/debugger/godot4/server_controller.ts

+ 6 - 0
package-lock.json

@@ -12,6 +12,7 @@
 				"@vscode/debugadapter": "^1.68.0",
 				"@vscode/debugadapter": "^1.68.0",
 				"@vscode/debugprotocol": "^1.68.0",
 				"@vscode/debugprotocol": "^1.68.0",
 				"await-notify": "^1.0.1",
 				"await-notify": "^1.0.1",
+				"bbcode-to-ansi": "^1.0.0",
 				"global": "^4.4.0",
 				"global": "^4.4.0",
 				"marked": "^4.0.11",
 				"marked": "^4.0.11",
 				"net": "^1.0.2",
 				"net": "^1.0.2",
@@ -2129,6 +2130,11 @@
 			],
 			],
 			"optional": true
 			"optional": true
 		},
 		},
+		"node_modules/bbcode-to-ansi": {
+			"version": "1.0.0",
+			"resolved": "https://registry.npmjs.org/bbcode-to-ansi/-/bbcode-to-ansi-1.0.0.tgz",
+			"integrity": "sha512-YQVaDdsVP2590q2AD3oTuSQecpx3YF2+gAimSbbmdjdvI8O8AOmEiTRLiRa1l2UoKjmbNh4e20s4XlRLk2n7ww=="
+		},
 		"node_modules/binary-extensions": {
 		"node_modules/binary-extensions": {
 			"version": "2.2.0",
 			"version": "2.2.0",
 			"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
 			"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",

+ 1 - 0
package.json

@@ -901,6 +901,7 @@
 		"@vscode/debugadapter": "^1.68.0",
 		"@vscode/debugadapter": "^1.68.0",
 		"@vscode/debugprotocol": "^1.68.0",
 		"@vscode/debugprotocol": "^1.68.0",
 		"await-notify": "^1.0.1",
 		"await-notify": "^1.0.1",
+		"bbcode-to-ansi": "^1.0.0",
 		"global": "^4.4.0",
 		"global": "^4.4.0",
 		"marked": "^4.0.11",
 		"marked": "^4.0.11",
 		"net": "^1.0.2",
 		"net": "^1.0.2",

+ 5 - 3
src/debugger/godot3/server_controller.ts

@@ -23,9 +23,12 @@ import { build_sub_values, parse_next_scene_node, split_buffers } from "./helper
 import { VariantDecoder } from "./variables/variant_decoder";
 import { VariantDecoder } from "./variables/variant_decoder";
 import { VariantEncoder } from "./variables/variant_encoder";
 import { VariantEncoder } from "./variables/variant_encoder";
 import { RawObject } from "./variables/variants";
 import { RawObject } from "./variables/variants";
+import BBCodeToAnsi from 'bbcode-to-ansi';
 
 
 const log = createLogger("debugger.controller", { output: "Godot Debugger" });
 const log = createLogger("debugger.controller", { output: "Godot Debugger" });
 const socketLog = createLogger("debugger.socket");
 const socketLog = createLogger("debugger.socket");
+//initialize bbcodeParser and set default output color to grey
+const bbcodeParser = new BBCodeToAnsi("\u001b[38;2;211;211;211m");
 
 
 class Command {
 class Command {
 	public command: string = "";
 	public command: string = "";
@@ -427,9 +430,8 @@ export class ServerController {
 					this.didFirstOutput = true;
 					this.didFirstOutput = true;
 					// this.request_scene_tree();
 					// this.request_scene_tree();
 				}
 				}
-				const lines = command.parameters;
-				for (const line of lines) {
-					debug.activeDebugConsole.appendLine(ansi.bright.blue + line[0]);
+				for (const output of command.parameters){
+					output[0].split("\n").forEach(line => debug.activeDebugConsole.appendLine(bbcodeParser.parse(line)));
 				}
 				}
 				break;
 				break;
 			}
 			}

+ 5 - 3
src/debugger/godot4/server_controller.ts

@@ -24,9 +24,12 @@ import { VariantDecoder } from "./variables/variant_decoder";
 import { VariantEncoder } from "./variables/variant_encoder";
 import { VariantEncoder } from "./variables/variant_encoder";
 import { RawObject } from "./variables/variants";
 import { RawObject } from "./variables/variants";
 import { VariablesManager } from "./variables/variables_manager";
 import { VariablesManager } from "./variables/variables_manager";
+import BBCodeToAnsi from 'bbcode-to-ansi';
 
 
 const log = createLogger("debugger.controller", { output: "Godot Debugger" });
 const log = createLogger("debugger.controller", { output: "Godot Debugger" });
 const socketLog = createLogger("debugger.socket");
 const socketLog = createLogger("debugger.socket");
+//initialize bbcodeParser and set default output color to grey
+const bbcodeParser = new BBCodeToAnsi("\u001b[38;2;211;211;211m");
 
 
 class Command {
 class Command {
 	public command: string = "";
 	public command: string = "";
@@ -529,9 +532,8 @@ export class ServerController {
 					this.didFirstOutput = true;
 					this.didFirstOutput = true;
 					// this.request_scene_tree();
 					// this.request_scene_tree();
 				}
 				}
-				const lines = command.parameters[0];
-				for (const line of lines) {
-					debug.activeDebugConsole.appendLine(ansi.bright.blue + line);
+				for (const output of command.parameters[0]){
+					output.split("\n").forEach(line => debug.activeDebugConsole.appendLine(bbcodeParser.parse(line)));
 				}
 				}
 				break;
 				break;
 			}
 			}