Syntax Highlighting Style Priorities

When editor draws text, it merges (layers) different styles applied to text to get resulted style of the text block to draw (text color, back color, italic/bold/…, hot-spot etc). All styles stapled into a stack and then merged with each other from bottom to top.

The following rules are used for merging:

  • Font properties (italic/bold/strikeout/underline), Style properties (text/overview/hotspot) are merged as 3 state variables (on/off/undefined). If a top property is not “undefined” it will overwrite property of bottom style. If a top property is undefined, the property style of resulting (merged) style will be equal to the state of the bottom property
  • Color properties (foreground and background, underline and box colors) are merged using alpha values of the corresponding color property. If alpha of the top style 100% color of the resulting style will be equal to the color of the bottom style. If alpha of the top stale 0% color of the resulting style will be equal to top color. If alpha is 50%, the color of resulting style will be equal to color mixture of the top and bottom style colors. Changing of the alpha value you can influence resulting color.

The following layering priorities are considered, when stapling styles:

  1. Window color or Read-Only color
  2. Embedded syntax color
  3. Inactive Code style
  4. Nesting color
  5. User text highlighting + text explicit highlighting from plugins
  6. Syntax driven styles (keywords, comments, strings etc)
  7. White space style
  8. Trailing white space
  9. Colored braces
  10. Search, Current Scope and Smart Highlighting
  11. Plugin text block highlighting
  12. Text Selection
  13. Alternated line style
  14. Protected areas line style
  15. Bookmark line style
  16. Breakpoint line style
  17. Current line style
  18. Execution line style
  19. Error line style