terminal_ui_interaction.dart 3.7 KB

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