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

Improved handling of escape sequences #68

Merged
merged 1 commit into from
Apr 8, 2018
Merged

Conversation

Grimy
Copy link
Contributor

@Grimy Grimy commented Apr 8, 2018

This is a followup to #66.

  • The Paint gem was emitting a \e[0m sequence after each painted character. This resets all graphical attributes, including background color, bold, italics… As a result, whenever a run of characters was supposed to be highlighted, only the first character in the run was actually highlighted. Example from htop:

blah

To fix this, we instead use \e[39m to reset only the foreground color (or, in invert mode, \e[49m to reset only the background color). This gives much prettier results:

0

  • Some things still weren’t properly reset. The aptly named stty sane does most of what we want, so we now use that.

  • We now detect incomplete UTF-8 characters and incomplete escape sequences, and perform another read when they occur, thus fixing the regression that was mentionned in Make nethack | lolcat work #66.

@m-o-e m-o-e merged commit d91b0dd into busyloop:master Apr 8, 2018
@m-o-e
Copy link
Member

m-o-e commented Apr 8, 2018

"In the beginner's mind there are many possibilities, but in the expert's there are few."
-- Shunryu Suzuki

Merged and released.

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.

None yet

2 participants