Просмотр исходного кода

➕ theme customization support

xuty 5 лет назад
Родитель
Сommit
e042f1f219

+ 7 - 8
lib/buffer/cell_attr.dart

@@ -1,5 +1,4 @@
-import 'package:meta/meta.dart';
-import 'package:xterm/buffer/cell_color.dart';
+import 'package:xterm/theme/terminal_color.dart';
 import 'package:xterm/utli/hash_values.dart';
 
 class CellAttr {
@@ -25,8 +24,8 @@ class CellAttr {
           invisible,
         );
 
-  final CellColor fgColor;
-  final CellColor bgColor;
+  final TerminalColor fgColor;
+  final TerminalColor bgColor;
   final bool bold;
   final bool faint;
   final bool italic;
@@ -78,8 +77,8 @@ class CellAttr {
   // }
 
   CellAttr copyWith({
-    CellColor fgColor,
-    CellColor bgColor,
+    TerminalColor fgColor,
+    TerminalColor bgColor,
     bool bold,
     bool faint,
     bool italic,
@@ -109,11 +108,11 @@ class CellAttrTemplate {
 
   CellAttr _attr;
 
-  set fgColor(CellColor value) {
+  set fgColor(TerminalColor value) {
     _attr = _attr.copyWith(fgColor: value);
   }
 
-  set bgColor(CellColor value) {
+  set bgColor(TerminalColor value) {
     _attr = _attr.copyWith(bgColor: value);
   }
 

+ 0 - 24
lib/color/color_default.dart

@@ -1,24 +0,0 @@
-import 'package:xterm/buffer/cell_color.dart';
-import 'package:xterm/color/color_scheme.dart';
-
-final defaultColorScheme = TerminalColourScheme(
-  cursor: CellColor(0xffaeafad),
-  selection: CellColor(0xffffff40),
-  foreground: CellColor(0xffcccccc),
-  background: CellColor(0xff1e1e1e),
-  black: CellColor(0xff000000),
-  white: CellColor(0xffe5e5e5),
-  red: CellColor(0xffcd3131),
-  green: CellColor(0xff0dbc79),
-  yellow: CellColor(0xffe5e510),
-  blue: CellColor(0xff2472c8),
-  magenta: CellColor(0xffbc3fbc),
-  cyan: CellColor(0xff11a8cd),
-  brightBlack: CellColor(0xff666666),
-  brightRed: CellColor(0xfff14c4c),
-  brightGreen: CellColor(0xff23d18b),
-  brightYellow: CellColor(0xfff5f543),
-  brightBlue: CellColor(0xff3b8eea),
-  brightMagenta: CellColor(0xffd670d6),
-  brightCyan: CellColor(0xff29b8db),
-);

+ 0 - 48
lib/color/color_scheme.dart

@@ -1,48 +0,0 @@
-import 'package:meta/meta.dart';
-import 'package:xterm/buffer/cell_color.dart';
-
-class TerminalColourScheme {
-  TerminalColourScheme({
-    @required this.cursor,
-    @required this.selection,
-    @required this.foreground,
-    @required this.background,
-    @required this.black,
-    @required this.white,
-    @required this.red,
-    @required this.green,
-    @required this.yellow,
-    @required this.blue,
-    @required this.magenta,
-    @required this.cyan,
-    @required this.brightBlack,
-    @required this.brightRed,
-    @required this.brightGreen,
-    @required this.brightYellow,
-    @required this.brightBlue,
-    @required this.brightMagenta,
-    @required this.brightCyan,
-  });
-
-  CellColor cursor;
-  CellColor selection;
-
-  CellColor foreground;
-  CellColor background;
-  CellColor black;
-  CellColor red;
-  CellColor green;
-  CellColor yellow;
-  CellColor blue;
-  CellColor magenta;
-  CellColor cyan;
-
-  CellColor brightBlack;
-  CellColor brightRed;
-  CellColor brightGreen;
-  CellColor brightYellow;
-  CellColor brightBlue;
-  CellColor brightMagenta;
-  CellColor brightCyan;
-  CellColor white;
-}

+ 21 - 49
lib/frontend/terminal_view.dart

@@ -17,42 +17,17 @@ import 'package:xterm/frontend/oscillator.dart';
 import 'package:xterm/frontend/cache.dart';
 import 'package:xterm/mouse/position.dart';
 import 'package:xterm/terminal/terminal.dart';
+import 'package:xterm/theme/terminal_style.dart';
 import 'package:xterm/utli/hash_values.dart';
 
 typedef ResizeHandler = void Function(int width, int height);
 
-const _kDefaultFontFamily = [
-  'Droid Sans Mono',
-  'Noto Sans Mono',
-  'Roboto Mono',
-  'Consolas',
-  'Noto Sans Mono CJK SC',
-  'Noto Sans Mono CJK TC',
-  'Noto Sans Mono CJK KR',
-  'Noto Sans Mono CJK JP',
-  'Noto Sans Mono CJK HK',
-  'monospace',
-  'Noto Color Emoji',
-  'Noto Sans Symbols',
-  'Roboto',
-  'Ubuntu',
-  'Cantarell',
-  'DejaVu Sans',
-  'Liberation Sans',
-  'Arial',
-  'Droid Sans Fallback',
-  'sans-serif',
-];
-
 class TerminalView extends StatefulWidget {
   TerminalView({
     Key key,
     @required this.terminal,
     this.onResize,
-    this.fontSize = 16,
-    this.fontFamily = _kDefaultFontFamily,
-    this.fontWidthScaleFactor = 1.0,
-    this.fontHeightScaleFactor = 1.1,
+    this.style = const TerminalStyle(),
     FocusNode focusNode,
     ScrollController scrollController,
     InputBehavior inputBehavior,
@@ -67,10 +42,7 @@ class TerminalView extends StatefulWidget {
   final FocusNode focusNode;
   final ScrollController scrollController;
 
-  final double fontSize;
-  final double fontWidthScaleFactor;
-  final double fontHeightScaleFactor;
-  final List<String> fontFamily;
+  final TerminalStyle style;
 
   final InputBehavior inputBehavior;
 
@@ -80,8 +52,8 @@ class TerminalView extends StatefulWidget {
     final text = Text(
       testString,
       style: TextStyle(
-        fontFamilyFallback: _kDefaultFontFamily,
-        fontSize: fontSize,
+        fontFamilyFallback: style.fontFamily,
+        fontSize: style.fontSize,
       ),
     );
 
@@ -90,8 +62,8 @@ class TerminalView extends StatefulWidget {
     final charWidth = (size.width / testString.length);
     final charHeight = size.height;
 
-    final cellWidth = charWidth * fontWidthScaleFactor;
-    final cellHeight = size.height * fontHeightScaleFactor;
+    final cellWidth = charWidth * style.fontWidthScaleFactor;
+    final cellHeight = size.height * style.fontHeightScaleFactor;
 
     return CellSize(
       charWidth: charWidth,
@@ -238,7 +210,7 @@ class _TerminalViewState extends State<TerminalView> {
       },
       child: Container(
         constraints: BoxConstraints.expand(),
-        color: Color(widget.terminal.colorScheme.background.value),
+        color: Color(widget.terminal.theme.background.value),
         child: CustomPaint(
           painter: TerminalPainter(
             terminal: widget.terminal,
@@ -466,12 +438,12 @@ class TerminalPainter extends CustomPainter {
         // color: color,
         // fontWeight: cell.attr.bold ? FontWeight.bold : FontWeight.normal,
         // fontStyle: cell.attr.italic ? FontStyle.italic : FontStyle.normal,
-        fontSize: view.fontSize,
+        fontSize: view.style.fontSize,
         letterSpacing: charSize.letterSpacing,
         fontFeatures: [FontFeature.tabularFigures()],
         // decoration:
         //     cell.attr.underline ? TextDecoration.underline : TextDecoration.none,
-        fontFamilyFallback: _kDefaultFontFamily,
+        fontFamilyFallback: view.style.fontFamily,
       );
 
       final span = TextSpan(
@@ -491,8 +463,8 @@ class TerminalPainter extends CustomPainter {
     }
 
     final cellColor = cell.attr.inverse
-        ? cell.attr.bgColor ?? terminal.colorScheme.background
-        : cell.attr.fgColor ?? terminal.colorScheme.foreground;
+        ? cell.attr.bgColor ?? terminal.theme.background
+        : cell.attr.fgColor ?? terminal.theme.foreground;
 
     var color = Color(cellColor.value);
 
@@ -501,14 +473,14 @@ class TerminalPainter extends CustomPainter {
     }
 
     final style = TextStyle(
-      color: color,
-      fontWeight: cell.attr.bold ? FontWeight.bold : FontWeight.normal,
-      fontStyle: cell.attr.italic ? FontStyle.italic : FontStyle.normal,
-      fontSize: view.fontSize,
-      decoration:
-          cell.attr.underline ? TextDecoration.underline : TextDecoration.none,
-      fontFamilyFallback: _kDefaultFontFamily,
-    );
+        color: color,
+        fontWeight: cell.attr.bold ? FontWeight.bold : FontWeight.normal,
+        fontStyle: cell.attr.italic ? FontStyle.italic : FontStyle.normal,
+        fontSize: view.style.fontSize,
+        decoration: cell.attr.underline
+            ? TextDecoration.underline
+            : TextDecoration.none,
+        fontFamilyFallback: view.style.fontFamily);
 
     final span = TextSpan(
       text: String.fromCharCode(cell.codePoint),
@@ -536,7 +508,7 @@ class TerminalPainter extends CustomPainter {
     final offsetX = charSize.cellWidth * terminal.cursorX;
     final offsetY = charSize.cellHeight * screenCursorY;
     final paint = Paint()
-      ..color = Color(terminal.colorScheme.cursor.value)
+      ..color = Color(terminal.theme.cursor.value)
       ..strokeWidth = focused ? 0.0 : 1.0
       ..style = focused ? PaintingStyle.fill : PaintingStyle.stroke;
     canvas.drawRect(

+ 72 - 62
lib/terminal/sgr.dart

@@ -1,6 +1,16 @@
-import 'package:xterm/buffer/cell_color.dart';
+import 'package:xterm/theme/terminal_color.dart';
 import 'package:xterm/terminal/csi.dart';
 import 'package:xterm/terminal/terminal.dart';
+import 'package:xterm/theme/terminal_color_ref.dart';
+
+// reference to color
+class Cr implements TerminalColor {
+  Cr(this.getter);
+
+  final TerminalColor Function() getter;
+
+  int get value => getter().value;
+}
 
 /// SGR selects one or more character attributes at the same time.
 /// Multiple params (up to 32) are applied from in order from left to right.
@@ -75,106 +85,106 @@ void sgrHandler(CSI csi, Terminal terminal) {
         // not strikethrough
         break;
       case '39':
-        terminal.cellAttr.fgColor = terminal.colorScheme.foreground;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.foreground);
         break;
       case '30':
-        terminal.cellAttr.fgColor = terminal.colorScheme.black;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.black);
         break;
       case '31':
-        terminal.cellAttr.fgColor = terminal.colorScheme.red;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.red);
         break;
       case '32':
-        terminal.cellAttr.fgColor = terminal.colorScheme.green;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.green);
         break;
       case '33':
-        terminal.cellAttr.fgColor = terminal.colorScheme.yellow;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.yellow);
         break;
       case '34':
-        terminal.cellAttr.fgColor = terminal.colorScheme.blue;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.blue);
         break;
       case '35':
-        terminal.cellAttr.fgColor = terminal.colorScheme.magenta;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.magenta);
         break;
       case '36':
-        terminal.cellAttr.fgColor = terminal.colorScheme.cyan;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.cyan);
         break;
       case '37':
-        terminal.cellAttr.fgColor = terminal.colorScheme.white;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.white);
         break;
       case '90':
-        terminal.cellAttr.fgColor = terminal.colorScheme.brightBlack;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.brightBlack);
         break;
       case '91':
-        terminal.cellAttr.fgColor = terminal.colorScheme.brightRed;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.brightRed);
         break;
       case '92':
-        terminal.cellAttr.fgColor = terminal.colorScheme.brightGreen;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.brightGreen);
         break;
       case '93':
-        terminal.cellAttr.fgColor = terminal.colorScheme.brightYellow;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.brightYellow);
         break;
       case '94':
-        terminal.cellAttr.fgColor = terminal.colorScheme.brightBlue;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.brightBlue);
         break;
       case '95':
-        terminal.cellAttr.fgColor = terminal.colorScheme.brightMagenta;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.brightMagenta);
         break;
       case '96':
-        terminal.cellAttr.fgColor = terminal.colorScheme.brightCyan;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.brightCyan);
         break;
       case '97':
-        terminal.cellAttr.fgColor = terminal.colorScheme.white;
+        terminal.cellAttr.fgColor = Cr(() => terminal.theme.white);
         break;
       case '49':
-        terminal.cellAttr.bgColor = terminal.colorScheme.background;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.background);
         break;
       case '40':
-        terminal.cellAttr.bgColor = terminal.colorScheme.black;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.black);
         break;
       case '41':
-        terminal.cellAttr.bgColor = terminal.colorScheme.red;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.red);
         break;
       case '42':
-        terminal.cellAttr.bgColor = terminal.colorScheme.green;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.green);
         break;
       case '43':
-        terminal.cellAttr.bgColor = terminal.colorScheme.yellow;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.yellow);
         break;
       case '44':
