IOutput.cs 2.2 KB

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