Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add print_rich() support to Debug Console #792

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

jnoel-dev
Copy link
Contributor

@jnoel-dev jnoel-dev commented Feb 11, 2025

  • Adds print_rich()/bbcode support to Debug Console
  • Sets Debug Console text color to grey (To match Godot console output)
  • Changes how lines are outputted to Debug Console. (Previously was printing lines in chunks/groups instead of line by line) Fixes Prevent bunching console messages #791
  • Adds "printing rich" to Godot3.6. bbcode in regular print statements will be parsed in debug console.

Limitations:

  1. Debug console will still parse bbcode in regular print() statements. I am not sure if there is a way to determine if print_rich() was used...
  2. [center] and [right] tags are emulated with spaces. May not be accurate depending on terminal size.

Tested working on Linux, Windows
Tested working on Godot4.4b3, Godot4.3, Godot3.6

using this to parse https://github.com/jnoel-dev/bbcode-to-ansi based on @Calinou 's https://github.com/Calinou/godot-bbcode-to-ansi

before
image

after
image

@Calinou
Copy link
Member

Calinou commented Feb 11, 2025

Changes how lines are outputted to Debug Console. (Previously was printing lines in chunks/groups instead of line by line)

Does this PR close #791?

@jnoel-dev
Copy link
Contributor Author

Changes how lines are outputted to Debug Console. (Previously was printing lines in chunks/groups instead of line by line)

Does this PR close #791?

Looks like it does..
filtering before
image
filtering after
image

@atirut-w
Copy link

2. [center] and [right] tags are emulated with spaces. May not be accurate depending on terminal size.

Do ANSI positioning escape codes not work in VSCode?

@Calinou
Copy link
Member

Calinou commented Feb 13, 2025

Do ANSI positioning escape codes not work in VSCode?

I didn't know there were ANSI positioning escape codes. Most apps seem to query your terminal width so that they can center or right-align text. There are ways to query this terminal width across terminals, but it requires specific APIs that are not cross-platform between Windows and POSIX.

See this terminal_size Rust crate for instance: https://github.com/eminence/terminal-size

@atirut-w
Copy link

I didn't know there were ANSI positioning escape codes.

It's documented as "Cursor Position" sequence on Wikipedia. I'm not sure if it's generally implemented, though.

@Calinou
Copy link
Member

Calinou commented Feb 13, 2025

It's documented as "Cursor Position" sequence on Wikipedia. I'm not sure if it's generally implemented, though.

That escape code is about moving the caret (e.g. for CLI text editors with mouse support).

@btarg
Copy link
Contributor

btarg commented Feb 13, 2025

This looks very useful for filtering information in the debug log!
I'm not sure if this should be another proposal/PR, but would it be possible to very slightly alter either the foreground or background default colour of the text per-line? Unity does this with its console log to more clearly separate each line visually at a glance. For instance, the new default grey can alternate between slightly darker or lighter grey colours for each line.

If this should be separated, I could make a new PR after this one is merged.
Thanks!

@DaelonSuzuka
Copy link
Collaborator

@MichaelXt Sorry to tag you into an unrelated PR, but: https://github.com/godotengine/godot-vscode-plugin/actions/runs/13291410139/job/37126617646?pr=792#step:9:293

Is this the flaky test you mentioned before?

@MichaelXt
Copy link
Contributor

MichaelXt commented Feb 14, 2025

@MichaelXt Sorry to tag you into an unrelated PR, but: https://github.com/godotengine/godot-vscode-plugin/actions/runs/13291410139/job/37126617646?pr=792#step:9:293

Is this the flaky test you mentioned before?

Yes it is. I've bumped the timeout for the test in latest PR. For now please retry the actions workflow.

@btarg
Copy link
Contributor

btarg commented Feb 15, 2025

Since center tags are "emulated" in a potentially janky way, it would be nice to have an option to ignore tags that change the position of text. Also, does the rainbow tag work properly? :)

@Calinou
Copy link
Member

Calinou commented Feb 15, 2025

Also, does the rainbow tag work properly? :)

Animations (other than blinking text1) are not possible to implement with ANSI escape codes.

Footnotes

  1. There is a standard ANSI escape code for blinking text, but it's not configurable in any way (e.g. speed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent bunching console messages
6 participants