Skip to content

Fix formatting text after an Error in the Terminal#227

Open
MikeSullivan7 wants to merge 1 commit into
RascalSoftware:mainfrom
MikeSullivan7:Terminal_colour_bug_fix
Open

Fix formatting text after an Error in the Terminal#227
MikeSullivan7 wants to merge 1 commit into
RascalSoftware:mainfrom
MikeSullivan7:Terminal_colour_bug_fix

Conversation

@MikeSullivan7
Copy link
Copy Markdown
Collaborator

@MikeSullivan7 MikeSullivan7 commented May 13, 2026

This PR fixes an issue in the Terminal where if an Error was produced via the Custom File and then the red text in the Termain was clicked (moving the invisible cursor), then all text in the Terminal will now be red, even if the Error is corrected.

To produce the issue in main:

  1. Open Domain Custom XY [Example]
  2. Edit the domains_XY_model.py custom file
  3. Edit it to force an issue, e.g. def domains_XY_model(params, bulk_in, bulk_out, contrast, domain): -> def domains_XY_model(params, bulk_in, bulk_out, contrast, domain) and click save and Accept Changes in the Project Window.
  4. Click on the red text in the Terminal MDI.
  5. Click run.
    All text in the Terminal will now be red.

This is fixed by when clearing the Terminal via TerminalWidget.clear(), we move the cursor onto some black HTML text before clearing the text and resetting the colour of the text.
Repeat the steps above on this branch to check that it fixes the formatting error.

Copy link
Copy Markdown
Contributor

@StephenNneji StephenNneji left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this, I had no idea clicking the text somehow transferred the colour. I am curious if there is an option to switch off that behaviour but I could not find anything.


def clear(self):
"""Clear the text in the terminal."""
self.write_html('<div style="color: black;white-space: pre-line;"><b>" "</b></div>')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding the black text colour may not be great for themes, it seems to work without the color entry i.e.

self.write_html('<div style="white-space: pre-line;"><b>" "</b></div>')

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants