IOutputBuffer.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #nullable enable
  2. namespace Terminal.Gui;
  3. /// <summary>
  4. /// Describes the screen state that you want the console to be in.
  5. /// Is designed to be drawn to repeatedly then manifest into the console
  6. /// once at the end of iteration after all drawing is finalized.
  7. /// </summary>
  8. public interface IOutputBuffer
  9. {
  10. /// <summary>
  11. /// As performance is a concern, we keep track of the dirty lines and only refresh those.
  12. /// This is in addition to the dirty flag on each cell.
  13. /// </summary>
  14. public bool [] DirtyLines { get; }
  15. /// <summary>
  16. /// The contents of the application output. The driver outputs this buffer to the terminal when UpdateScreen is called.
  17. /// </summary>
  18. Cell [,] Contents { get; set; }
  19. /// <summary>
  20. /// Gets or sets the clip rectangle that <see cref="AddRune(Rune)"/> and <see cref="AddStr(string)"/> are subject
  21. /// to.
  22. /// </summary>
  23. /// <value>The rectangle describing the of <see cref="Clip"/> region.</value>
  24. public Region? Clip { get; set; }
  25. /// <summary>
  26. /// The <see cref="Attribute"/> that will be used for the next AddRune or AddStr call.
  27. /// </summary>
  28. Attribute CurrentAttribute { get; set; }
  29. /// <summary>The number of rows visible in the terminal.</summary>
  30. int Rows { get; set; }
  31. /// <summary>The number of columns visible in the terminal.</summary>
  32. int Cols { get; set; }
  33. /// <summary>
  34. /// Gets the row last set by <see cref="Move"/>. <see cref="Col"/> and <see cref="Row"/> are used by
  35. /// <see cref="AddRune(Rune)"/> and <see cref="AddStr"/> to determine where to add content.
  36. /// </summary>
  37. public int Row { get; }
  38. /// <summary>
  39. /// Gets the column last set by <see cref="Move"/>. <see cref="Col"/> and <see cref="Row"/> are used by
  40. /// <see cref="AddRune(Rune)"/> and <see cref="AddStr"/> to determine where to add content.
  41. /// </summary>
  42. public int Col { get; }
  43. /// <summary>
  44. /// The first cell index on left of screen - basically always 0.
  45. /// Changing this may have unexpected consequences.
  46. /// </summary>
  47. int Left { get; set; }
  48. /// <summary>
  49. /// The first cell index on top of screen - basically always 0.
  50. /// Changing this may have unexpected consequences.
  51. /// </summary>
  52. int Top { get; set; }
  53. /// <summary>
  54. /// Updates the column and row to the specified location in the buffer.
  55. /// </summary>
  56. /// <param name="col">The column to move to.</param>
  57. /// <param name="row">The row to move to.</param>
  58. void Move (int col, int row);
  59. /// <summary>Adds the specified rune to the display at the current cursor position.</summary>
  60. /// <param name="rune">Rune to add.</param>
  61. void AddRune (Rune rune);
  62. /// <summary>
  63. /// Adds the specified character to the display at the current cursor position. This is a convenience method for
  64. /// AddRune.
  65. /// </summary>
  66. /// <param name="c">Character to add.</param>
  67. void AddRune (char c);
  68. /// <summary>Adds the string to the display at the current cursor position.</summary>
  69. /// <param name="str">String to add.</param>
  70. void AddStr (string str);
  71. /// <summary>Clears the contents of the buffer.</summary>
  72. void ClearContents ();
  73. /// <summary>
  74. /// Tests whether the specified coordinate is valid for drawing the specified Rune.
  75. /// </summary>
  76. /// <param name="rune">Used to determine if one or two columns are required.</param>
  77. /// <param name="col">The column.</param>
  78. /// <param name="row">The row.</param>
  79. /// <returns>
  80. /// True if the coordinate is valid for the Rune; false otherwise.
  81. /// </returns>
  82. bool IsValidLocation (Rune rune, int col, int row);
  83. /// <summary>
  84. /// Changes the size of the buffer to the given size
  85. /// </summary>
  86. /// <param name="cols"></param>
  87. /// <param name="rows"></param>
  88. void SetWindowSize (int cols, int rows);
  89. /// <summary>
  90. /// Fills the given <paramref name="rect"/> with the given
  91. /// symbol using the currently selected attribute.
  92. /// </summary>
  93. /// <param name="rect"></param>
  94. /// <param name="rune"></param>
  95. void FillRect (Rectangle rect, Rune rune);
  96. /// <summary>
  97. /// Fills the given <paramref name="rect"/> with the given
  98. /// symbol using the currently selected attribute.
  99. /// </summary>
  100. /// <param name="rect"></param>
  101. /// <param name="rune"></param>
  102. void FillRect (Rectangle rect, char rune);
  103. }