terminal_ui_interaction.dart 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import 'package:xterm/buffer/buffer_line.dart';
  2. import 'package:xterm/input/keys.dart';
  3. import 'package:xterm/mouse/position.dart';
  4. import 'package:xterm/mouse/selection.dart';
  5. import 'package:xterm/terminal/platform.dart';
  6. import 'package:xterm/util/observable.dart';
  7. /// this interface describes what a Terminal UI needs from a Terminal
  8. abstract class TerminalUiInteraction with Observable {
  9. /// the ViewPort scroll offset from the bottom
  10. int get scrollOffsetFromBottom;
  11. /// the ViewPort scroll offset from the top
  12. int get scrollOffsetFromTop;
  13. /// the total buffer height
  14. int get bufferHeight;
  15. /// terminal height (view port)
  16. int get terminalHeight;
  17. /// terminal width (view port)
  18. int get terminalWidth;
  19. /// the part of the buffer that is not visible (scrollback)
  20. int get invisibleHeight;
  21. /// object that describes details about the current selection
  22. Selection? get selection;
  23. /// [true] when the cursor shall be shown, otherwise [false]
  24. bool get showCursor;
  25. /// returns the visible lines
  26. List<BufferLine> getVisibleLines();
  27. /// cursor y coordinate
  28. int get cursorY;
  29. /// cursor x coordinate
  30. int get cursorX;
  31. /// current line
  32. BufferLine? get currentLine;
  33. /// color code for the cursor
  34. int get cursorColor;
  35. /// color code for the background
  36. int get backgroundColor;
  37. /// flag that indicates if the terminal is dirty (since the last time this
  38. /// flag has been queried)
  39. bool get dirty;
  40. /// platform behavior for this terminal
  41. PlatformBehavior get platform;
  42. /// selected text defined by [selection]
  43. String? get selectedText;
  44. /// flag that indicates if the Terminal is ready
  45. bool get isReady;
  46. /// refreshes the Terminal (notifies listeners and sets it to dirty)
  47. void refresh();
  48. /// clears the selection
  49. void clearSelection();
  50. /// notify the Terminal about a mouse tap
  51. void onMouseTap(Position position);
  52. /// notify the Terminal about a pan start
  53. void onPanStart(Position position);
  54. /// notify the Terminal about a pan update
  55. void onPanUpdate(Position position);
  56. /// sets the scroll offset from bottom (scrolling)
  57. void setScrollOffsetFromBottom(int offset);
  58. /// converts the given view line (view port line) index to its position in the
  59. /// overall buffer
  60. int convertViewLineToRawLine(int viewLine);
  61. /// notifies the Terminal about user input
  62. void raiseOnInput(String input);
  63. /// writes data to the Terminal
  64. void write(String text);
  65. /// paste clipboard content to the Terminal
  66. void paste(String data);
  67. /// notifies the Terminal about a resize that happened. The Terminal will
  68. /// do any resize / reflow logic and notify the backend about the resize
  69. void resize(int newWidth, int newHeight);
  70. /// notifies the Terminal about key input
  71. void keyInput(
  72. TerminalKey key, {
  73. bool ctrl = false,
  74. bool alt = false,
  75. bool shift = false,
  76. bool mac = false,
  77. // bool meta,
  78. });
  79. /// Future that fires when the backend has exited
  80. Future<int> get backendExited;
  81. /// terminates the backend. If already terminated, nothing happens
  82. void terminateBackend();
  83. /// flag that indicates if the backend is already terminated
  84. bool get isTerminated;
  85. }