Skip to content

Commit 7fc229f

Browse files
author
stalin
committed
enable backspace for mobile platform.
I think it's bad idea to totally reject key stroke. It made many functional keybinding not usable. Just accept it as PC does and throw those situation to application developer is more resonable.
1 parent 43e5414 commit 7fc229f

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

lib/frontend/input_behavior_mobile.dart

+3-24
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,15 @@
11
import 'package:flutter/services.dart';
2-
import 'package:flutter/widgets.dart';
32
import 'package:xterm/frontend/input_behavior_default.dart';
43
import 'package:xterm/input/keys.dart';
54
import 'package:xterm/xterm.dart';
65

76
class InputBehaviorMobile extends InputBehaviorDefault {
87
InputBehaviorMobile();
98

10-
final acceptKeyStroke = false;
11-
12-
final initEditingState = const TextEditingValue(
13-
text: ' ',
14-
selection: TextSelection.collapsed(offset: 1),
15-
);
16-
17-
TextEditingValue onTextEdit(
18-
TextEditingValue value, TerminalUiInteraction terminal) {
19-
if (value.text.length > initEditingState.text.length) {
20-
terminal.raiseOnInput(value.text.substring(1, value.text.length - 1));
21-
} else if (value.text.length < initEditingState.text.length) {
22-
terminal.keyInput(TerminalKey.backspace);
23-
} else {
24-
if (value.selection.baseOffset < 1) {
25-
terminal.keyInput(TerminalKey.arrowLeft);
26-
} else if (value.selection.baseOffset > 1) {
27-
terminal.keyInput(TerminalKey.arrowRight);
28-
}
29-
}
30-
31-
return initEditingState;
32-
}
9+
@override
10+
final acceptKeyStroke = true;
3311

12+
@override
3413
void onAction(TextInputAction action, TerminalUiInteraction terminal) {
3514
print('action $action');
3615
switch (action) {

0 commit comments

Comments
 (0)