This commit is contained in:
LZX committed 2026-09-16 13:40:49 +08:00
1 parent 1ab5d52449
commit 5efc778165
18 files changed
+1031 -63

No files matched your search

+12 -3
View File
@@ -300,6 +300,7 @@ class TerminalViewState extends State<TerminalView> {
terminalView: this,
terminalController: _controller,
onTapUp: _onTapUp,
onSingleTapUp: _onSingleTapUp,
onTapDown: _onTapDown,
onSecondaryTapDown:
widget.onSecondaryTapDown != null ? _onSecondaryTapDown : null,
@@ -345,8 +346,8 @@ class TerminalViewState extends State<TerminalView> {
widget.onTapUp?.call(details, offset);
}
void _onTapDown(_) {
if (_controller.selection != null) {
void _onSingleTapUp(TapUpDetails details) {
if (_controller.selection != null && !_controller.selection!.isCollapsed) {
_controller.clearSelection();
} else {
if (!widget.hardwareKeyboardOnly) {
@@ -355,6 +356,13 @@ class TerminalViewState extends State<TerminalView> {
_focusNode.requestFocus();
}
}
final offset = renderTerminal.getCellOffset(details.localPosition);
widget.onTapUp?.call(details, offset);
}
void _onTapDown(_) {
// Intentionally empty: tapping down (PointerDown) must not open the soft keyboard,
// ensuring long-press can select text without triggering keyboard pop-up or scroll jumps.
}
void _onSecondaryTapDown(TapDownDetails details) {
@@ -431,7 +439,8 @@ class TerminalViewState extends State<TerminalView> {
}
void _onKeyboardShow() {
if (_focusNode.hasFocus) {
if (_focusNode.hasFocus &&
(_controller.selection == null || _controller.selection!.isCollapsed)) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_scrollToBottom();
});
@@ -64,6 +64,13 @@ class _TerminalGestureDetectorState extends State<TerminalGestureDetector> {
// subsequent tap up / tap hold of the same tap.
bool _isDoubleTap = false;
@override
void dispose() {
_doubleTapTimer?.cancel();
_doubleTapTimer = null;
super.dispose();
}
// The down handler is force-run on success of a single tap and optimistically
// run before a long press success.
void _handleTapDown(TapDownDetails details) {
@@ -84,12 +91,19 @@ class _TerminalGestureDetectorState extends State<TerminalGestureDetector> {
void _handleTapUp(TapUpDetails details) {
if (!_isDoubleTap) {
widget.onSingleTapUp?.call(details);
widget.onTapUp?.call(details);
_lastTapOffset = details.globalPosition;
_doubleTapTimer = Timer(kDoubleTapTimeout, _doubleTapTimeout);
}
_isDoubleTap = false;
}
void _handleTapCancel() {
_doubleTapTimer?.cancel();
_doubleTapTimeout();
_isDoubleTap = false;
}
void _doubleTapTimeout() {
_doubleTapTimer = null;
_lastTapOffset = null;
@@ -115,6 +129,7 @@ class _TerminalGestureDetectorState extends State<TerminalGestureDetector> {
instance
..onTapDown = _handleTapDown
..onTapUp = _handleTapUp
..onTapCancel = _handleTapCancel
..onSecondaryTapDown = widget.onSecondaryTapDown
..onSecondaryTapUp = widget.onSecondaryTapUp
..onTertiaryTapDown = widget.onTertiaryTapDown