-        terminal.cellAttr.bgColor = terminal.colorScheme.blue;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.blue);
         break;
       case '45':
-        terminal.cellAttr.bgColor = terminal.colorScheme.magenta;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.magenta);
         break;
       case '46':
-        terminal.cellAttr.bgColor = terminal.colorScheme.cyan;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.cyan);
         break;
       case '47':
-        terminal.cellAttr.bgColor = terminal.colorScheme.white;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.white);
         break;
       case '100':
-        terminal.cellAttr.bgColor = terminal.colorScheme.brightBlack;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.brightBlack);
         break;
       case '101':
-        terminal.cellAttr.bgColor = terminal.colorScheme.brightRed;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.brightRed);
         break;
       case '102':
-        terminal.cellAttr.bgColor = terminal.colorScheme.brightGreen;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.brightGreen);
         break;
       case '103':
-        terminal.cellAttr.bgColor = terminal.colorScheme.brightYellow;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.brightYellow);
         break;
       case '104':
-        terminal.cellAttr.bgColor = terminal.colorScheme.brightBlue;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.brightBlue);
         break;
       case '105':
-        terminal.cellAttr.bgColor = terminal.colorScheme.brightMagenta;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.brightMagenta);
         break;
       case '106':
-        terminal.cellAttr.bgColor = terminal.colorScheme.brightCyan;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.brightCyan);
         break;
       case '107':
