readd: paste in ssh

This commit is contained in:
lollipopkit
2023-04-17 12:55:47 +08:00
parent bf22309fe5
commit 9e503e4901
6 changed files with 60 additions and 57 deletions

View File

@@ -2,9 +2,8 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 256;
static const String engine =
"Flutter 3.7.7 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 2ad6cd72c0 (4 weeks ago) • 2023-03-08 09:41:59 -0800\nEngine • revision 1837b5be5f\nTools • Dart 2.19.4 • DevTools 2.20.1\n";
static const String buildAt = "2023-04-05 15:16:00.949501";
static const int modifications = 2;
static const int build = 260;
static const String engine = "Flutter 3.7.7 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 2ad6cd72c0 (6 weeks ago) • 2023-03-08 09:41:59 -0800\nEngine • revision 1837b5be5f\nTools • Dart 2.19.4 • DevTools 2.20.1\n";
static const String buildAt = "2023-04-16 22:22:23.410508";
static const int modifications = 3;
}

View File

@@ -9,17 +9,18 @@ var virtualKeys = [
VirtualKey('Home', key: TerminalKey.home),
VirtualKey('Up', key: TerminalKey.arrowUp, icon: Icons.arrow_upward),
VirtualKey('End', key: TerminalKey.end),
// VirtualKey(
// 'Del',
// key: TerminalKey.delete,
// ),
//VirtualKey('Paste', func: VirtualKeyFunc.paste, icon: Icons.paste),
VirtualKey(
'Del',
key: TerminalKey.delete,
icon: Icons.backspace,
),
VirtualKey('Snippet', func: VirtualKeyFunc.snippet, icon: Icons.code),
VirtualKey('Tab', key: TerminalKey.tab),
VirtualKey('Ctrl', key: TerminalKey.control, toggleable: true),
VirtualKey('Left', key: TerminalKey.arrowLeft, icon: Icons.arrow_back),
VirtualKey('Down', key: TerminalKey.arrowDown, icon: Icons.arrow_downward),
VirtualKey('Right', key: TerminalKey.arrowRight, icon: Icons.arrow_forward),
VirtualKey('Paste', func: VirtualKeyFunc.paste, icon: Icons.paste),
VirtualKey(
'IME',
func: VirtualKeyFunc.toggleIME,

View File

@@ -42,6 +42,9 @@ class _SSHPageState extends State<SSHPage> {
late TextStyle _menuTextStyle;
late TerminalColors _termColors;
late S _s;
late TerminalStyle _terminalStyle;
late TerminalUITheme _termUITheme;
late TerminalTheme _terminalTheme;
var _isDark = false;
@@ -50,6 +53,8 @@ class _SSHPageState extends State<SSHPage> {
super.initState();
final termColorIdx = _setting.termColorIdx.fetch()!;
_termColors = TerminalColorsPlatform.values[termColorIdx].colors;
final ts = TextStyle(fontFamily: getFileName(_setting.fontPath.fetch()));
_terminalStyle = TerminalStyle.fromTextStyle(ts);
initTerminal();
}
@@ -60,6 +65,8 @@ class _SSHPageState extends State<SSHPage> {
_media = MediaQuery.of(context);
_menuTextStyle = TextStyle(color: contentColor.resolve(context));
_s = S.of(context)!;
_termUITheme = _isDark ? termDarkTheme : termLightTheme;
_terminalTheme = _termUITheme.toTerminalTheme(_termColors);
}
@override
@@ -125,11 +132,10 @@ class _SSHPageState extends State<SSHPage> {
@override
Widget build(BuildContext context) {
final termTheme = _isDark ? termDarkTheme : termLightTheme;
Widget child = Scaffold(
backgroundColor: termTheme.background,
body: _buildBody(termTheme.toTerminalTheme(_termColors)),
bottomNavigationBar: _buildBottom(termTheme.background),
backgroundColor: _termUITheme.background,
body: _buildBody(),
bottomNavigationBar: _buildBottom(),
);
if (isIOS) {
child = AnnotatedRegion(
@@ -140,7 +146,7 @@ class _SSHPageState extends State<SSHPage> {
return child;
}
Widget _buildBody(TerminalTheme termTheme) {
Widget _buildBody() {
return SizedBox(
height: _media.size.height -
_virtualKeyboardHeight -
@@ -150,9 +156,8 @@ class _SSHPageState extends State<SSHPage> {
_terminal,
controller: _terminalController,
keyboardType: TextInputType.visiblePassword,
textStyle: TerminalStyle.fromTextStyle(
TextStyle(fontFamily: getFileName(_setting.fontPath.fetch()))),
theme: termTheme,
textStyle: _terminalStyle,
theme: _terminalTheme,
deleteDetection: isIOS,
onTapUp: _onTapUp,
autoFocus: true,
@@ -161,14 +166,14 @@ class _SSHPageState extends State<SSHPage> {
);
}
Widget _buildBottom(Color bgColor) {
Widget _buildBottom() {
return SafeArea(
child: AnimatedPadding(
padding: _media.viewInsets,
duration: const Duration(milliseconds: 23),
curve: Curves.fastOutSlowIn,
child: Container(
color: bgColor,
color: _termUITheme.background,
height: _virtualKeyboardHeight,
child: Consumer<VirtualKeyboard>(
builder: (_, __, ___) => _buildVirtualKey(),
@@ -218,7 +223,7 @@ class _SSHPageState extends State<SSHPage> {
item.text,
style: TextStyle(
color: selected ? primaryColor : null,
fontSize: 17,
fontSize: 15,
),
);
@@ -306,27 +311,27 @@ class _SSHPageState extends State<SSHPage> {
}
final selected = terminalSelected;
if (selected.trim().isEmpty) {
_menuController.show(
context: context,
contextMenuBuilder: (context) {
return TextSelectionToolbar(
anchorAbove: details.globalPosition,
anchorBelow: details.globalPosition,
children: [
TextButton(
child: Text(
_s.paste,
style: _menuTextStyle,
),
onPressed: () async {
_paste();
_menuController.remove();
},
)
],
);
},
);
// _menuController.show(
// context: context,
// contextMenuBuilder: (context) {
// return TextSelectionToolbar(
// anchorAbove: details.globalPosition,
// anchorBelow: details.globalPosition,
// children: [
// TextButton(
// child: Text(
// _s.paste,
// style: _menuTextStyle,
// ),
// onPressed: () async {
// _paste();
// _menuController.remove();
// },
// )
// ],
// );
// },
// );
return;
}
_menuController.show(