mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 23:34:24 +01:00
new: support pick ssh term theme
This commit is contained in:
142
lib/data/model/ssh/terminal_color.dart
Normal file
142
lib/data/model/ssh/terminal_color.dart
Normal file
@@ -0,0 +1,142 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/data/res/terminal_color.dart';
|
||||
import 'package:xterm/ui.dart';
|
||||
|
||||
class TerminalUITheme {
|
||||
final Color cursor;
|
||||
final Color selection;
|
||||
final Color foreground;
|
||||
final Color background;
|
||||
final Color searchHitBackground;
|
||||
final Color searchHitBackgroundCurrent;
|
||||
final Color searchHitForeground;
|
||||
|
||||
const TerminalUITheme({
|
||||
required this.cursor,
|
||||
required this.selection,
|
||||
required this.foreground,
|
||||
required this.background,
|
||||
required this.searchHitBackground,
|
||||
required this.searchHitBackgroundCurrent,
|
||||
required this.searchHitForeground,
|
||||
});
|
||||
|
||||
TerminalTheme toTerminalTheme(TerminalColors termColor) {
|
||||
return TerminalTheme(
|
||||
cursor: cursor,
|
||||
selection: selection,
|
||||
foreground: foreground,
|
||||
background: background,
|
||||
black: termColor.black,
|
||||
red: termColor.red,
|
||||
green: termColor.green,
|
||||
yellow: termColor.yellow,
|
||||
blue: termColor.blue,
|
||||
magenta: termColor.magenta,
|
||||
cyan: termColor.cyan,
|
||||
white: termColor.white,
|
||||
brightBlack: termColor.brightBlack,
|
||||
brightRed: termColor.brightRed,
|
||||
brightGreen: termColor.brightGreen,
|
||||
brightYellow: termColor.brightYellow,
|
||||
brightBlue: termColor.brightBlue,
|
||||
brightMagenta: termColor.brightMagenta,
|
||||
brightCyan: termColor.brightCyan,
|
||||
brightWhite: termColor.brightWhite,
|
||||
searchHitBackground: searchHitBackground,
|
||||
searchHitBackgroundCurrent: searchHitBackgroundCurrent,
|
||||
searchHitForeground: searchHitForeground,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TerminalColors {
|
||||
final TerminalColorsPlatform platform;
|
||||
final Color black = Colors.black;
|
||||
final Color red;
|
||||
final Color green;
|
||||
final Color yellow;
|
||||
final Color blue;
|
||||
// 品红
|
||||
final Color magenta;
|
||||
// 青
|
||||
final Color cyan;
|
||||
final Color white;
|
||||
|
||||
/// Also called grey
|
||||
final Color brightBlack;
|
||||
final Color brightRed;
|
||||
final Color brightGreen;
|
||||
final Color brightYellow;
|
||||
final Color brightBlue;
|
||||
final Color brightMagenta;
|
||||
final Color brightCyan;
|
||||
final Color brightWhite;
|
||||
|
||||
TerminalColors(
|
||||
this.platform,
|
||||
this.red,
|
||||
this.green,
|
||||
this.yellow,
|
||||
this.blue,
|
||||
this.magenta,
|
||||
this.cyan,
|
||||
this.white,
|
||||
this.brightBlack,
|
||||
this.brightRed,
|
||||
this.brightGreen,
|
||||
this.brightYellow,
|
||||
this.brightBlue,
|
||||
this.brightMagenta,
|
||||
this.brightCyan, {
|
||||
this.brightWhite = Colors.white,
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 211;
|
||||
static const int build = 212;
|
||||
static const String engine =
|
||||
"Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision b06b8b2710 (9 days ago) • 2023-01-23 16:55:55 -0800\nEngine • revision b24591ed32\nTools • Dart 2.19.0 • DevTools 2.20.1\n";
|
||||
static const String buildAt = "2023-02-02 12:40:53.962160";
|
||||
static const int modifications = 5;
|
||||
static const String buildAt = "2023-02-02 13:16:45.445785";
|
||||
static const int modifications = 3;
|
||||
}
|
||||
|
||||
128
lib/data/res/terminal_color.dart
Normal file
128
lib/data/res/terminal_color.dart
Normal file
@@ -0,0 +1,128 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toolbox/data/model/ssh/terminal_color.dart';
|
||||
|
||||
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),
|
||||
);
|
||||
}
|
||||
@@ -1,53 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:xterm/ui.dart';
|
||||
|
||||
const termDarkTheme = TerminalTheme(
|
||||
import '../model/ssh/terminal_color.dart';
|
||||
|
||||
const termDarkTheme = TerminalUITheme(
|
||||
cursor: Color(0XAAAEAFAD),
|
||||
selection: Color(0XAAAEAFAD),
|
||||
foreground: Color(0XFFCCCCCC),
|
||||
background: Colors.black,
|
||||
black: Color(0XFF000000),
|
||||
red: Color(0XFFCD3131),
|
||||
green: Color(0XFF0DBC79),
|
||||
yellow: Color(0XFFE5E510),
|
||||
blue: Color(0XFF2472C8),
|
||||
magenta: Color(0XFFBC3FBC),
|
||||
cyan: Color(0XFF11A8CD),
|
||||
white: Color(0XFFE5E5E5),
|
||||
brightBlack: Color(0XFF666666),
|
||||
brightRed: Color(0XFFF14C4C),
|
||||
brightGreen: Color(0XFF23D18B),
|
||||
brightYellow: Color(0XFFF5F543),
|
||||
brightBlue: Color(0XFF3B8EEA),
|
||||
brightMagenta: Color(0XFFD670D6),
|
||||
brightCyan: Color(0XFF29B8DB),
|
||||
brightWhite: Color(0XFFFFFFFF),
|
||||
searchHitBackground: Color(0XFFFFFF2B),
|
||||
searchHitBackgroundCurrent: Color(0XFF31FF26),
|
||||
searchHitForeground: Color(0XFF000000),
|
||||
);
|
||||
|
||||
const termLightTheme = TerminalTheme(
|
||||
const termLightTheme = TerminalUITheme(
|
||||
cursor: Color(0XFFAEAFAD),
|
||||
selection: Color(0XFFAEAFAD),
|
||||
selection: Color.fromARGB(102, 174, 175, 173),
|
||||
foreground: Color(0XFF000000),
|
||||
background: Color(0XFFFFFFFF),
|
||||
black: Color(0XFF000000),
|
||||
red: Color(0XFFCD3131),
|
||||
green: Color(0XFF0DBC79),
|
||||
yellow: Color(0XFFE5E510),
|
||||
blue: Color(0XFF2472C8),
|
||||
magenta: Color(0XFFBC3FBC),
|
||||
cyan: Color(0XFF11A8CD),
|
||||
white: Color(0XFFE5E5E5),
|
||||
brightBlack: Color(0XFF666666),
|
||||
brightRed: Color(0XFFF14C4C),
|
||||
brightGreen: Color(0XFF23D18B),
|
||||
brightYellow: Color(0XFFF5F543),
|
||||
brightBlue: Color(0XFF3B8EEA),
|
||||
brightMagenta: Color(0XFFD670D6),
|
||||
brightCyan: Color(0XFF29B8DB),
|
||||
brightWhite: Color(0XFFFFFFFF),
|
||||
searchHitBackground: Color(0XFFFFFF2B),
|
||||
searchHitBackgroundCurrent: Color(0XFF31FF26),
|
||||
searchHitForeground: Color(0XFF000000),
|
||||
|
||||
@@ -22,4 +22,6 @@ class SettingStore extends PersistentStore {
|
||||
/// First time to use SSH term
|
||||
StoreProperty<bool> get firstTimeUseSshTerm =>
|
||||
property('firstTimeUseSshTerm', defaultValue: true);
|
||||
|
||||
StoreProperty<int> get termColorIdx => property('termColorIdx', defaultValue: 0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user