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

Underline styles and colors - core part #2751

Merged
merged 9 commits into from
May 3, 2020
Merged

Conversation

jerch
Copy link
Member

@jerch jerch commented Mar 8, 2020

PR to support additional underline styles and colors in AttributeData. Implements core parts of #1145.

Note that this PR extends AttributeData in a generic way, which can be use to store other data later on (like #1134).

Changes to the internal interface:

interface IAttributeData {
  ...
  // whether the attr object has any extended attrs defined
  hasExtendedAttrs(): number;
  // update internal HAS_EXTENDED flag
  updateExtended(): void;
  // transparently either returns FG color or underline color if set
  getUnderlineColor(): number;
  // color mode accessors
  getUnderlineColorMode(): number;
  isUnderlineColorRGB(): boolean;
  isUnderlineColorPalette(): boolean;
  isUnderlineColorDefault(): boolean;
  // actual underline
  getUnderlineStyle(): UnderlineStyle;
}

The color and the color mode accessors transparently map to the FG variants, if no independent color was set or underline is unset. Thus its important to test beforehand for isUnderline.

TODO:

  • handle extended SGR 4 sequences
  • handle SGR 58 and SGR 59 sequences
  • extend AttributeData to expose extended attributes
  • extend BufferLine to hold and export extended attributes
  • test cases for all

@jerch jerch changed the title extend AttributeData with eAttrs, implement SGR 4 subparams, tests Underline styles and colors - core part Mar 8, 2020
@jerch jerch self-assigned this Mar 8, 2020
@jerch jerch added area/parser type/enhancement Features or improvements to existing features labels Mar 8, 2020
@jerch jerch marked this pull request as ready for review March 8, 2020 22:02
@jerch jerch closed this Mar 8, 2020
@jerch jerch reopened this Mar 8, 2020
src/common/Types.d.ts Show resolved Hide resolved
src/common/Types.d.ts Show resolved Hide resolved
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

Looks good after the minor issues are resolved 👍, next PR would be adding rendering?

src/InputHandler.ts Outdated Show resolved Hide resolved
src/InputHandler.ts Outdated Show resolved Hide resolved
isUnderlineColorRGB(): boolean;
isUnderlineColorPalette(): boolean;
isUnderlineColorDefault(): boolean;
getUnderlineStyle(): number;
Copy link
Member

Choose a reason for hiding this comment

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

Just to clarify, all underline styles will still result in the isUnderline public API being non-zero?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea here for renderer side is to first test for isUnderline, if that evals to true, you'd have to request the style and the color to finally draw it. This way it is compatible to our current code, which only relies on a isUnderline test and always draws a single line.

The color methods cannot be used to determine whether underline is in place, as they would always report a color (fg color). The style method can be used for that, yes.

public content = 0;
public fg = 0;
public bg = 0;
public extended: IExtendedAttrs = new ExtendedAttrs();
Copy link
Member

Choose a reason for hiding this comment

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

So the approximate memory increase per cell will be 1 pointer for this, and then the standard ExtendedAttrs object will get shared between all cells?

Copy link
Member Author

Choose a reason for hiding this comment

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

But only for cells, that actually have extended attribs set. All other (thus most cells) dont use more memory in the buffer. To get this working I used another bit in bg as indicator whether a cell holds extended attrs (HAS_EXTENDED flag).

@Tyriar Tyriar modified the milestones: 4.5.0, 4.6.0 Apr 10, 2020
@jerch
Copy link
Member Author

jerch commented Apr 11, 2020

Looks good after the minor issues are resolved +1, next PR would be adding rendering?

Yepp. But thats non trivial, as you already might have guessed from the comments in #1145. Gonna fix the issues above in the next couple of days, but prolly wont make it to the renderer parts 😞

@Tyriar
Copy link
Member

Tyriar commented Apr 11, 2020

@jerch no worries, we should still merge to avoid conflicts piling up

DHowett pushed a commit to microsoft/terminal that referenced this pull request Jul 18, 2023
Adds support for colon `:` separated sub parameters in parser.
Technically, after this PR, nothing should change except, now sub
parameters are parsed, stored safely and we don't invalidate the whole
sequence when a `:` is received within a parameter substring.

In this PR:
- If sub parameters are detected with a parameter, but the usage is
unrecognised, we simply *skip* the parameter in `adaptDispatch`.
- A separate store for sub parameters is used to avoid too many changes
to the codebase.
- We currently allow up to `6` sub parameters for each parameter, extra
sub parameters are *ignored*.
- Introduced `VTSubParameters` for easy access to underlying sub
parameters.

> **Info**: We don't use sub parameters for any feature yet, this is
just the core implementation to support newer usecases.

## Validation Steps Performed
- [x] Use of sub parameters must not have any effect on the output.
- [x] Skip parameters with unexpected set of sub parameters.
- [x] Skip sequences with unexpected set of sub parameters.

References #4321
References #7228
References #15599
References xtermjs/xterm.js#2751
Closes #4321
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/parser type/enhancement Features or improvements to existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants