@@ -125,9 +125,14 @@ quickTools.$input.addEventListener("input", (e) => {
125125 if ( ! key || key . length > 1 ) return ;
126126 const keyCombination = getKeys ( { key } ) ;
127127
128- if ( keyCombination . shiftKey && ! keyCombination . ctrlKey ) {
128+ if (
129+ keyCombination . shiftKey &&
130+ ! keyCombination . ctrlKey &&
131+ ! keyCombination . altKey &&
132+ ! keyCombination . metaKey
133+ ) {
129134 resetKeys ( ) ;
130- editorManager . editor . insert ( shiftKeyMapping ( key ) ) ;
135+ insertText ( shiftKeyMapping ( key ) ) ;
131136 return ;
132137 }
133138
@@ -296,8 +301,7 @@ export default function actions(action, value) {
296301
297302 switch ( action ) {
298303 case "insert" :
299- editor . insert ( value ) ;
300- return true ;
304+ return insertText ( value ) ;
301305
302306 case "command" : {
303307 const commandName =
@@ -393,6 +397,12 @@ export default function actions(action, value) {
393397}
394398
395399function setInput ( ) {
400+ const terminalInput = getActiveTerminalInput ( ) ;
401+ if ( terminalInput ) {
402+ input = terminalInput ;
403+ return ;
404+ }
405+
396406 const { activeElement } = document ;
397407 if (
398408 ! activeElement ||
@@ -666,7 +676,16 @@ function getFooterHeight() {
666676
667677function focusEditor ( ) {
668678 const { editor, activeFile } = editorManager ;
669- if ( activeFile . focused ) {
679+ if ( ! activeFile ?. focused ) {
680+ return ;
681+ }
682+
683+ if ( activeFile . type === "terminal" && activeFile . terminalComponent ) {
684+ activeFile . terminalComponent . focus ( ) ;
685+ return ;
686+ }
687+
688+ if ( editor ) {
670689 editor . focus ( ) ;
671690 }
672691}
@@ -680,7 +699,7 @@ function resetKeys() {
680699 events . ctrl . forEach ( ( cb ) => cb ( false ) ) ;
681700 state . meta = false ;
682701 events . meta . forEach ( ( cb ) => cb ( false ) ) ;
683- input . focus ( ) ;
702+ input ? .focus ?. ( ) ;
684703}
685704
686705/**
@@ -700,6 +719,50 @@ export function getKeys(key = {}) {
700719 } ;
701720}
702721
722+ function getActiveTerminalComponent ( ) {
723+ const { activeFile } = editorManager ;
724+ if ( activeFile ?. type !== "terminal" ) return null ;
725+ return activeFile . terminalComponent || null ;
726+ }
727+
728+ function getActiveTerminalInput ( ) {
729+ return getActiveTerminalComponent ( ) ?. terminal ?. textarea || null ;
730+ }
731+
732+ function getInsertValue ( value ) {
733+ const text = String ( value ?? "" ) ;
734+ if (
735+ text . length === 1 &&
736+ state . shift &&
737+ ! state . ctrl &&
738+ ! state . alt &&
739+ ! state . meta
740+ ) {
741+ return shiftKeyMapping ( text ) ;
742+ }
743+
744+ return text ;
745+ }
746+
747+ function insertText ( value ) {
748+ const text = getInsertValue ( value ) ;
749+ if ( ! text ) return false ;
750+
751+ const terminalComponent = getActiveTerminalComponent ( ) ;
752+ if ( terminalComponent ?. terminal ) {
753+ if ( typeof terminalComponent . terminal . paste === "function" ) {
754+ terminalComponent . terminal . paste ( text ) ;
755+ } else {
756+ terminalComponent . write ( text ) ;
757+ }
758+ terminalComponent . focus ( ) ;
759+ return true ;
760+ }
761+
762+ const { editor } = editorManager ;
763+ return editor ? editor . insert ( text ) : false ;
764+ }
765+
703766function shiftKeyMapping ( char ) {
704767 switch ( char ) {
705768 case "1" :
0 commit comments