Skip to content

Commit

Permalink
Add print_rich() support to Debug Console (#792)
Browse files Browse the repository at this point in the history
* add bbcode support to debug console
* fix output line for Debug Console
* Update debug console output. Add Godot3.6 support.
  • Loading branch information
jnoel-dev authored Feb 22, 2025
1 parent b986ce0 commit b29fbb7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,7 @@
"@vscode/debugadapter": "^1.68.0",
"@vscode/debugprotocol": "^1.68.0",
"await-notify": "^1.0.1",
"bbcode-to-ansi": "^1.0.0",
"global": "^4.4.0",
"marked": "^4.0.11",
"net": "^1.0.2",
Expand Down
8 changes: 5 additions & 3 deletions src/debugger/godot3/server_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ import { build_sub_values, parse_next_scene_node, split_buffers } from "./helper
import { VariantDecoder } from "./variables/variant_decoder";
import { VariantEncoder } from "./variables/variant_encoder";
import { RawObject } from "./variables/variants";
import BBCodeToAnsi from 'bbcode-to-ansi';

const log = createLogger("debugger.controller", { output: "Godot Debugger" });
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 {
public command: string = "";
Expand Down Expand Up @@ -427,9 +430,8 @@ export class ServerController {
this.didFirstOutput = true;
// 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;
}
Expand Down
8 changes: 5 additions & 3 deletions src/debugger/godot4/server_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ import { VariantDecoder } from "./variables/variant_decoder";
import { VariantEncoder } from "./variables/variant_encoder";
import { RawObject } from "./variables/variants";
import { VariablesManager } from "./variables/variables_manager";
import BBCodeToAnsi from 'bbcode-to-ansi';

const log = createLogger("debugger.controller", { output: "Godot Debugger" });
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 {
public command: string = "";
Expand Down Expand Up @@ -529,9 +532,8 @@ export class ServerController {
this.didFirstOutput = true;
// 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;
}
Expand Down

0 comments on commit b29fbb7

Please sign in to comment.