From bd8186962b7e00e53df536c551b9aab671d121ba Mon Sep 17 00:00:00 2001 From: Andrei Toterman Date: Thu, 5 Dec 2024 14:01:41 +0100 Subject: [PATCH 1/3] [gui] replace some deprecated styling classes --- src/client/gui/lib/vm_details/terminal.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/client/gui/lib/vm_details/terminal.dart b/src/client/gui/lib/vm_details/terminal.dart index 8ef6de99cd..476b5b15e0 100644 --- a/src/client/gui/lib/vm_details/terminal.dart +++ b/src/client/gui/lib/vm_details/terminal.dart @@ -192,12 +192,12 @@ class _VmTerminalState extends ConsumerState { })); final buttonStyle = ButtonStyle( - foregroundColor: MaterialStateColor.resolveWith((states) { - final disabled = states.contains(MaterialState.disabled); + foregroundColor: WidgetStateColor.resolveWith((states) { + final disabled = states.contains(WidgetState.disabled); return Colors.white.withOpacity(disabled ? 0.5 : 1.0); }), - side: MaterialStateBorderSide.resolveWith((states) { - final disabled = states.contains(MaterialState.disabled); + side: WidgetStateBorderSide.resolveWith((states) { + final disabled = states.contains(WidgetState.disabled); var color = Colors.white.withOpacity(disabled ? 0.5 : 1.0); return BorderSide(color: color); }), From 239cb3f856786e25e5926519dd42a2d41800db40 Mon Sep 17 00:00:00 2001 From: Andrei Toterman Date: Thu, 5 Dec 2024 16:23:35 +0100 Subject: [PATCH 2/3] [gui] add zoom in terminal --- src/client/gui/lib/platform/linux.dart | 7 ++ src/client/gui/lib/platform/macos.dart | 7 ++ src/client/gui/lib/platform/windows.dart | 7 ++ src/client/gui/lib/vm_details/terminal.dart | 115 ++++++++++++------ .../gui/lib/vm_details/terminal_tabs.dart | 1 + 5 files changed, 98 insertions(+), 39 deletions(-) diff --git a/src/client/gui/lib/platform/linux.dart b/src/client/gui/lib/platform/linux.dart index eaf69140e6..b778e7bbaf 100644 --- a/src/client/gui/lib/platform/linux.dart +++ b/src/client/gui/lib/platform/linux.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import '../settings/autostart_notifiers.dart'; +import '../vm_details/terminal.dart'; import 'platform.dart'; class LinuxPlatform extends MpPlatform { @@ -32,6 +33,12 @@ class LinuxPlatform extends MpPlatform { CopySelectionTextIntent.copy, SingleActivator(LogicalKeyboardKey.keyV, control: true, shift: true): PasteTextIntent(SelectionChangedCause.keyboard), + SingleActivator(LogicalKeyboardKey.equal, control: true): + IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.minus, control: true): + DecreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.digit0, control: true): + ResetTerminalFontIntent(), }; @override diff --git a/src/client/gui/lib/platform/macos.dart b/src/client/gui/lib/platform/macos.dart index f4a7991bb4..8cf1e4100a 100644 --- a/src/client/gui/lib/platform/macos.dart +++ b/src/client/gui/lib/platform/macos.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import '../settings/autostart_notifiers.dart'; +import '../vm_details/terminal.dart'; import 'platform.dart'; class MacOSPlatform extends MpPlatform { @@ -31,6 +32,12 @@ class MacOSPlatform extends MpPlatform { CopySelectionTextIntent.copy, SingleActivator(LogicalKeyboardKey.keyV, meta: true): PasteTextIntent(SelectionChangedCause.keyboard), + SingleActivator(LogicalKeyboardKey.equal, meta: true): + IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.minus, meta: true): + DecreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.digit0, meta: true): + ResetTerminalFontIntent(), }; @override diff --git a/src/client/gui/lib/platform/windows.dart b/src/client/gui/lib/platform/windows.dart index f23fcc91e2..4b6a41903b 100644 --- a/src/client/gui/lib/platform/windows.dart +++ b/src/client/gui/lib/platform/windows.dart @@ -7,6 +7,7 @@ import 'package:flutter/widgets.dart'; import 'package:win32/win32.dart'; import '../settings/autostart_notifiers.dart'; +import '../vm_details/terminal.dart'; import 'platform.dart'; class WindowsPlatform extends MpPlatform { @@ -34,6 +35,12 @@ class WindowsPlatform extends MpPlatform { CopySelectionTextIntent.copy, SingleActivator(LogicalKeyboardKey.keyV, control: true, shift: true): PasteTextIntent(SelectionChangedCause.keyboard), + SingleActivator(LogicalKeyboardKey.equal, control: true): + IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.minus, control: true): + DecreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.digit0, control: true): + ResetTerminalFontIntent(), }; @override diff --git a/src/client/gui/lib/vm_details/terminal.dart b/src/client/gui/lib/vm_details/terminal.dart index 476b5b15e0..c194ed1b9b 100644 --- a/src/client/gui/lib/vm_details/terminal.dart +++ b/src/client/gui/lib/vm_details/terminal.dart @@ -1,5 +1,6 @@ import 'dart:convert'; import 'dart:isolate'; +import 'dart:math'; import 'package:async/async.dart'; import 'package:dartssh2/dartssh2.dart'; @@ -160,9 +161,27 @@ class VmTerminal extends ConsumerStatefulWidget { ConsumerState createState() => _VmTerminalState(); } +class IncreaseTerminalFontIntent extends Intent { + const IncreaseTerminalFontIntent(); +} + +class DecreaseTerminalFontIntent extends Intent { + const DecreaseTerminalFontIntent(); +} + +class ResetTerminalFontIntent extends Intent { + const ResetTerminalFontIntent(); +} + class _VmTerminalState extends ConsumerState { + static const defaultFontSize = 13.0; + static const minFontSize = 2.5; + static const maxFontSize = 36.0; + static const fontSizeStep = 0.5; + final scrollController = ScrollController(); final focusNode = FocusNode(); + var fontSize = defaultFontSize; @override void initState() { @@ -228,45 +247,63 @@ class _VmTerminalState extends ConsumerState { ); } - return RawScrollbar( - controller: scrollController, - thickness: 9, - child: ClipRect( - child: TerminalView( - terminal, - scrollController: scrollController, - focusNode: focusNode, - shortcuts: mpPlatform.terminalShortcuts, - hardwareKeyboardOnly: true, - padding: const EdgeInsets.all(4), - textStyle: TerminalStyle( - fontFamily: 'UbuntuMono', - fontFamilyFallback: ['NotoColorEmoji', 'FreeSans'], - ), - theme: const TerminalTheme( - cursor: Color(0xFFE5E5E5), - selection: Color(0x80E5E5E5), - foreground: Color(0xffffffff), - background: Color(0xff380c2a), - black: Color(0xFF000000), - white: Color(0xFFE5E5E5), - red: Color(0xFFCD3131), - green: Color(0xFF0DBC79), - yellow: Color(0xFFE5E510), - blue: Color(0xFF2472C8), - magenta: Color(0xFFBC3FBC), - cyan: Color(0xFF11A8CD), - 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), + return Actions( + actions: { + IncreaseTerminalFontIntent: CallbackAction( + onInvoke: (_) => setState(() { + fontSize = min(fontSize + fontSizeStep, maxFontSize); + }), + ), + DecreaseTerminalFontIntent: CallbackAction( + onInvoke: (_) => setState(() { + fontSize = max(fontSize - fontSizeStep, minFontSize); + }), + ), + ResetTerminalFontIntent: CallbackAction( + onInvoke: (_) => setState(() => fontSize = defaultFontSize), + ), + }, + child: RawScrollbar( + controller: scrollController, + thickness: 9, + child: ClipRect( + child: TerminalView( + terminal, + scrollController: scrollController, + focusNode: focusNode, + shortcuts: mpPlatform.terminalShortcuts, + hardwareKeyboardOnly: true, + padding: const EdgeInsets.all(4), + textStyle: TerminalStyle( + fontFamily: 'UbuntuMono', + fontFamilyFallback: ['NotoColorEmoji', 'FreeSans'], + fontSize: fontSize, + ), + theme: const TerminalTheme( + cursor: Color(0xFFE5E5E5), + selection: Color(0x80E5E5E5), + foreground: Color(0xffffffff), + background: Color(0xff380c2a), + black: Color(0xFF000000), + white: Color(0xFFE5E5E5), + red: Color(0xFFCD3131), + green: Color(0xFF0DBC79), + yellow: Color(0xFFE5E510), + blue: Color(0xFF2472C8), + magenta: Color(0xFFBC3FBC), + cyan: Color(0xFF11A8CD), + 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), + ), ), ), ), diff --git a/src/client/gui/lib/vm_details/terminal_tabs.dart b/src/client/gui/lib/vm_details/terminal_tabs.dart index 881987136d..591cb2eb51 100644 --- a/src/client/gui/lib/vm_details/terminal_tabs.dart +++ b/src/client/gui/lib/vm_details/terminal_tabs.dart @@ -149,6 +149,7 @@ class TerminalTabs extends ConsumerWidget { ); final shell = VmTerminal( + key: GlobalObjectKey(shellId), name, shellId, isCurrent: index == currentIndex, From 4afcbbb0cd0ae7c2dc36c678bd7fd1c0cafc3d07 Mon Sep 17 00:00:00 2001 From: Andrei Toterman Date: Wed, 11 Dec 2024 12:28:26 +0100 Subject: [PATCH 3/3] [gui] more shortcuts for terminal zoom --- src/client/gui/lib/platform/linux.dart | 8 ++++++++ src/client/gui/lib/platform/macos.dart | 8 ++++++++ src/client/gui/lib/platform/windows.dart | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/client/gui/lib/platform/linux.dart b/src/client/gui/lib/platform/linux.dart index b778e7bbaf..335a49d9e7 100644 --- a/src/client/gui/lib/platform/linux.dart +++ b/src/client/gui/lib/platform/linux.dart @@ -35,8 +35,16 @@ class LinuxPlatform extends MpPlatform { PasteTextIntent(SelectionChangedCause.keyboard), SingleActivator(LogicalKeyboardKey.equal, control: true): IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.equal, control: true, shift: true): + IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.add, control: true, shift: true): + IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.numpadAdd, control: true): + IncreaseTerminalFontIntent(), SingleActivator(LogicalKeyboardKey.minus, control: true): DecreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.numpadSubtract, control: true): + DecreaseTerminalFontIntent(), SingleActivator(LogicalKeyboardKey.digit0, control: true): ResetTerminalFontIntent(), }; diff --git a/src/client/gui/lib/platform/macos.dart b/src/client/gui/lib/platform/macos.dart index 8cf1e4100a..b26974be29 100644 --- a/src/client/gui/lib/platform/macos.dart +++ b/src/client/gui/lib/platform/macos.dart @@ -34,8 +34,16 @@ class MacOSPlatform extends MpPlatform { PasteTextIntent(SelectionChangedCause.keyboard), SingleActivator(LogicalKeyboardKey.equal, meta: true): IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.equal, meta: true, shift: true): + IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.add, meta: true, shift: true): + IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.numpadAdd, meta: true): + IncreaseTerminalFontIntent(), SingleActivator(LogicalKeyboardKey.minus, meta: true): DecreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.numpadSubtract, meta: true): + DecreaseTerminalFontIntent(), SingleActivator(LogicalKeyboardKey.digit0, meta: true): ResetTerminalFontIntent(), }; diff --git a/src/client/gui/lib/platform/windows.dart b/src/client/gui/lib/platform/windows.dart index 4b6a41903b..1745ca0cd3 100644 --- a/src/client/gui/lib/platform/windows.dart +++ b/src/client/gui/lib/platform/windows.dart @@ -37,8 +37,16 @@ class WindowsPlatform extends MpPlatform { PasteTextIntent(SelectionChangedCause.keyboard), SingleActivator(LogicalKeyboardKey.equal, control: true): IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.equal, control: true, shift: true): + IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.add, control: true, shift: true): + IncreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.numpadAdd, control: true): + IncreaseTerminalFontIntent(), SingleActivator(LogicalKeyboardKey.minus, control: true): DecreaseTerminalFontIntent(), + SingleActivator(LogicalKeyboardKey.numpadSubtract, control: true): + DecreaseTerminalFontIntent(), SingleActivator(LogicalKeyboardKey.digit0, control: true): ResetTerminalFontIntent(), };