cell_attr.dart 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import 'package:meta/meta.dart';
  2. import 'package:xterm/buffer/cell_color.dart';
  3. class CellAttr {
  4. CellAttr({
  5. @required this.fgColor,
  6. this.bgColor,
  7. this.bold = false,
  8. this.faint = false,
  9. this.italic = false,
  10. this.underline = false,
  11. this.blink = false,
  12. this.inverse = false,
  13. this.invisible = false,
  14. });
  15. CellColor fgColor;
  16. CellColor bgColor;
  17. bool bold;
  18. bool faint;
  19. bool italic;
  20. bool underline;
  21. bool blink;
  22. bool inverse;
  23. bool invisible;
  24. CellAttr copy() {
  25. return CellAttr(
  26. fgColor: this.fgColor,
  27. bgColor: this.bgColor,
  28. bold: this.bold,
  29. faint: this.faint,
  30. italic: this.italic,
  31. underline: this.underline,
  32. blink: this.blink,
  33. inverse: this.inverse,
  34. invisible: this.invisible,
  35. );
  36. }
  37. void reset({
  38. @required fgColor,
  39. bgColor,
  40. bold = false,
  41. faint = false,
  42. italic = false,
  43. underline = false,
  44. blink = false,
  45. inverse = false,
  46. invisible = false,
  47. }) {
  48. this.fgColor = fgColor;
  49. this.bgColor = bgColor;
  50. this.bold = bold;
  51. this.faint = faint;
  52. this.italic = italic;
  53. this.underline = underline;
  54. this.blink = blink;
  55. this.inverse = inverse;
  56. this.invisible = invisible;
  57. }
  58. CellAttr copyWith({
  59. CellColor fgColor,
  60. CellColor bgColor,
  61. bool bold,
  62. bool faint,
  63. bool italic,
  64. bool underline,
  65. bool blink,
  66. bool inverse,
  67. bool invisible,
  68. }) {
  69. return CellAttr(
  70. fgColor: fgColor ?? this.fgColor,
  71. bgColor: bgColor ?? this.bgColor,
  72. bold: bold ?? this.bold,
  73. faint: faint ?? this.faint,
  74. italic: italic ?? this.italic,
  75. underline: underline ?? this.underline,
  76. blink: blink ?? this.blink,
  77. inverse: inverse ?? this.inverse,
  78. invisible: invisible ?? this.invisible,
  79. );
  80. }
  81. }
  82. class CellAttrTemplate {
  83. CellAttrTemplate();
  84. CellAttr _attr;
  85. set fgColor(CellColor value) {
  86. _attr = _attr.copyWith(fgColor: value);
  87. }
  88. set bgColor(CellColor value) {
  89. _attr = _attr.copyWith(bgColor: value);
  90. }
  91. set bold(bool value) {
  92. _attr = _attr.copyWith(bold: value);
  93. }
  94. set faint(bool value) {
  95. _attr = _attr.copyWith(faint: value);
  96. }
  97. set italic(bool value) {
  98. _attr = _attr.copyWith(italic: value);
  99. }
  100. set underline(bool value) {
  101. _attr = _attr.copyWith(underline: value);
  102. }
  103. set blink(bool value) {
  104. _attr = _attr.copyWith(blink: value);
  105. }
  106. set inverse(bool value) {
  107. _attr = _attr.copyWith(inverse: value);
  108. }
  109. set invisible(bool value) {
  110. _attr = _attr.copyWith(invisible: value);
  111. }
  112. CellAttr get value {}
  113. }