TextStyle.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. namespace Terminal.Gui;
  2. /// <summary>
  3. /// Defines non-color text style flags for an <see cref="Attribute"/>.
  4. /// </summary>
  5. /// <remarks>
  6. /// <para>
  7. /// Only a subset of ANSI SGR (Select Graphic Rendition) styles are represented.
  8. /// Styles that are poorly supported, non-visual, or redundant with other APIs are omitted.
  9. /// </para>
  10. /// <para>
  11. /// Multiple styles can be combined using bitwise operations. Use <see cref="Attribute.TextStyle"/>
  12. /// to get or set these styles on an <see cref="Attribute"/>.
  13. /// </para>
  14. /// <para>
  15. /// Note that <see cref="TextStyle.Bold"/> and <see cref="TextStyle.Faint"/> may be mutually exclusive depending on
  16. /// the user's terminal and its settings. For instance, if a terminal displays faint text as a darker color, and
  17. /// bold text as a lighter color, then both cannot
  18. /// be shown at the same time, and it will be up to the terminal to decide which to display.
  19. /// </para>
  20. /// </remarks>
  21. [Flags]
  22. public enum TextStyle : byte
  23. {
  24. /// <summary>
  25. /// No text style.
  26. /// </summary>
  27. /// <remarks>Corresponds to no active SGR styles.</remarks>
  28. None = 0b_0000_0000,
  29. /// <summary>
  30. /// Bold text.
  31. /// </summary>
  32. /// <remarks>
  33. /// SGR code: 1 (Bold). May be mutually exclusive with <see cref="TextStyle.Faint"/>, see <see cref="TextStyle"/>
  34. /// remarks.
  35. /// </remarks>
  36. Bold = 0b_0000_0001,
  37. /// <summary>
  38. /// Faint (dim) text.
  39. /// </summary>
  40. /// <remarks>
  41. /// SGR code: 2 (Faint). Not widely supported on all terminals. May be mutually exclusive with
  42. /// <see cref="TextStyle.Bold"/>, see
  43. /// <see cref="TextStyle"/> remarks.
  44. /// </remarks>
  45. Faint = 0b_0000_0010,
  46. /// <summary>
  47. /// Italic text.
  48. /// </summary>
  49. /// <remarks>SGR code: 3 (Italic). Some terminals may not support italic rendering.</remarks>
  50. Italic = 0b_0000_0100,
  51. /// <summary>
  52. /// Underlined text.
  53. /// </summary>
  54. /// <remarks>SGR code: 4 (Underline).</remarks>
  55. Underline = 0b_0000_1000,
  56. /// <summary>
  57. /// Slow blinking text.
  58. /// </summary>
  59. /// <remarks>SGR code: 5 (Slow Blink). Support varies; blinking is often disabled in modern terminals.</remarks>
  60. Blink = 0b_0001_0000,
  61. /// <summary>
  62. /// Reverse video (swaps foreground and background colors).
  63. /// </summary>
  64. /// <remarks>SGR code: 7 (Reverse Video).</remarks>
  65. Reverse = 0b_0010_0000,
  66. /// <summary>
  67. /// Strikethrough (crossed-out) text.
  68. /// </summary>
  69. /// <remarks>SGR code: 9 (Crossed-out / Strikethrough).</remarks>
  70. Strikethrough = 0b_0100_0000
  71. }