@@ -42,6 +42,7 @@ define(function (require, exports, module) {
4242
4343 const Menus = require ( "command/Menus" ) ;
4444 const Commands = require ( "command/Commands" ) ;
45+ const KeyBindingManager = require ( "command/KeyBindingManager" ) ;
4546 const NotificationUI = require ( "widgets/NotificationUI" ) ;
4647 const TerminalInstance = require ( "./TerminalInstance" ) ;
4748 const ShellProfiles = require ( "./ShellProfiles" ) ;
@@ -90,6 +91,7 @@ define(function (require, exports, module) {
9091 let processInfo = { } ; // id -> processName from PTY
9192 let originalDefaultShellName = null ; // System-detected default shell name
9293 let _focusToastShown = false ; // Show focus hint toast only once per session
94+ let _clearHintShown = false ; // Show clear buffer hint toast only once per session
9395 let $panel , $contentArea , $shellDropdown , $flyoutList ;
9496
9597 /**
@@ -145,6 +147,38 @@ define(function (require, exports, module) {
145147 // Dropdown chevron button toggles shell selector
146148 $panel . find ( ".terminal-flyout-dropdown-btn" ) . on ( "click" , _onDropdownButtonClick ) ;
147149
150+ // When the terminal is focused, prevent Phoenix keybindings from
151+ // stealing keys that should go to the shell (e.g. Ctrl+L for clear).
152+ // The EDITOR_SHORTCUTS list in TerminalInstance.js already defines which
153+ // Ctrl combos should pass through to Phoenix; everything else should
154+ // reach xterm/the PTY.
155+ KeyBindingManager . addGlobalKeydownHook ( function ( event ) {
156+ if ( event . type !== "keydown" ) {
157+ return false ;
158+ }
159+ // Only intercept when a terminal textarea is focused
160+ const el = document . activeElement ;
161+ if ( ! el || ! $contentArea [ 0 ] . contains ( el ) ) {
162+ return false ;
163+ }
164+ // Let the terminal handle Ctrl/Cmd key combos that aren't
165+ // reserved for the editor (those are handled by TerminalInstance's
166+ // _customKeyHandler which returns false for them).
167+ const ctrlOrMeta = event . ctrlKey || event . metaKey ;
168+ const key = event . key . toLowerCase ( ) ;
169+ if ( ctrlOrMeta && ! event . shiftKey && key === "l" ) {
170+ _showClearBufferHintToast ( ) ;
171+ return true ; // Block Phoenix, let xterm handle Ctrl+L
172+ }
173+ // Ctrl+K (Cmd+K on mac): clear terminal scrollback
174+ if ( ctrlOrMeta && ! event . shiftKey && key === "k" ) {
175+ event . preventDefault ( ) ;
176+ _clearActiveTerminal ( ) ;
177+ return true ;
178+ }
179+ return false ;
180+ } ) ;
181+
148182 // Listen for panel resize
149183 WorkspaceManager . on ( "workspaceUpdateLayout" , _handleResize ) ;
150184
@@ -588,7 +622,7 @@ define(function (require, exports, module) {
588622 * Update the expanded/collapsed tab bar class based on panel width
589623 */
590624 function _updateTabBarMode ( ) {
591- $panel . toggleClass ( "terminal-tabs-expanded" , $panel . width ( ) >= 750 ) ;
625+ $panel . toggleClass ( "terminal-tabs-expanded" , $panel . width ( ) >= 840 ) ;
592626 }
593627
594628 /**
@@ -629,6 +663,24 @@ define(function (require, exports, module) {
629663 } ) ;
630664 }
631665
666+ /**
667+ * Show a one-time toast hint about Ctrl/Cmd+K to clear terminal buffer
668+ */
669+ function _showClearBufferHintToast ( ) {
670+ if ( _clearHintShown ) {
671+ return ;
672+ }
673+ _clearHintShown = true ;
674+
675+ const isMac = brackets . platform === "mac" ;
676+ const shortcutKey = isMac ? '<kbd>Cmd+K</kbd>' : '<kbd>Ctrl+K</kbd>' ;
677+ const message = StringUtils . format ( Strings . TERMINAL_CLEAR_BUFFER_HINT , shortcutKey ) ;
678+ NotificationUI . showToastOn ( $contentArea [ 0 ] , message , {
679+ autoCloseTimeS : 5 ,
680+ dismissOnClick : true
681+ } ) ;
682+ }
683+
632684 /**
633685 * Escape HTML special characters
634686 */
0 commit comments