@@ -241,20 +241,13 @@ export default class AcodeX {
241241 }
242242
243243 renderUI ( ) {
244- if ( ! this . $terminalContainer || ! this . $showTermBtn ) return ;
244+ if ( ! this . $terminalHeader || ! this . $showTermBtn ) return ;
245245
246246 render (
247247 h ( TerminalShell , {
248- bindHeader : ( element ) => {
249- this . $terminalHeader = element ;
250- } ,
251- bindContent : ( element ) => {
252- this . $terminalContent = element ;
253- } ,
254248 bindSearchInput : ( element ) => {
255249 this . $searchInput = element ;
256250 } ,
257- onHeaderPointerDown : this . handleStartDragging ,
258251 searchVisible : this . uiState . searchVisible ,
259252 searchQuery : this . uiState . searchQuery ,
260253 sessionName : this . uiState . sessionName ,
@@ -270,7 +263,7 @@ export default class AcodeX {
270263 onSearchNext : this . _findNextMatchofSearch . bind ( this ) ,
271264 onSearchPrevious : this . _findPreviousMatchofSearch . bind ( this ) ,
272265 } ) ,
273- this . $terminalContainer ,
266+ this . $terminalHeader ,
274267 ) ;
275268
276269 render ( h ( FloatingTerminalButton , null ) , this . $showTermBtn ) ;
@@ -435,6 +428,12 @@ export default class AcodeX {
435428 this . $terminalContainer = tag ( "div" , {
436429 className : "terminal-panel" ,
437430 } ) ;
431+ this . $terminalHeader = tag ( "div" , {
432+ className : "terminal-title-bar" ,
433+ } ) ;
434+ this . $terminalContent = tag ( "div" , {
435+ className : "terminal-content" ,
436+ } ) ;
438437 this . $showTermBtn = tag ( "button" , {
439438 className : "show-terminal-btn" ,
440439 ariaLabel : "Restore terminal" ,
@@ -444,6 +443,18 @@ export default class AcodeX {
444443 this . setupGUIViewerPage ( ) ;
445444 }
446445
446+ this . $terminalHeader . addEventListener (
447+ "mousedown" ,
448+ this . handleStartDragging ,
449+ ) ;
450+ this . $terminalHeader . addEventListener (
451+ "touchstart" ,
452+ this . handleStartDragging ,
453+ ) ;
454+ this . $terminalContainer . append (
455+ this . $terminalHeader ,
456+ this . $terminalContent ,
457+ ) ;
447458 this . renderUI ( ) ;
448459
449460 // append Terminal panel to app main
@@ -1070,7 +1081,6 @@ export default class AcodeX {
10701081 this . $terminal . loadAddon ( this . $webLinkAddon ) ;
10711082 this . $terminal . loadAddon ( this . $searchAddon ) ;
10721083
1073- this . fitTerminal ( ) ;
10741084 if ( this . $webglAddon ) {
10751085 try {
10761086 this . $terminal . loadAddon ( this . $webglAddon ) ;
@@ -1087,6 +1097,7 @@ export default class AcodeX {
10871097 }
10881098 if ( this . $terminal . element ) {
10891099 this . _setTerminalPadding ( this . settings . terminalPadding ) ;
1100+ this . fitTerminal ( ) ;
10901101 }
10911102 if ( this . settings . fontLigatures ) {
10921103 this . $ligatureAddon = new LigaturesAddon ( ) ;
@@ -1514,6 +1525,7 @@ export default class AcodeX {
15141525 }
15151526
15161527 _hideTerminalSession ( ) {
1528+ this . cleanupSelectionManager ( ) ;
15171529 this . $attachAddon ?. dispose ( ) ;
15181530 this . $fitAddon ?. dispose ( ) ;
15191531 this . $unicode11Addon ?. dispose ( ) ;
@@ -1724,6 +1736,7 @@ export default class AcodeX {
17241736 }
17251737
17261738 _updateTerminalHeight ( ) {
1739+ if ( ! this . $terminalContent ) return ;
17271740 this . $terminalContent . style . height = "100%" ;
17281741 localStorage . setItem (
17291742 "AcodeX_Terminal_Cont_Height" ,
@@ -1733,9 +1746,24 @@ export default class AcodeX {
17331746 }
17341747
17351748 fitTerminal ( ) {
1736- const dimensions = this . $fitAddon . proposeDimensions ( ) ;
1737- if ( dimensions ) {
1749+ if (
1750+ ! this . $fitAddon ||
1751+ ! this . $terminal ||
1752+ ! this . $terminal . element ||
1753+ ! this . $terminalContent ?. isConnected ||
1754+ this . $terminalContainer ?. classList . contains ( "hide" )
1755+ ) {
1756+ return ;
1757+ }
1758+
1759+ try {
1760+ const dimensions = this . $fitAddon . proposeDimensions ( ) ;
1761+ if ( ! dimensions ?. cols || ! dimensions ?. rows ) {
1762+ return ;
1763+ }
17381764 this . $terminal . resize ( dimensions . cols + 2 , dimensions . rows + 1 ) ;
1765+ } catch ( error ) {
1766+ console . warn ( "AcodeX fitTerminal skipped:" , error ) ;
17391767 }
17401768 }
17411769
@@ -2115,7 +2143,7 @@ export default class AcodeX {
21152143 }
21162144
21172145 async destroy ( ) {
2118- render ( null , this . $terminalContainer ) ;
2146+ render ( null , this . $terminalHeader ) ;
21192147 render ( null , this . $showTermBtn ) ;
21202148 this . $style ?. remove ( ) ;
21212149 this . xtermCss ?. remove ( ) ;
@@ -2141,6 +2169,8 @@ export default class AcodeX {
21412169 this . handleStartDraggingFloatingBtn ,
21422170 ) ;
21432171 this . $showTermBtn ?. removeEventListener ( "click" , this . handleMaximiseClick ) ;
2172+ this . $terminalHeader ?. removeEventListener ( "mousedown" , this . handleStartDragging ) ;
2173+ this . $terminalHeader ?. removeEventListener ( "touchstart" , this . handleStartDragging ) ;
21442174 window . removeEventListener ( "mousemove" , this . handleDrag ) ;
21452175 window . removeEventListener ( "touchmove" , this . handleDrag ) ;
21462176 window . removeEventListener ( "mouseup" , this . handleStopDragging ) ;
0 commit comments