File tree 1 file changed +23
-2
lines changed
1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 1
1
import 'package:flutter/services.dart' ;
2
+ import 'package:flutter/widgets.dart' ;
2
3
import 'package:xterm/frontend/input_behavior_default.dart' ;
3
4
import 'package:xterm/input/keys.dart' ;
4
5
import 'package:xterm/xterm.dart' ;
5
6
6
7
class InputBehaviorMobile extends InputBehaviorDefault {
7
8
InputBehaviorMobile ();
8
9
9
- @override
10
10
final acceptKeyStroke = true ;
11
11
12
- @override
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
+ }
33
+
13
34
void onAction (TextInputAction action, TerminalUiInteraction terminal) {
14
35
print ('action $action ' );
15
36
switch (action) {
You can’t perform that action at this time.
0 commit comments