From f89228db40afb03e344962534db431aabb44fae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?lollipopkit=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7?= =?UTF-8?q?=EF=B8=8F?= <10864310+lollipopkit@users.noreply.github.com> Date: Sat, 28 Sep 2024 17:09:35 +0800 Subject: [PATCH] opt.: ssh page --- lib/view/page/ssh/page.dart | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/view/page/ssh/page.dart b/lib/view/page/ssh/page.dart index 6b7b20579..b3842619a 100644 --- a/lib/view/page/ssh/page.dart +++ b/lib/view/page/ssh/page.dart @@ -346,11 +346,11 @@ class SSHPageState extends State await Future.delayed(const Duration(milliseconds: 777)); // the line below `echo $PWD` is the current path final idx = cmds.lastIndexWhere((e) => e.toString().contains(_echoPWD)); - final initPath = cmds[idx + 1].toString(); - if (initPath.isEmpty || !initPath.startsWith('/')) { + final initPath = cmds.elementAtOrNull(idx + 1)?.toString(); + if (initPath == null || !initPath.startsWith('/')) { context.showRoundDialog( title: libL10n.error, - child: const Text('Failed to get current path'), + child: Text('${l10n.remotePath}: $initPath'), ); return; } @@ -360,8 +360,14 @@ class SSHPageState extends State void _paste() { Clipboard.getData(Clipboard.kTextPlain).then((value) { - if (value != null) { - _terminal.textInput(value.text!); + final text = value?.text; + if (text != null) { + _terminal.textInput(text); + } else { + context.showRoundDialog( + title: libL10n.error, + child: Text(libL10n.empty), + ); } }); } @@ -400,7 +406,7 @@ class SSHPageState extends State } Future _initTerminal() async { - _writeLn('Connecting...\r\n'); + _writeLn(libL10n.content); _client ??= await genClient( widget.spi, onStatus: (p0) { @@ -410,7 +416,7 @@ class SSHPageState extends State KeybordInteractive.defaultHandle(widget.spi), ); - _writeLn('Starting shell...\r\n'); + _writeLn('${libL10n.execute}: Shell'); final session = await _client?.shell( pty: SSHPtyConfig( width: _terminal.viewWidth, @@ -422,7 +428,7 @@ class SSHPageState extends State //_setupDiscontinuityTimer(); if (session == null) { - _writeLn('Null session, please back and retry\r\n'); + _writeLn(libL10n.fail); return; }