Skip to content

Add support for VT100 terminal color ESC sequences #10105

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

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

RetiredWizard
Copy link

On Show and Tell @FoamyGuy demonstrated how he was able to modify the terminal font color which got me thinking that the same functionality could be used to enable the VT100 Escape sequences for setting the terminal background and foreground. This PR adds support for all the color attributes as well as the reset to default sequence.

I used the following code.py file to test the functionality:

ans = ''
while ans.upper() != 'Q':
    ans = input('Enter ESC sequence: ')
    print(chr(27)+ans)

Entering [44m at the prompt sets the background to blue and entering [30;41m will set the foreground to black and the background to red.

Although many terminal programs run from host computers will respond to the same escape sequences this PR has nothing to do with controlling the attributes of a terminal session from a host computer, rather it sets the attributes on an attached display like a TFT Featherwing. If the board doesn't bring up the display automatically, you may need to add the initialization code to the code.py file as well.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Neat! Thank you!

@tannewt tannewt merged commit b9237e6 into adafruit:main Feb 27, 2025
530 checks passed
@RetiredWizard
Copy link
Author

Based on the direction #10102 appears to be heading, this will probably need to be re-worked once that PR is merged. If each tile does get a foreground/background color index then perhaps this can be made more compliant and apply from the current cursor rather than applying to the entire screen.

@RetiredWizard RetiredWizard deleted the ansiesc branch February 27, 2025 21:22
@tannewt
Copy link
Member

tannewt commented Feb 28, 2025

No problem! I figured we'd need values for default foreground and background.

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