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 support for dimmed characters (faint) #1043

Merged
merged 8 commits into from
Oct 11, 2017
Merged

Add support for dimmed characters (faint) #1043

merged 8 commits into from
Oct 11, 2017

Conversation

mofux
Copy link
Contributor

@mofux mofux commented Oct 9, 2017

Fixes #1042

This PR adds support to render dimmed characters.

screen shot 2017-10-09 at 17 13 23

@mofux mofux added the type/enhancement Features or improvements to existing features label Oct 9, 2017
@mofux mofux added this to the 3.0.0 milestone Oct 9, 2017
@mofux mofux self-assigned this Oct 9, 2017
@mofux mofux requested a review from Tyriar October 9, 2017 15:26
@@ -1220,6 +1221,9 @@ export class InputHandler implements IInputHandler {
} else if (p === 8) {
// invisible
flags |= 16;
} else if (p === 2) {
// dimmed text
flags |= 32;
Copy link
Member

Choose a reason for hiding this comment

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

Let's import FLAGS from Types.ts here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I have also replaced the other numeric references with the according flag.

@@ -241,11 +241,15 @@ export abstract class BaseRenderLayer implements IRenderLayer {
// ImageBitmap's draw about twice as fast as from a canvas
const charAtlasCellWidth = this._scaledCharWidth + CHAR_ATLAS_CELL_SPACING;
const charAtlasCellHeight = this._scaledCharHeight + CHAR_ATLAS_CELL_SPACING;
// Apply alpha to dim the character
if (dim) {
this._ctx.globalAlpha = 0.5;
Copy link
Member

Choose a reason for hiding this comment

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

Let's make the 0.5 a constant up the top. How does 0.5 compare to other terminals that implement this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

0.5 was the value that matched the dimmed characters from Terminal.app best. I have made this a constant now

@coveralls
Copy link

coveralls commented Oct 9, 2017

Coverage Status

Coverage decreased (-0.04%) to 70.192% when pulling e3cb871 on mofux:dim into b06eb44 on sourcelair:v3.

@coveralls
Copy link

coveralls commented Oct 9, 2017

Coverage Status

Coverage decreased (-0.05%) to 70.19% when pulling 2afdfd6 on mofux:dim into b06eb44 on sourcelair:v3.

@theflyingape
Copy link
Contributor

I see inclusion for (p === 22) to cancel both bold + dim, perfect, thank you.
While "not widely supported", there are legacy apps that can send a cancel bold only SGR, could this else if(p === 21) flags &= ~FLAGS.BOLD; be added?
As noted here: Select Graphic Rendition (SGR)

@mofux
Copy link
Contributor Author

mofux commented Oct 9, 2017

@theflyingape Thanks for your feedback! I've added SGR 21 to clear bold.

@coveralls
Copy link

coveralls commented Oct 9, 2017

Coverage Status

Coverage decreased (-0.05%) to 70.184% when pulling 12abc87 on mofux:dim into b06eb44 on sourcelair:v3.

@coveralls
Copy link

coveralls commented Oct 9, 2017

Coverage Status

Coverage decreased (-0.05%) to 70.184% when pulling 12abc87 on mofux:dim into b06eb44 on sourcelair:v3.

@Tyriar
Copy link
Member

Tyriar commented Oct 10, 2017

@theflyingape normally we use http://invisible-island.net/xterm/ctlseqs/ctlseqs.html as the "spec" as it's maintained by a developer of xterm. Do several popular terminal emulators implement this clear bold?

@mofux
Copy link
Contributor Author

mofux commented Oct 10, 2017

Terminal.app and iTerm do not I'm afraid (they don't seem to implement it at all, neither double underline nor cancel bold):

echo -e '\x1B[33m yellow \x1B[1m bo\x1B[21mld \x1B[2m dim \x1B[m off'

screen shot 2017-10-10 at 13 34 19

Not sure about other Terminal apps though...

@Tyriar Shall I remove the support for it (at least in this PR, so we can have a separate discussion about this feature in a separate issue)?

@theflyingape
Copy link
Contributor

@Tyriar, Linux-based X terminals including its physical VGA console indeed consume a clear bold sequence (21m) and turn only that character attribute off; and Windows commercial terminal emulators, sigh, like what we still use at our hospital for many classic apps that transmit bold on / bold off in this manner.

@Tyriar
Copy link
Member

Tyriar commented Oct 10, 2017

I see gnome-terminal supports it but actual xterm does not:

screen shot 2017-10-10 at 7 41 25 am

Split it into a separate issue might be good so we can merge this and have a discussion.

@theflyingape
Copy link
Contributor

Right, it's not widely implemented and it's mostly ignored. Thanks for the work on dim and please do split cancel bold into a separate non-blocking issue; I do not see any downside for adding it in. For reference, hterm also lists it as ignored but TBD.

@mofux
Copy link
Contributor Author

mofux commented Oct 11, 2017

I have reverted the SGR 21 support, let's track it in a separate issue. PR should be good to merge now.

@coveralls
Copy link

coveralls commented Oct 11, 2017

Coverage Status

Coverage decreased (-0.05%) to 70.184% when pulling 6ea73c8 on mofux:dim into b06eb44 on sourcelair:v3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Features or improvements to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants