mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-23 16:45:27 +01:00
#135 opt.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 471;
|
||||
static const int build = 472;
|
||||
static const String engine = "3.10.6";
|
||||
static const String buildAt = "2023-08-13 22:48:32.724672";
|
||||
static const int modifications = 6;
|
||||
static const String buildAt = "2023-08-14 11:11:21.335805";
|
||||
static const int modifications = 2;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,6 @@ const seperator = 'SrvBoxSep';
|
||||
const serverBoxDir = r'$HOME/.config/server_box';
|
||||
const shellPath = '$serverBoxDir/mobile_app.sh';
|
||||
|
||||
const echoPWD = 'echo \$PWD';
|
||||
|
||||
const statusCmds = [
|
||||
'cat /proc/net/dev && date +%s',
|
||||
'cat /etc/os-release | grep PRETTY_NAME',
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/extension/navigator.dart';
|
||||
import 'package:toolbox/data/res/server_cmd.dart';
|
||||
import 'package:xterm/xterm.dart';
|
||||
|
||||
import '../../../core/route.dart';
|
||||
@@ -25,6 +24,8 @@ import '../../../data/store/setting.dart';
|
||||
import '../../../locator.dart';
|
||||
import '../storage/sftp.dart';
|
||||
|
||||
const echoPWD = 'echo \$PWD';
|
||||
|
||||
class SSHPage extends StatefulWidget {
|
||||
final ServerPrivateInfo spi;
|
||||
final String? initCmd;
|
||||
@@ -39,6 +40,7 @@ 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;
|
||||
@@ -97,7 +99,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
Widget child = Scaffold(
|
||||
backgroundColor: _terminalTheme.background,
|
||||
body: _buildBody(),
|
||||
bottomNavigationBar: _buildBottom(),
|
||||
bottomNavigationBar: isDesktop ? null : _buildBottom(),
|
||||
);
|
||||
if (isIOS) {
|
||||
child = AnnotatedRegion(
|
||||
@@ -116,6 +118,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
_media.padding.top,
|
||||
child: TerminalView(
|
||||
_terminal,
|
||||
onTapUp: _onTapUp,
|
||||
controller: _terminalController,
|
||||
keyboardType: _keyboardType,
|
||||
textStyle: _terminalStyle,
|
||||
@@ -362,4 +365,49 @@ class _SSHPageState extends State<SSHPage> {
|
||||
.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,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user