terminal_ui_interaction.dart 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. import 'package:xterm/buffer/line/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. /// select the whole buffer
  51. void selectAll();
  52. /// notify the Terminal about a mouse tap
  53. void onMouseTap(Position position);
  54. /// notify the Terminal about a mouse double tap
  55. void onMouseDoubleTap(Position position);
  56. /// notify the Terminal about a pan start
  57. void onPanStart(Position position);
  58. /// notify the Terminal about a pan update
  59. void onPanUpdate(Position position);
  60. /// sets the scroll offset from bottom (scrolling)
  61. void setScrollOffsetFromBottom(int offset);
  62. /// converts the given view line (view port line) index to its position in the
  63. /// overall buffer
  64. int convertViewLineToRawLine(int viewLine);
  65. /// notifies the Terminal about user input
  66. void raiseOnInput(String input);
  67. /// writes data to the Terminal
  68. void write(String text);
  69. /// paste clipboard content to the Terminal
  70. void paste(String data);
  71. /// notifies the Terminal about a resize that happened. The Terminal will
  72. /// do any resize / reflow logic and notify the backend about the resize
  73. void resize(
  74. int newWidth, int newHeight, int newPixelWidth, int newPixelHeight);
  75. /// notifies the Terminal about key input
  76. void keyInput(
  77. TerminalKey key, {
  78. bool ctrl = false,
  79. bool alt = false,
  80. bool shift = false,
  81. bool mac = false,
  82. // bool meta,
  83. });
  84. /// Future that fires when the backend has exited
  85. Future<int> get backendExited;
  86. /// terminates the backend. If already terminated, nothing happens
  87. void terminateBackend();
  88. /// flag that indicates if the backend is already terminated
  89. bool get isTerminated;
  90. /// returns the current composing string. '' when there is no composing going on
  91. String get composingString;
  92. /// update the composing string. This gets called by the input handling
  93. /// part of the terminal
  94. void updateComposingString(String value);
  95. }