-        terminal.cellAttr.bgColor = terminal.colorScheme.white;
+        terminal.cellAttr.bgColor = Cr(() => terminal.theme.white);
         break;
       case '38': // set foreground
         final color = parseAnsiColour(params.sublist(i), terminal);
@@ -190,7 +200,7 @@ void sgrHandler(CSI csi, Terminal terminal) {
   }
 }
 
-CellColor parseAnsiColour(List<String> params, Terminal terminal) {
+TerminalColor parseAnsiColour(List<String> params, Terminal terminal) {
   if (params.length > 2) {
     switch (params[1]) {
       case "5":
@@ -198,14 +208,14 @@ CellColor parseAnsiColour(List<String> params, Terminal terminal) {
         final colNum = int.tryParse(params[2]);
 
         if (colNum == null || colNum >= 256 || colNum < 0) {
-          return CellColor.empty();
+          return TerminalColor.empty();
         }
 
         return parse8BitSgrColour(colNum, terminal);
 
       case "2":
         if (params.length < 4) {
-          return CellColor.empty();
+          return TerminalColor.empty();
         }
 
         // 24 bit colour
@@ -215,10 +225,10 @@ CellColor parseAnsiColour(List<String> params, Terminal terminal) {
           final b = int.tryParse(params[4]);
 
           if (r == null || g == null || b == null) {
-            return CellColor.empty();
+            return TerminalColor.empty();
           }
 
-          return CellColor.fromARGB(0xff, r, g, b);
+          return TerminalColor.fromARGB(0xff, r, g, b);
         }
 
         if (params.length > 5) {
@@ -228,15 +238,15 @@ CellColor parseAnsiColour(List<String> params, Terminal terminal) {
           final b = int.tryParse(params[5]);
 
           if (r == null || g == null || b == null) {
-            return CellColor.empty();
+            return TerminalColor.empty();
           }
 
-          return CellColor.fromARGB(0xff, r, g, b);
+          return TerminalColor.fromARGB(0xff, r, g, b);
         }
     }
   }
 
-  return CellColor.empty();
+  return TerminalColor.empty();
 }
 
 const grayscaleColors = {
@@ -266,42 +276,42 @@ const grayscaleColors = {
   255: 0xffeeeeee,
 };
 
-CellColor parse8BitSgrColour(int colNum, Terminal terminal) {
+TerminalColor parse8BitSgrColour(int colNum, Terminal terminal) {
   // https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
 
   switch (colNum) {
     case 0:
-      return terminal.colorScheme.black;
+      return terminal.theme.black;
     case 1:
-      return terminal.colorScheme.red;
+      return terminal.theme.red;
     case 2:
-      return terminal.colorScheme.green;
+      return terminal.theme.green;
     case 3:
-      return terminal.colorScheme.yellow;
+      return terminal.theme.yellow;
     case 4:
-      return terminal.colorScheme.blue;
+      return terminal.theme.blue;
     case 5:
-      return terminal.colorScheme.magenta;
+      return terminal.theme.magenta;
     case 6:
-      return terminal.colorScheme.cyan;
+      return terminal.theme.cyan;
     case 7:
-      return terminal.colorScheme.white;
+      return terminal.theme.white;
     case 8:
-      return terminal.colorScheme.brightBlack;
+      return terminal.theme.brightBlack;
     case 9:
-      return terminal.colorScheme.brightRed;
+      return terminal.theme.brightRed;
     case 10:
-      return terminal.colorScheme.brightGreen;
+      return terminal.theme.brightGreen;
     case 11:
-      return terminal.colorScheme.brightYellow;
+      return terminal.theme.brightYellow;
     case 12:
-      return terminal.colorScheme.brightBlue;
+      return terminal.theme.brightBlue;
     case 13:
-      return terminal.colorScheme.brightMagenta;
+      return terminal.theme.brightMagenta;
     case 14:
-      return terminal.colorScheme.brightCyan;
+      return terminal.theme.brightCyan;
     case 15:
-      return terminal.colorScheme.white;
+      return terminal.theme.white;
   }
 
   if (colNum < 232) {
@@ -335,8 +345,8 @@ CellColor parse8BitSgrColour(int colNum, Terminal terminal) {
       }
     }
 
-    return CellColor.fromARGB(0xff, r, g, b);
+    return TerminalColor.fromARGB(0xff, r, g, b);
   }
 
-  return CellColor(grayscaleColors[colNum.clamp(232, 255)]);
+  return TerminalColor(grayscaleColors[colNum.clamp(232, 255)]);
 }

+ 4 - 2
lib/terminal/terminal.dart

@@ -6,7 +6,6 @@ import 'package:xterm/buffer/buffer.dart';
 import 'package:xterm/buffer/buffer_line.dart';
 import 'package:xterm/buffer/cell_attr.dart';
 import 'package:xterm/mouse/selection.dart';
-import 'package:xterm/color/color_default.dart';
 import 'package:xterm/input/keys.dart';
 import 'package:xterm/input/keytab/keytab.dart';
 import 'package:xterm/input/keytab/keytab_escape.dart';
@@ -16,6 +15,8 @@ import 'package:xterm/terminal/ansi.dart';
 import 'package:xterm/terminal/platform.dart';
 import 'package:xterm/terminal/sbc.dart';
 import 'package:xterm/terminal/tabs.dart';
+import 'package:xterm/theme/terminal_theme.dart';
+import 'package:xterm/theme/terminal_themes.dart';
 import 'package:xterm/utli/debug_handler.dart';
 import 'package:xterm/utli/observable.dart';
 
@@ -31,6 +32,7 @@ class Terminal with Observable {
     this.onTitleChange,
     this.onIconChange,
     this.platform = PlatformBehavior.unix,
+    this.theme = TerminalThemes.defaultTheme,
     int maxLines,
   }) {
     _maxLines = maxLines;
@@ -106,7 +108,7 @@ class Terminal with Observable {
   MouseMode _mouseMode = MouseMode.none;
   MouseMode get mouseMode => _mouseMode;
 
-  final colorScheme = defaultColorScheme;
+  final TerminalTheme theme;
   final cellAttr = CellAttrTemplate();
 
   final keytab = Keytab.defaultKeytab();

+ 6 - 4
lib/buffer/cell_color.dart → lib/theme/terminal_color.dart

@@ -1,7 +1,9 @@
-class CellColor {
-  const CellColor(this.value);
-  const CellColor.empty() : value = 0xFF000000;
-  const CellColor.fromARGB(int a, int r, int g, int b)
+class TerminalColor {
+  const TerminalColor(this.value);
+
+  const TerminalColor.empty() : value = 0xFF000000;
+
+  const TerminalColor.fromARGB(int a, int r, int g, int b)
       : value = (((a & 0xff) << 24) |
                 ((r & 0xff) << 16) |
                 ((g & 0xff) << 8) |

+ 9 - 0
lib/theme/terminal_color_ref.dart

@@ -0,0 +1,9 @@
+import 'package:xterm/theme/terminal_color.dart';
+
+class TerminalColorRef implements TerminalColor {
+  TerminalColorRef(this.getter);
+
+  final TerminalColor Function() getter;
+
+  int get value => getter().value;
+}

+ 36 - 0
lib/theme/terminal_style.dart

@@ -0,0 +1,36 @@
+class TerminalStyle {
+  static const defaultFontFamily = [
+    'Droid Sans Mono',
+    'Noto Sans Mono',
+    'Roboto Mono',
+    'Consolas',
+    'Noto Sans Mono CJK SC',
+    'Noto Sans Mono CJK TC',
+    'Noto Sans Mono CJK KR',
+    'Noto Sans Mono CJK JP',
+    'Noto Sans Mono CJK HK',
+    'monospace',
+    'Noto Color Emoji',
+    'Noto Sans Symbols',
+    'Roboto',
+    'Ubuntu',
+    'Cantarell',
+    'DejaVu Sans',
+    'Liberation Sans',
+    'Arial',
+    'Droid Sans Fallback',
+    'sans-serif',
+  ];
+
+  const TerminalStyle({
+    this.fontFamily = defaultFontFamily,
+    this.fontSize = 14,
+    this.fontWidthScaleFactor = 1.0,
+    this.fontHeightScaleFactor = 1.1,
+  });
+
+  final List<String> fontFamily;
+  final double fontSize;
+  final double fontWidthScaleFactor;
+  final double fontHeightScaleFactor;
+}

+ 48 - 0
lib/theme/terminal_theme.dart

@@ -0,0 +1,48 @@
+import 'package:meta/meta.dart';
+import 'package:xterm/theme/terminal_color.dart';
+
+class TerminalTheme {
+  const TerminalTheme({
+    @required this.cursor,
+    @required this.selection,
+    @required this.foreground,
+    @required this.background,
+    @required this.black,
+    @required this.white,
+    @required this.red,
+    @required this.green,
+    @required this.yellow,
+    @required this.blue,
+    @required this.magenta,
+    @required this.cyan,
+    @required this.brightBlack,
+    @required this.brightRed,
+    @required this.brightGreen,
+    @required this.brightYellow,
+    @required this.brightBlue,
+    @required this.brightMagenta,
+    @required this.brightCyan,
+  });
+
+  final TerminalColor cursor;
+  final TerminalColor selection;
+
+  final TerminalColor foreground;
+  final TerminalColor background;
+  final TerminalColor black;
+  final TerminalColor red;
+  final TerminalColor green;
+  final TerminalColor yellow;
+  final TerminalColor blue;
+  final TerminalColor magenta;
+  final TerminalColor cyan;
+
+  final TerminalColor brightBlack;
+  final TerminalColor brightRed;
+  final TerminalColor brightGreen;
+  final TerminalColor brightYellow;
+  final TerminalColor brightBlue;
+  final TerminalColor brightMagenta;
+  final TerminalColor brightCyan;
+  final TerminalColor white;
+}

+ 26 - 0
lib/theme/terminal_themes.dart

@@ -0,0 +1,26 @@
+import 'package:xterm/theme/terminal_color.dart';
+import 'package:xterm/theme/terminal_theme.dart';
+
+class TerminalThemes {
+  static const defaultTheme = TerminalTheme(
+    cursor: TerminalColor(0xffaeafad),
+    selection: TerminalColor(0xffffff40),
+    foreground: TerminalColor(0xffcccccc),
+    background: TerminalColor(0xff1e1e1e),
+    black: TerminalColor(0xff000000),
+    white: TerminalColor(0xffe5e5e5),
+    red: TerminalColor(0xffcd3131),
+    green: TerminalColor(0xff0dbc79),
+    yellow: TerminalColor(0xffe5e510),
+    blue: TerminalColor(0xff2472c8),
+    magenta: TerminalColor(0xffbc3fbc),
+    cyan: TerminalColor(0xff11a8cd),
+    brightBlack: TerminalColor(0xff666666),
+    brightRed: TerminalColor(0xfff14c4c),
+    brightGreen: TerminalColor(0xff23d18b),
+    brightYellow: TerminalColor(0xfff5f543),
+    brightBlue: TerminalColor(0xff3b8eea),
+    brightMagenta: TerminalColor(0xffd670d6),
+    brightCyan: TerminalColor(0xff29b8db),
+  );
+}