fix: ssh term (#365)

This commit is contained in:
lollipopkit
2024-05-27 11:32:52 +08:00
parent ccab4040b1
commit 1a3cb09ca2
33 changed files with 73 additions and 66 deletions

View File

@@ -30,7 +30,7 @@ class SSHPage extends StatefulWidget {
final String? initCmd;
final bool notFromTab;
final Function()? onSessionEnd;
final FocusNode? focus;
final GlobalKey<TerminalViewState>? terminalKey;
const SSHPage({
super.key,
@@ -38,11 +38,11 @@ class SSHPage extends StatefulWidget {
this.initCmd,
this.notFromTab = true,
this.onSessionEnd,
this.focus,
this.terminalKey,
});
@override
_SSHPageState createState() => _SSHPageState();
State<SSHPage> createState() => _SSHPageState();
}
const _horizonPadding = 7.0;
@@ -52,7 +52,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
late final _terminal = Terminal(inputHandler: _keyboard);
final TerminalController _terminalController = TerminalController();
final List<List<VirtKey>> _virtKeysList = [];
late final _focus = widget.focus ?? FocusNode();
late final _termKey = widget.terminalKey ?? GlobalKey<TerminalViewState>();
late MediaQueryData _media;
late TerminalStyle _terminalStyle;
@@ -144,8 +144,8 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
),
child: TerminalView(
_terminal,
key: _termKey,
controller: _terminalController,
focusNode: _focus,
keyboardType: TextInputType.text,
enableSuggestions: true,
textStyle: _terminalStyle,
@@ -282,11 +282,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
Future<void> _doVirtualKeyFunc(VirtualKeyFunc type) async {
switch (type) {
case VirtualKeyFunc.toggleIME:
if (!_focus.hasFocus) {
_focus.requestFocus();
} else {
_focus.unfocus();
}
_termKey.currentState?.toggleFocus();
break;
case VirtualKeyFunc.backspace:
_terminal.keyInput(TerminalKey.backspace);