fix: ssh session not inited

This commit is contained in:
lollipopkit
2023-08-17 14:59:23 +08:00
parent 329922a836
commit 1be87d0ec0
18 changed files with 90 additions and 160 deletions

View File

@@ -956,11 +956,11 @@ abstract class S {
/// **'Preview'**
String get preview;
/// No description provided for @primaryColor.
/// No description provided for @primaryColorSeed.
///
/// In en, this message translates to:
/// **'Primary color'**
String get primaryColor;
/// **'Primary color seed'**
String get primaryColorSeed;
/// No description provided for @privateKey.
///

View File

@@ -456,7 +456,7 @@ class SDe extends S {
String get preview => 'Vorschau';
@override
String get primaryColor => 'Farbschema';
String get primaryColorSeed => 'Farbschema';
@override
String get privateKey => 'Private Key';

View File

@@ -456,7 +456,7 @@ class SEn extends S {
String get preview => 'Preview';
@override
String get primaryColor => 'Primary color';
String get primaryColorSeed => 'Primary color seed';
@override
String get privateKey => 'Private Key';

View File

@@ -456,7 +456,7 @@ class SId extends S {
String get preview => 'Pratinjau';
@override
String get primaryColor => 'Warna utama';
String get primaryColorSeed => 'Warna utama';
@override
String get privateKey => 'Kunci Pribadi';

View File

@@ -456,7 +456,7 @@ class SZh extends S {
String get preview => '预览';
@override
String get primaryColor => '主题色';
String get primaryColorSeed => '主题色种子';
@override
String get privateKey => '私钥';
@@ -1155,7 +1155,7 @@ class SZhTw extends SZh {
String get preview => '預覽';
@override
String get primaryColor => '主要色調';
String get primaryColorSeed => '主要色調種子';
@override
String get privateKey => '私鑰';

View File

@@ -470,7 +470,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 473;
CURRENT_PROJECT_VERSION = 474;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -478,7 +478,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.473;
MARKETING_VERSION = 1.0.474;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -602,7 +602,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 473;
CURRENT_PROJECT_VERSION = 474;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -610,7 +610,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.473;
MARKETING_VERSION = 1.0.474;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -628,7 +628,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 473;
CURRENT_PROJECT_VERSION = 474;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -636,7 +636,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0.473;
MARKETING_VERSION = 1.0.474;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -657,7 +657,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 473;
CURRENT_PROJECT_VERSION = 474;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
@@ -670,7 +670,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.473;
MARKETING_VERSION = 1.0.474;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
@@ -696,7 +696,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 473;
CURRENT_PROJECT_VERSION = 474;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
@@ -709,7 +709,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.473;
MARKETING_VERSION = 1.0.474;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -732,7 +732,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 473;
CURRENT_PROJECT_VERSION = 474;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES;
@@ -745,7 +745,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.473;
MARKETING_VERSION = 1.0.474;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
PRODUCT_NAME = "$(TARGET_NAME)";

View File

@@ -2,8 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 473;
static const int build = 474;
static const String engine = "3.10.6";
static const String buildAt = "2023-08-15 23:06:31.430481";
static const int modifications = 2;
static const String buildAt = "2023-08-16 15:42:48.857532";
static const int modifications = 24;
}

View File

@@ -143,7 +143,7 @@
"plzSelectKey": "Wähle einen Key.",
"port": "Port",
"preview": "Vorschau",
"primaryColor": "Farbschema",
"primaryColorSeed": "Farbschema",
"privateKey": "Private Key",
"process": "Prozess",
"pushToken": "Push Token",

View File

@@ -143,7 +143,7 @@
"plzSelectKey": "Please select a key.",
"port": "Port",
"preview": "Preview",
"primaryColor": "Primary color",
"primaryColorSeed": "Primary color seed",
"privateKey": "Private Key",
"process": "Process",
"pushToken": "Push token",

View File

@@ -143,7 +143,7 @@
"plzSelectKey": "Pilih kunci.",
"port": "Port",
"preview": "Pratinjau",
"primaryColor": "Warna utama",
"primaryColorSeed": "Warna utama",
"privateKey": "Kunci Pribadi",
"process": "Proses",
"pushToken": "Dorong token",

View File

@@ -143,7 +143,7 @@
"plzSelectKey": "请选择私钥",
"port": "端口",
"preview": "预览",
"primaryColor": "主题色",
"primaryColorSeed": "主题色种子",
"privateKey": "私钥",
"process": "进程",
"pushToken": "消息推送 Token",

View File

@@ -143,7 +143,7 @@
"plzSelectKey": "請選擇私鑰",
"port": "端口",
"preview": "預覽",
"primaryColor": "主要色調",
"primaryColorSeed": "主要色調種子",
"privateKey": "私鑰",
"process": "進程",
"pushToken": "消息推送 Token",

View File

@@ -437,10 +437,12 @@ class _ServerDetailPageState extends State<ServerDetailPage>
),
],
)));
return RoundRectCard(Padding(
padding: roundRectCardPadding,
child: Column(children: children),
),);
return RoundRectCard(
Padding(
padding: roundRectCardPadding,
child: Column(children: children),
),
);
}
Widget _buildAnimatedText(Key key, String text, TextStyle style) {

View File

@@ -274,14 +274,12 @@ class _SettingPageState extends State<SettingPage> {
width: 27,
),
),
title: Text(
_s.primaryColor,
),
title: Text(_s.primaryColorSeed),
onTap: () async {
final ctrl = TextEditingController(text: primaryColor.toHex);
await showRoundDialog(
context: context,
title: Text(_s.primaryColor),
title: Text(_s.primaryColorSeed),
child: Input(
onSubmitted: _onSaveColor,
controller: ctrl,
@@ -674,7 +672,7 @@ class _SettingPageState extends State<SettingPage> {
},
).toList();
return ListTile(
title: Text(_s.light + _s.theme),
title: Text('${_s.light} ${_s.theme.toLowerCase()}'),
trailing: ValueBuilder(
listenable: _editorTheme,
build: () => PopupMenuButton(
@@ -707,7 +705,7 @@ class _SettingPageState extends State<SettingPage> {
},
).toList();
return ListTile(
title: Text(_s.dark + _s.theme),
title: Text('${_s.dark} ${_s.theme.toLowerCase()}'),
trailing: ValueBuilder(
listenable: _editorDarkTheme,
build: () => PopupMenuButton(

View File

@@ -40,7 +40,6 @@ class _SSHPageState extends State<SSHPage> {
final _setting = locator<SettingStore>();
late final _terminal = Terminal(inputHandler: _keyboard);
final TerminalController _terminalController = TerminalController();
final ContextMenuController _menuController = ContextMenuController();
final List<List<VirtKey>> _virtKeysList = [];
late MediaQueryData _media;
@@ -48,13 +47,13 @@ class _SSHPageState extends State<SSHPage> {
late TerminalStyle _terminalStyle;
late TerminalTheme _terminalTheme;
late TextInputType _keyboardType;
late SSHSession _session;
late double _virtKeyWidth;
late double _virtKeysHeight;
bool _isDark = false;
Timer? _virtKeyLongPressTimer;
SSHClient? _client;
SSHSession? _session;
@override
void initState() {
@@ -76,10 +75,7 @@ class _SSHPageState extends State<SSHPage> {
_virtKeyLongPressTimer?.cancel();
_terminalController.dispose();
_client?.close();
// ignore: unnecessary_null_comparison
if (_session != null) {
_session.close();
}
_session?.close();
}
@override
@@ -116,16 +112,18 @@ class _SSHPageState extends State<SSHPage> {
_virtKeysHeight -
_media.padding.bottom -
_media.padding.top,
child: TerminalView(
_terminal,
onTapUp: _onTapUp,
controller: _terminalController,
keyboardType: _keyboardType,
textStyle: _terminalStyle,
theme: _terminalTheme,
deleteDetection: isIOS,
autofocus: true,
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
child: Padding(
padding: EdgeInsets.only(top: _media.padding.top),
child: TerminalView(
_terminal,
controller: _terminalController,
keyboardType: _keyboardType,
textStyle: _terminalStyle,
theme: _terminalTheme,
deleteDetection: isIOS,
autofocus: true,
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
),
),
);
}
@@ -268,13 +266,8 @@ class _SSHPageState extends State<SSHPage> {
);
return;
}
AppRoute(
SftpPage(
widget.spi,
initPath: initPath,
),
'SSH SFTP')
.go(context);
final page = SftpPage(widget.spi, initPath: initPath);
AppRoute(page, 'SSH SFTP').go(context);
}
}
@@ -338,76 +331,42 @@ class _SSHPageState extends State<SSHPage> {
),
);
if (_session == null) {
showSnackBar(context, const Text('Null session'));
return;
}
_terminal.buffer.clear();
_terminal.buffer.setCursor(0, 0);
_terminal.onOutput = (data) {
_session.write(utf8.encode(data) as Uint8List);
_session?.write(utf8.encode(data) as Uint8List);
};
_terminal.onResize = (width, height, pixelWidth, pixelHeight) {
_session?.resizeTerminal(width, height);
};
_listen(_session.stdout);
_listen(_session.stderr);
_listen(_session?.stdout);
_listen(_session?.stderr);
if (widget.initCmd != null) {
_terminal.textInput(widget.initCmd!);
_terminal.keyInput(TerminalKey.enter);
}
await _session.done;
await _session?.done;
if (mounted) {
context.pop();
}
}
void _listen(Stream<Uint8List> stream) {
void _listen(Stream<Uint8List>? stream) {
if (stream == null) {
return;
}
stream
.cast<List<int>>()
.transform(const Utf8Decoder())
.listen(_terminal.write);
}
void _onTapUp(TapUpDetails details, CellOffset offset) {
if (_menuController.isShown) {
_menuController.remove();
return;
}
final selected = terminalSelected;
final children = <Widget>[
// TextButton(
// onPressed: () {
// _paste();
// },
// child: Text(_s.paste),
// ),
];
if (selected?.trim().isNotEmpty ?? false) {
children.add(
TextButton(
child: Text(
_s.copy,
),
onPressed: () {
_terminalController.setSelection(CellAnchor(0), CellAnchor(0));
if (selected != null) {
copy2Clipboard(selected);
}
_menuController.remove();
},
),
);
}
if (children.isEmpty) {
return;
}
_menuController.show(
context: context,
contextMenuBuilder: (context) {
return TextSelectionToolbar(
anchorAbove: details.globalPosition,
anchorBelow: details.globalPosition,
children: children,
);
},
);
}
}

View File

@@ -475,9 +475,9 @@
baseConfigurationReference = C1C758C41C4E208965A68933 /* Pods-RunnerTests.debug.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 473;
CURRENT_PROJECT_VERSION = 474;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0.473;
MARKETING_VERSION = 1.0.474;
PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
@@ -490,9 +490,9 @@
baseConfigurationReference = 15AF97DF993E8968098D6EBE /* Pods-RunnerTests.release.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 473;
CURRENT_PROJECT_VERSION = 474;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0.473;
MARKETING_VERSION = 1.0.474;
PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
@@ -505,9 +505,9 @@
baseConfigurationReference = 7CFA7DE7FABA75685DFB6948 /* Pods-RunnerTests.profile.xcconfig */;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CURRENT_PROJECT_VERSION = 473;
CURRENT_PROJECT_VERSION = 474;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0.473;
MARKETING_VERSION = 1.0.474;
PRODUCT_BUNDLE_IDENTIFIER = tech.lolli.serverBox.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;

View File

@@ -1038,9 +1038,11 @@ packages:
xterm:
dependency: "direct main"
description:
path: "../xterm.dart"
relative: true
source: path
path: "."
ref: master
resolved-ref: "937c25f58904432a4eb478a8b7f81bc012d20027"
url: "https://github.com/lollipopkit/xterm.dart"
source: git
version: "3.6.1-pre"
yaml:
dependency: transitive

View File

@@ -1,31 +1,11 @@
name: toolbox
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
description: A server toolbox app.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.17.0 <3.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
@@ -54,10 +34,10 @@ dependencies:
intl: ^0.18.0
# xterm: ^3.5.0
xterm:
path: ../xterm.dart
# git:
# ref: master
# url: https://github.com/lollipopkit/xterm.dart
#path: ../xterm.dart
git:
ref: master
url: https://github.com/lollipopkit/xterm.dart
file_picker: ^5.3.2
plain_notification_token: ^0.0.4
highlight: ^0.7.0
@@ -70,24 +50,13 @@ dev_dependencies:
flutter_native_splash: ^2.1.6
hive_generator: ^2.0.0
build_runner: ^2.3.2
flutter_lints: ^2.0.0
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^2.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
generate: true
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
@@ -182,4 +151,4 @@ flutter_native_splash:
- 'ios/Runner/Info-Profile.plist'
- 'ios/Runner/Info-Release.plist'
# To enable support for Android 12, set the following parameter to true. Defaults to false.
#android12: true
android12: true