From 253f8e6d4ec6ef30c3d32cd51d0ad3dea12b1039 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 27 Sep 2022 11:25:20 +0200 Subject: [PATCH] Expose shortcut actions Allow passing in custom actions for e.g. scrolling shortcuts. --- lib/src/terminal_view.dart | 5 +++++ lib/src/ui/shortcut/actions.dart | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/lib/src/terminal_view.dart b/lib/src/terminal_view.dart index f0e441b7..1158c6bf 100644 --- a/lib/src/terminal_view.dart +++ b/lib/src/terminal_view.dart @@ -43,6 +43,7 @@ class TerminalView extends StatefulWidget { this.alwaysShowCursor = false, this.deleteDetection = false, this.shortcuts, + this.actions, this.readOnly = false, this.hardwareKeyboardOnly = false, }) : super(key: key); @@ -118,6 +119,9 @@ class TerminalView extends StatefulWidget { /// of the terminal If not provided, [defaultTerminalShortcuts] will be used. final Map? shortcuts; + /// Optional actions for this terminal. + final Map>? actions; + /// True if no input should send to the terminal. final bool readOnly; @@ -261,6 +265,7 @@ class TerminalViewState extends State { child = TerminalActions( terminal: widget.terminal, controller: _controller, + actions: widget.actions, child: child, ); diff --git a/lib/src/ui/shortcut/actions.dart b/lib/src/ui/shortcut/actions.dart index 8c5b472c..5a5bd3e2 100644 --- a/lib/src/ui/shortcut/actions.dart +++ b/lib/src/ui/shortcut/actions.dart @@ -10,6 +10,7 @@ class TerminalActions extends StatelessWidget { super.key, required this.terminal, required this.controller, + required this.actions, required this.child, }); @@ -19,6 +20,8 @@ class TerminalActions extends StatelessWidget { final Widget child; + final Map>? actions; + @override Widget build(BuildContext context) { return Actions( @@ -60,6 +63,7 @@ class TerminalActions extends StatelessWidget { return null; }, ), + ...?actions, }, child: child, );