terminal_ui_interaction.dart 4.7 KB

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