itom-project / itom

itom core repository
https://itom-project.github.io/
Other
14 stars 5 forks source link

Support for ANSI escape sequences in console widget #277

Closed magro11 closed 6 months ago

magro11 commented 7 months ago

The console widget of itom can now handle ANSI escape sequences (see https://en.wikipedia.org/wiki/ANSI_escape_code), that can be used to format the output or error texts (e.g. text color, background color, bold, underline, italic...). This feature can also be disabled by a setting in the Console >> General tab of the itom property editor.

Python packages, like Sphinx or Numba, are using these codes per default. itom can now identify these codes, and if supported, change the style of the affected parts in the texts.

The pythonLogWidget, that can be used in user-defined GUIs for displaying Python output or error streams, can not interpret these ANSI escape sequences (or ANSI escape codes), however there is a new property removeAnsiEscapeSequences. If true, the special sequence codes are recognized and removed, but not interpreted. Nevertheless, this allows that the text is not messed up with these strange codes.

For examples, sett the demo itom/basics/demo_ansiEscapeSequencesOutput.py: grafik

magro11 commented 7 months ago

ESC[2K and other erase sequences will now also be considered and removed. However, they are not interpreted.

magro11 commented 7 months ago

Still open: If long lines are wrapped, the ANSI escape codes are not interpreted, if they are split at the line limit. --> TODO

magro11 commented 6 months ago

From my perspective all issues are solved and this PR is ready to merge. @photoniker : what do you think?

photoniker commented 6 months ago

I didn't see issues so far...