IOutput.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System.Collections.Concurrent;
  2. namespace Terminal.Gui.Drivers;
  3. /// <summary>
  4. /// The low-level interface drivers implement to provide output capabilities; encapsulates platform-specific
  5. /// output functionality.
  6. /// </summary>
  7. public interface IOutput : IDisposable
  8. {
  9. /// <seealso cref="IDriver.Force16Colors"/>
  10. bool Force16Colors { get; set; }
  11. /// <seealso cref="IDriver.IsLegacyConsole"/>
  12. bool IsLegacyConsole { get; set; }
  13. /// <seealso cref="IDriver.GetSixels"/>
  14. ConcurrentQueue<SixelToRender> GetSixels ();
  15. /// <summary>
  16. /// Gets the current position of the console cursor.
  17. /// </summary>
  18. /// <returns></returns>
  19. Point GetCursorPosition ();
  20. /// <summary>
  21. /// Returns the current size of the console in rows/columns (i.e.
  22. /// of characters not pixels).
  23. /// </summary>
  24. /// <returns></returns>
  25. Size GetSize ();
  26. /// <summary>
  27. /// Moves the console cursor to the given location.
  28. /// </summary>
  29. /// <param name="col"></param>
  30. /// <param name="row"></param>
  31. void SetCursorPosition (int col, int row);
  32. /// <summary>
  33. /// Updates the console cursor (the blinking underscore) to be hidden,
  34. /// visible etc.
  35. /// </summary>
  36. /// <param name="visibility"></param>
  37. void SetCursorVisibility (CursorVisibility visibility);
  38. /// <summary>
  39. /// Sets the size of the console.
  40. /// </summary>
  41. /// <param name="width"></param>
  42. /// <param name="height"></param>
  43. void SetSize (int width, int height);
  44. /// <summary>
  45. /// Writes the given text directly to the console. Use to send
  46. /// ansi escape codes etc. Regular screen output should use the
  47. /// <see cref="IOutputBuffer"/> overload.
  48. /// </summary>
  49. /// <param name="text"></param>
  50. void Write (ReadOnlySpan<char> text);
  51. /// <summary>
  52. /// Write the contents of the <paramref name="buffer"/> to the console
  53. /// </summary>
  54. /// <param name="buffer"></param>
  55. void Write (IOutputBuffer buffer);
  56. /// <summary>
  57. /// Gets a string containing the ANSI escape sequences and content most recently written
  58. /// to the terminal via <see cref="Write(IOutputBuffer)"/>
  59. /// </summary>
  60. string GetLastOutput ();
  61. /// <summary>
  62. /// Generates an ANSI escape sequence string representation of the given <paramref name="buffer"/> contents.
  63. /// This is the same output that would be written to the terminal to recreate the current screen contents.
  64. /// </summary>
  65. /// <param name="buffer">The output buffer to convert to ANSI.</param>
  66. /// <returns>A string containing ANSI escape sequences representing the buffer contents.</returns>
  67. string ToAnsi (IOutputBuffer buffer);
  68. }