mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
opt.
- `TerminalColors` - ssh virtual key auto switch
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:xterm/ui.dart';
|
||||
import '../../res/terminal.dart';
|
||||
import 'package:xterm/ui.dart' hide TerminalColors;
|
||||
|
||||
class TerminalUITheme {
|
||||
final Color cursor;
|
||||
@@ -50,16 +49,13 @@ class TerminalUITheme {
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TerminalColors {
|
||||
final TerminalColorsPlatform platform;
|
||||
final Color black = Colors.black;
|
||||
class TerminalColors {
|
||||
final Color black;
|
||||
final Color red;
|
||||
final Color green;
|
||||
final Color yellow;
|
||||
final Color blue;
|
||||
// 品红
|
||||
final Color magenta;
|
||||
// 青
|
||||
final Color cyan;
|
||||
final Color white;
|
||||
|
||||
@@ -73,8 +69,7 @@ abstract class TerminalColors {
|
||||
final Color brightCyan;
|
||||
final Color brightWhite;
|
||||
|
||||
TerminalColors(
|
||||
this.platform,
|
||||
const TerminalColors(
|
||||
this.red,
|
||||
this.green,
|
||||
this.yellow,
|
||||
@@ -89,54 +84,7 @@ abstract class TerminalColors {
|
||||
this.brightBlue,
|
||||
this.brightMagenta,
|
||||
this.brightCyan, {
|
||||
this.brightWhite = Colors.white,
|
||||
this.black = const Color(0x00000000),
|
||||
this.brightWhite = const Color(0xFFFFFFFF),
|
||||
});
|
||||
}
|
||||
|
||||
enum TerminalColorsPlatform {
|
||||
macOS,
|
||||
vga,
|
||||
cmd,
|
||||
putty,
|
||||
xterm,
|
||||
ubuntu,
|
||||
;
|
||||
|
||||
String get name {
|
||||
switch (this) {
|
||||
case TerminalColorsPlatform.vga:
|
||||
return 'VGA';
|
||||
case TerminalColorsPlatform.cmd:
|
||||
return 'CMD';
|
||||
case TerminalColorsPlatform.macOS:
|
||||
return 'macOS';
|
||||
case TerminalColorsPlatform.putty:
|
||||
return 'PuTTY';
|
||||
case TerminalColorsPlatform.xterm:
|
||||
return 'XTerm';
|
||||
case TerminalColorsPlatform.ubuntu:
|
||||
return 'Ubuntu';
|
||||
default:
|
||||
return 'Unknown';
|
||||
}
|
||||
}
|
||||
|
||||
TerminalColors get colors {
|
||||
switch (this) {
|
||||
case TerminalColorsPlatform.vga:
|
||||
return VGATerminalColor();
|
||||
case TerminalColorsPlatform.cmd:
|
||||
return CMDTerminalColor();
|
||||
case TerminalColorsPlatform.macOS:
|
||||
return MacOSTerminalColor();
|
||||
case TerminalColorsPlatform.putty:
|
||||
return PuttyTerminalColor();
|
||||
case TerminalColorsPlatform.xterm:
|
||||
return XTermTerminalColor();
|
||||
case TerminalColorsPlatform.ubuntu:
|
||||
return UbuntuTerminalColor();
|
||||
default:
|
||||
return MacOSTerminalColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:toolbox/data/store/setting.dart';
|
||||
import 'package:toolbox/locator.dart';
|
||||
import 'package:xterm/core.dart';
|
||||
|
||||
class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier {
|
||||
@@ -7,6 +9,8 @@ class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier {
|
||||
bool ctrl = false;
|
||||
bool alt = false;
|
||||
|
||||
final _setting = locator<SettingStore>();
|
||||
|
||||
void reset(TerminalKeyboardEvent e) {
|
||||
if (e.ctrl) {
|
||||
ctrl = false;
|
||||
@@ -23,7 +27,9 @@ class VirtualKeyboard extends TerminalInputHandler with ChangeNotifier {
|
||||
ctrl: event.ctrl || ctrl,
|
||||
alt: event.alt || alt,
|
||||
);
|
||||
reset(e);
|
||||
if (_setting.sshVirtualKeyAutoOff.fetch()!) {
|
||||
reset(e);
|
||||
}
|
||||
return defaultInputHandler.call(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 321;
|
||||
static const String engine = "3.10.2";
|
||||
static const String buildAt = "2023-05-26 20:09:33.821996";
|
||||
static const int modifications = 2;
|
||||
static const int build = 328;
|
||||
static const String engine = "3.10.0";
|
||||
static const String buildAt = "2023-05-27 19:03:35.177457";
|
||||
static const int modifications = 3;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/data/model/ssh/terminal_color.dart';
|
||||
|
||||
const termDarkTheme = TerminalUITheme(
|
||||
cursor: Color(0XAAAEAFAD),
|
||||
selection: Color(0XAAAEAFAD),
|
||||
cursor: Color.fromARGB(137, 174, 175, 173),
|
||||
selection: Color.fromARGB(147, 174, 175, 173),
|
||||
foreground: Color(0XFFCCCCCC),
|
||||
background: Colors.black,
|
||||
searchHitBackground: Color(0XFFFFFF2B),
|
||||
@@ -12,7 +12,7 @@ const termDarkTheme = TerminalUITheme(
|
||||
);
|
||||
|
||||
const termLightTheme = TerminalUITheme(
|
||||
cursor: Color(0XFFAEAFAD),
|
||||
cursor: Color.fromARGB(153, 174, 175, 173),
|
||||
selection: Color.fromARGB(102, 174, 175, 173),
|
||||
foreground: Color(0XFF000000),
|
||||
background: Color(0XFFFFFFFF),
|
||||
@@ -21,128 +21,23 @@ const termLightTheme = TerminalUITheme(
|
||||
searchHitForeground: Color(0XFF000000),
|
||||
);
|
||||
|
||||
class VGATerminalColor extends TerminalColors {
|
||||
VGATerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.vga,
|
||||
const Color.fromARGB(255, 170, 0, 0),
|
||||
const Color.fromARGB(255, 0, 170, 0),
|
||||
const Color.fromARGB(255, 170, 85, 0),
|
||||
const Color.fromARGB(255, 0, 0, 170),
|
||||
const Color.fromARGB(255, 170, 0, 170),
|
||||
const Color.fromARGB(255, 0, 170, 170),
|
||||
const Color.fromARGB(255, 170, 170, 170),
|
||||
const Color.fromARGB(255, 85, 85, 85),
|
||||
const Color.fromARGB(255, 255, 85, 85),
|
||||
const Color.fromARGB(255, 85, 255, 85),
|
||||
const Color.fromARGB(255, 255, 255, 85),
|
||||
const Color.fromARGB(255, 85, 85, 255),
|
||||
const Color.fromARGB(255, 255, 85, 255),
|
||||
const Color.fromARGB(255, 85, 255, 255),
|
||||
);
|
||||
}
|
||||
|
||||
class CMDTerminalColor extends TerminalColors {
|
||||
CMDTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.cmd,
|
||||
const Color.fromARGB(255, 128, 0, 0),
|
||||
const Color.fromARGB(255, 0, 128, 0),
|
||||
const Color.fromARGB(255, 128, 128, 0),
|
||||
const Color.fromARGB(255, 0, 0, 128),
|
||||
const Color.fromARGB(255, 128, 0, 128),
|
||||
const Color.fromARGB(255, 0, 128, 128),
|
||||
const Color.fromARGB(255, 192, 192, 192),
|
||||
const Color.fromARGB(255, 128, 128, 128),
|
||||
const Color.fromARGB(255, 255, 0, 0),
|
||||
const Color.fromARGB(255, 0, 255, 0),
|
||||
const Color.fromARGB(255, 255, 255, 0),
|
||||
const Color.fromARGB(255, 0, 0, 255),
|
||||
const Color.fromARGB(255, 255, 0, 255),
|
||||
const Color.fromARGB(255, 0, 255, 255),
|
||||
);
|
||||
}
|
||||
|
||||
class MacOSTerminalColor extends TerminalColors {
|
||||
MacOSTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.macOS,
|
||||
const Color.fromARGB(255, 194, 54, 33),
|
||||
const Color.fromARGB(255, 37, 188, 36),
|
||||
const Color.fromARGB(255, 173, 173, 39),
|
||||
const Color.fromARGB(255, 73, 46, 225),
|
||||
const Color.fromARGB(255, 211, 56, 211),
|
||||
const Color.fromARGB(255, 51, 187, 200),
|
||||
const Color.fromARGB(255, 203, 204, 205),
|
||||
const Color.fromARGB(255, 129, 131, 131),
|
||||
const Color.fromARGB(255, 252, 57, 31),
|
||||
const Color.fromARGB(255, 49, 231, 34),
|
||||
const Color.fromARGB(255, 234, 236, 35),
|
||||
const Color.fromARGB(255, 88, 51, 255),
|
||||
const Color.fromARGB(255, 249, 53, 248),
|
||||
const Color.fromARGB(255, 20, 240, 240),
|
||||
brightWhite: const Color.fromARGB(255, 233, 235, 235));
|
||||
}
|
||||
|
||||
class PuttyTerminalColor extends TerminalColors {
|
||||
PuttyTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.putty,
|
||||
const Color.fromARGB(255, 187, 0, 0),
|
||||
const Color.fromARGB(255, 0, 187, 0),
|
||||
const Color.fromARGB(255, 187, 187, 0),
|
||||
const Color.fromARGB(255, 0, 0, 187),
|
||||
const Color.fromARGB(255, 187, 0, 187),
|
||||
const Color.fromARGB(255, 0, 187, 187),
|
||||
const Color.fromARGB(255, 187, 187, 187),
|
||||
const Color.fromARGB(255, 85, 85, 85),
|
||||
const Color.fromARGB(255, 255, 85, 85),
|
||||
const Color.fromARGB(255, 85, 255, 85),
|
||||
const Color.fromARGB(255, 255, 255, 85),
|
||||
const Color.fromARGB(255, 85, 85, 255),
|
||||
const Color.fromARGB(255, 255, 85, 255),
|
||||
const Color.fromARGB(255, 85, 255, 255),
|
||||
);
|
||||
}
|
||||
|
||||
class XTermTerminalColor extends TerminalColors {
|
||||
XTermTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.xterm,
|
||||
const Color.fromARGB(255, 205, 0, 0),
|
||||
const Color.fromARGB(255, 0, 205, 0),
|
||||
const Color.fromARGB(255, 205, 205, 0),
|
||||
const Color.fromARGB(255, 0, 0, 238),
|
||||
const Color.fromARGB(255, 205, 0, 205),
|
||||
const Color.fromARGB(255, 0, 205, 205),
|
||||
const Color.fromARGB(255, 229, 229, 229),
|
||||
const Color.fromARGB(255, 127, 127, 127),
|
||||
const Color.fromARGB(255, 255, 0, 0),
|
||||
const Color.fromARGB(255, 0, 255, 0),
|
||||
const Color.fromARGB(255, 255, 255, 0),
|
||||
const Color.fromARGB(255, 92, 92, 255),
|
||||
const Color.fromARGB(255, 255, 0, 255),
|
||||
const Color.fromARGB(255, 0, 255, 255),
|
||||
);
|
||||
}
|
||||
|
||||
class UbuntuTerminalColor extends TerminalColors {
|
||||
UbuntuTerminalColor()
|
||||
: super(
|
||||
TerminalColorsPlatform.ubuntu,
|
||||
const Color.fromARGB(255, 222, 56, 43),
|
||||
const Color.fromARGB(255, 57, 181, 74),
|
||||
const Color.fromARGB(255, 255, 199, 6),
|
||||
const Color.fromARGB(255, 0, 111, 184),
|
||||
const Color.fromARGB(255, 118, 38, 113),
|
||||
const Color.fromARGB(255, 44, 181, 233),
|
||||
const Color.fromARGB(255, 204, 204, 204),
|
||||
const Color.fromARGB(255, 128, 128, 128),
|
||||
const Color.fromARGB(255, 255, 0, 0),
|
||||
const Color.fromARGB(255, 0, 255, 0),
|
||||
const Color.fromARGB(255, 255, 255, 0),
|
||||
const Color.fromARGB(255, 0, 0, 255),
|
||||
const Color.fromARGB(255, 255, 0, 255),
|
||||
const Color.fromARGB(255, 0, 255, 255),
|
||||
const Color.fromARGB(255, 194, 54, 33),
|
||||
const Color.fromARGB(255, 37, 188, 36),
|
||||
const Color.fromARGB(255, 173, 173, 39),
|
||||
const Color.fromARGB(255, 73, 46, 225),
|
||||
const Color.fromARGB(255, 211, 56, 211),
|
||||
const Color.fromARGB(255, 51, 187, 200),
|
||||
const Color.fromARGB(255, 203, 204, 205),
|
||||
const Color.fromARGB(255, 129, 131, 131),
|
||||
const Color.fromARGB(255, 252, 57, 31),
|
||||
const Color.fromARGB(255, 49, 231, 34),
|
||||
const Color.fromARGB(255, 234, 236, 35),
|
||||
const Color.fromARGB(255, 88, 51, 255),
|
||||
const Color.fromARGB(255, 249, 53, 248),
|
||||
const Color.fromARGB(255, 20, 240, 240),
|
||||
brightWhite: const Color.fromARGB(255, 233, 235, 235),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,50 +12,50 @@ class SettingStore extends PersistentStore {
|
||||
StoreProperty<int> get serverStatusUpdateInterval =>
|
||||
property('serverStatusUpdateInterval', defaultValue: 3);
|
||||
|
||||
/// Lanch page idx
|
||||
// Lanch page idx
|
||||
StoreProperty<int> get launchPage => property('launchPage', defaultValue: 0);
|
||||
|
||||
/// Version of store db
|
||||
// Version of store db
|
||||
StoreProperty<int> get storeVersion =>
|
||||
property('storeVersion', defaultValue: 0);
|
||||
|
||||
/// Show logo on server detail page
|
||||
// Show logo on server detail page
|
||||
StoreProperty<bool> get showDistLogo =>
|
||||
property('showDistLogo', defaultValue: true);
|
||||
|
||||
/// First time to use SSH term
|
||||
// First time to use SSH term
|
||||
StoreProperty<bool> get firstTimeUseSshTerm =>
|
||||
property('firstTimeUseSshTerm', defaultValue: true);
|
||||
|
||||
StoreProperty<int> get termColorIdx =>
|
||||
property('termColorIdx', defaultValue: 0);
|
||||
|
||||
/// Max retry count when connect to server
|
||||
// Max retry count when connect to server
|
||||
StoreProperty<int> get maxRetryCount =>
|
||||
property('maxRetryCount', defaultValue: 2);
|
||||
|
||||
/// Night mode: 0 -> auto, 1 -> light, 2 -> dark
|
||||
// Night mode: 0 -> auto, 1 -> light, 2 -> dark
|
||||
StoreProperty<int> get themeMode => property('themeMode', defaultValue: 0);
|
||||
|
||||
/// Font file path
|
||||
// Font file path
|
||||
StoreProperty<String> get fontPath => property('fontPath');
|
||||
|
||||
/// Backgroud running (Android)
|
||||
// Backgroud running (Android)
|
||||
StoreProperty<bool> get bgRun => property('bgRun', defaultValue: isAndroid);
|
||||
|
||||
/// Server order
|
||||
// Server order
|
||||
StoreProperty<List<String>> get serverOrder =>
|
||||
property('serverOrder', defaultValue: null);
|
||||
|
||||
/// Server details page cards order
|
||||
// Server details page cards order
|
||||
StoreProperty<List<String>> get detailCardOrder =>
|
||||
property('detailCardPrder', defaultValue: defaultDetailCardOrder);
|
||||
|
||||
/// SSH term font size
|
||||
// SSH term font size
|
||||
StoreProperty<double> get termFontSize =>
|
||||
property('termFontSize', defaultValue: 13);
|
||||
|
||||
/// Server detail disk ignore path
|
||||
// Server detail disk ignore path
|
||||
StoreProperty<List<String>> get diskIgnorePath =>
|
||||
property('diskIgnorePath', defaultValue: [
|
||||
'udev',
|
||||
@@ -66,6 +66,10 @@ class SettingStore extends PersistentStore {
|
||||
'none',
|
||||
]);
|
||||
|
||||
/// Locale
|
||||
// Locale
|
||||
StoreProperty<String> get locale => property('locale', defaultValue: null);
|
||||
|
||||
// SSH virtual key (ctrl | alt) auto turn off
|
||||
StoreProperty<bool> get sshVirtualKeyAutoOff =>
|
||||
property('sshVirtualKeyAutoOff', defaultValue: true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user