|
|
@@ -1,6 +1,7 @@
|
|
|
import 'dart:math' show max;
|
|
|
|
|
|
import 'package:xterm/src/core/buffer/buffer.dart';
|
|
|
+import 'package:xterm/src/core/buffer/cell_offset.dart';
|
|
|
import 'package:xterm/src/core/buffer/line.dart';
|
|
|
import 'package:xterm/src/core/cursor.dart';
|
|
|
import 'package:xterm/src/core/escape/emitter.dart';
|
|
|
@@ -9,6 +10,9 @@ import 'package:xterm/src/core/escape/parser.dart';
|
|
|
import 'package:xterm/src/core/input/handler.dart';
|
|
|
import 'package:xterm/src/core/input/keys.dart';
|
|
|
import 'package:xterm/src/core/mouse/mode.dart';
|
|
|
+import 'package:xterm/src/core/mouse/button.dart';
|
|
|
+import 'package:xterm/src/core/mouse/button_state.dart';
|
|
|
+import 'package:xterm/src/core/mouse/handler.dart';
|
|
|
import 'package:xterm/src/core/state.dart';
|
|
|
import 'package:xterm/src/core/tabs.dart';
|
|
|
import 'package:xterm/src/utils/ascii.dart';
|
|
|
@@ -44,8 +48,11 @@ class Terminal with Observable implements TerminalState, EscapeHandler {
|
|
|
this.onResize,
|
|
|
this.platform = TerminalTargetPlatform.unknown,
|
|
|
this.inputHandler = defaultInputHandler,
|
|
|
+ this.mouseHandler = defaultMouseHandler,
|
|
|
});
|
|
|
|
|
|
+ TerminalMouseHandler? mouseHandler;
|
|
|
+
|
|
|
late final _parser = EscapeParser(this);
|
|
|
|
|
|
final _emitter = const EscapeEmitter();
|
|
|
@@ -234,6 +241,23 @@ class Terminal with Observable implements TerminalState, EscapeHandler {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ void mouseInput(
|
|
|
+ TerminalMouseButton button,
|
|
|
+ TerminalMouseButtonState buttonState,
|
|
|
+ CellOffset position,
|
|
|
+ ) {
|
|
|
+ final output = mouseHandler?.call(TerminalMouseEvent(
|
|
|
+ button: button,
|
|
|
+ buttonState: buttonState,
|
|
|
+ position: position,
|
|
|
+ state: this,
|
|
|
+ platform: platform,
|
|
|
+ ));
|
|
|
+ if (output != null) {
|
|
|
+ onOutput?.call(output);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/// Resize the terminal screen. [newWidth] and [newHeight] should be greater
|
|
|
/// than 0. Text reflow is currently not implemented and will be avaliable in
|
|
|
/// the future.
|