diff --git a/src/client/gui/lib/platform/linux.dart b/src/client/gui/lib/platform/linux.dart index c504e291e4..6e6a2b70b6 100644 --- a/src/client/gui/lib/platform/linux.dart +++ b/src/client/gui/lib/platform/linux.dart @@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart'; import '../settings/autostart_notifiers.dart'; import '../vm_details/terminal.dart'; +import '../vm_details/terminal_tabs.dart'; import 'platform.dart'; class LinuxPlatform extends MpPlatform { @@ -37,6 +38,10 @@ class LinuxPlatform extends MpPlatform { PasteTextIntent(SelectionChangedCause.keyboard), SingleActivator(LogicalKeyboardKey.insert, shift: true): PasteTextIntent(SelectionChangedCause.keyboard), + SingleActivator(LogicalKeyboardKey.keyW, control: true): + CloseTerminalIntent(), + SingleActivator(LogicalKeyboardKey.keyT, control: true): + AddTerminalIntent(), SingleActivator(LogicalKeyboardKey.equal, control: true): IncreaseTerminalFontIntent(), SingleActivator(LogicalKeyboardKey.equal, control: true, shift: true): diff --git a/src/client/gui/lib/platform/macos.dart b/src/client/gui/lib/platform/macos.dart index b26974be29..c8a49ad67b 100644 --- a/src/client/gui/lib/platform/macos.dart +++ b/src/client/gui/lib/platform/macos.dart @@ -5,6 +5,7 @@ import 'package:flutter/widgets.dart'; import '../settings/autostart_notifiers.dart'; import '../vm_details/terminal.dart'; +import '../vm_details/terminal_tabs.dart'; import 'platform.dart'; class MacOSPlatform extends MpPlatform { @@ -32,6 +33,10 @@ class MacOSPlatform extends MpPlatform { CopySelectionTextIntent.copy, SingleActivator(LogicalKeyboardKey.keyV, meta: true): PasteTextIntent(SelectionChangedCause.keyboard), + SingleActivator(LogicalKeyboardKey.keyW, meta: true): + CloseTerminalIntent(), + SingleActivator(LogicalKeyboardKey.keyT, meta: true): + AddTerminalIntent(), SingleActivator(LogicalKeyboardKey.equal, meta: true): IncreaseTerminalFontIntent(), SingleActivator(LogicalKeyboardKey.equal, meta: true, shift: true): diff --git a/src/client/gui/lib/platform/windows.dart b/src/client/gui/lib/platform/windows.dart index 4b9f870804..86a60d2780 100644 --- a/src/client/gui/lib/platform/windows.dart +++ b/src/client/gui/lib/platform/windows.dart @@ -8,6 +8,7 @@ import 'package:win32/win32.dart'; import '../settings/autostart_notifiers.dart'; import '../vm_details/terminal.dart'; +import '../vm_details/terminal_tabs.dart'; import 'platform.dart'; class WindowsPlatform extends MpPlatform { @@ -39,6 +40,10 @@ class WindowsPlatform extends MpPlatform { PasteTextIntent(SelectionChangedCause.keyboard), SingleActivator(LogicalKeyboardKey.insert, shift: true): PasteTextIntent(SelectionChangedCause.keyboard), + SingleActivator(LogicalKeyboardKey.keyW, control: true): + CloseTerminalIntent(), + SingleActivator(LogicalKeyboardKey.keyT, control: true): + AddTerminalIntent(), SingleActivator(LogicalKeyboardKey.equal, control: true): IncreaseTerminalFontIntent(), SingleActivator(LogicalKeyboardKey.equal, control: true, shift: true): diff --git a/src/client/gui/lib/vm_details/terminal_tabs.dart b/src/client/gui/lib/vm_details/terminal_tabs.dart index 591cb2eb51..b1b48c27c9 100644 --- a/src/client/gui/lib/vm_details/terminal_tabs.dart +++ b/src/client/gui/lib/vm_details/terminal_tabs.dart @@ -125,6 +125,14 @@ class Tab extends StatelessWidget { } } +class CloseTerminalIntent extends Intent { + const CloseTerminalIntent(); +} + +class AddTerminalIntent extends Intent { + const AddTerminalIntent(); +} + class TerminalTabs extends ConsumerWidget { final String name; @@ -136,6 +144,14 @@ class TerminalTabs extends ConsumerWidget { final notifier = provider.notifier; final (:ids, :currentIndex) = ref.watch(provider); + void closeTab(int index) { + ref.read(notifier).remove(index); + } + + void addTab() { + ref.read(notifier).add(); + } + final tabsAndShells = ids.mapIndexed((index, shellId) { final tab = ReorderableDragStartListener( key: ValueKey(shellId.id), @@ -144,7 +160,7 @@ class TerminalTabs extends ConsumerWidget { title: 'Shell ${shellId.id}', selected: index == currentIndex, onTap: () => ref.read(notifier).setCurrent(index), - onClose: () => ref.read(notifier).remove(index), + onClose: () => closeTab(index), ), ); @@ -164,7 +180,7 @@ class TerminalTabs extends ConsumerWidget { hoverColor: Colors.white24, splashRadius: 10, icon: const Icon(Icons.add, color: Colors.white, size: 20), - onPressed: () => ref.read(notifier).add(), + onPressed: () => addTab(), ), ); @@ -187,13 +203,23 @@ class TerminalTabs extends ConsumerWidget { ), ); - return Column(children: [ - Container( - color: const Color(0xff222222), - height: 35, - child: tabList, - ), - Expanded(child: shellStack), - ]); + return Actions( + actions: { + CloseTerminalIntent: CallbackAction( + onInvoke: (_) => closeTab(currentIndex), + ), + AddTerminalIntent: CallbackAction( + onInvoke: (_) => addTab(), + ), + }, + child: Column(children: [ + Container( + color: const Color(0xff222222), + height: 35, + child: tabList, + ), + Expanded(child: shellStack), + ]), + ); } }