|
@@ -1,5 +1,6 @@
|
|
|
import 'package:flutter/gestures.dart';
|
|
import 'package:flutter/gestures.dart';
|
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
|
+import 'package:xterm/src/core/buffer/cell_offset.dart';
|
|
|
import 'package:xterm/src/core/mouse/button.dart';
|
|
import 'package:xterm/src/core/mouse/button.dart';
|
|
|
import 'package:xterm/src/core/mouse/button_state.dart';
|
|
import 'package:xterm/src/core/mouse/button_state.dart';
|
|
|
import 'package:xterm/src/terminal_view.dart';
|
|
import 'package:xterm/src/terminal_view.dart';
|
|
@@ -59,6 +60,9 @@ class _TerminalGestureHandlerState extends State<TerminalGestureHandler> {
|
|
|
|
|
|
|
|
LongPressStartDetails? _lastLongPressStartDetails;
|
|
LongPressStartDetails? _lastLongPressStartDetails;
|
|
|
|
|
|
|
|
|
|
+ CellOffset? _dragStartCellOffset;
|
|
|
|
|
+ CellOffset? _longPressStartCellOffset;
|
|
|
|
|
+
|
|
|
@override
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
|
return TerminalGestureDetector(
|
|
return TerminalGestureDetector(
|
|
@@ -162,13 +166,17 @@ class _TerminalGestureHandlerState extends State<TerminalGestureHandler> {
|
|
|
|
|
|
|
|
void onLongPressStart(LongPressStartDetails details) {
|
|
void onLongPressStart(LongPressStartDetails details) {
|
|
|
_lastLongPressStartDetails = details;
|
|
_lastLongPressStartDetails = details;
|
|
|
- renderTerminal.selectWord(details.localPosition);
|
|
|
|
|
|
|
+ _longPressStartCellOffset = renderTerminal.getCellOffset(details.localPosition);
|
|
|
|
|
+ // Use selectWordByCell to start selection
|
|
|
|
|
+ renderTerminal.selectWordByCell(_longPressStartCellOffset!);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void onLongPressMoveUpdate(LongPressMoveUpdateDetails details) {
|
|
void onLongPressMoveUpdate(LongPressMoveUpdateDetails details) {
|
|
|
- renderTerminal.selectWord(
|
|
|
|
|
- _lastLongPressStartDetails!.localPosition,
|
|
|
|
|
- details.localPosition,
|
|
|
|
|
|
|
+ if (_longPressStartCellOffset == null) return;
|
|
|
|
|
+ final currentCellOffset = renderTerminal.getCellOffset(details.localPosition);
|
|
|
|
|
+ renderTerminal.selectWordByCell(
|
|
|
|
|
+ _longPressStartCellOffset!,
|
|
|
|
|
+ currentCellOffset,
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -176,16 +184,45 @@ class _TerminalGestureHandlerState extends State<TerminalGestureHandler> {
|
|
|
|
|
|
|
|
void onDragStart(DragStartDetails details) {
|
|
void onDragStart(DragStartDetails details) {
|
|
|
_lastDragStartDetails = details;
|
|
_lastDragStartDetails = details;
|
|
|
|
|
+ _dragStartCellOffset = renderTerminal.getCellOffset(details.localPosition);
|
|
|
|
|
|
|
|
details.kind == PointerDeviceKind.mouse
|
|
details.kind == PointerDeviceKind.mouse
|
|
|
- ? renderTerminal.selectCharacters(details.localPosition)
|
|
|
|
|
- : renderTerminal.selectWord(details.localPosition);
|
|
|
|
|
|
|
+ ? renderTerminal.selectCharactersByCell(_dragStartCellOffset!)
|
|
|
|
|
+ : renderTerminal.selectWordByCell(_dragStartCellOffset!);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void onDragUpdate(DragUpdateDetails details) {
|
|
void onDragUpdate(DragUpdateDetails details) {
|
|
|
- renderTerminal.selectCharacters(
|
|
|
|
|
- _lastDragStartDetails!.localPosition,
|
|
|
|
|
- details.localPosition,
|
|
|
|
|
|
|
+ if (_dragStartCellOffset == null) return;
|
|
|
|
|
+
|
|
|
|
|
+ final currentCellOffset = renderTerminal.getCellOffset(details.localPosition);
|
|
|
|
|
+
|
|
|
|
|
+ // renderTerminal.selectCharacters(
|
|
|
|
|
+ // _lastDragStartDetails!.localPosition,
|
|
|
|
|
+ // details.localPosition,
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // Instead of using screen coordinates, use logical cell coordinates.
|
|
|
|
|
+ // Assuming drag mode keeps the same selection granularity (char vs word).
|
|
|
|
|
+ // The original code used selectCharacters for update always?
|
|
|
|
|
+ // Wait, original onDragStart did selectWord for touch, but onDragUpdate did selectCharacters.
|
|
|
|
|
+ // If I started with word selection (touch), should I continue with word selection?
|
|
|
|
|
+ // Usually yes.
|
|
|
|
|
+
|
|
|
|
|
+ // But RenderTerminal.selectCharacters behaves differently than selectWord.
|
|
|
|
|
+ // Original code:
|
|
|
|
|
+ // onDragUpdate(DragUpdateDetails details) {
|
|
|
|
|
+ // renderTerminal.selectCharacters(
|
|
|
|
|
+ // _lastDragStartDetails!.localPosition,
|
|
|
|
|
+ // details.localPosition,
|
|
|
|
|
+ // );
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ // This looks like it switches to character selection during drag even if it started as word selection?
|
|
|
|
|
+ // Let's stick to what original code did: selectCharacters.
|
|
|
|
|
+
|
|
|
|
|
+ renderTerminal.selectCharactersByCell(
|
|
|
|
|
+ _dragStartCellOffset!,
|
|
|
|
|
+ currentCellOffset,
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|