@@ -115,6 +115,10 @@ class Terminal extends Box {
115115 }
116116
117117 this . pty . onData ( ( ) => {
118+ // Auto-scroll to bottom when new content arrives
119+ if ( this . term && typeof this . term . scrollToBottom === 'function' ) {
120+ this . term . scrollToBottom ( ) ;
121+ }
118122 setTimeout ( ( ) => this . screen . render ( ) , 16 ) ;
119123 } ) ;
120124
@@ -186,11 +190,13 @@ class Terminal extends Box {
186190 if ( xi >= xl || yi >= yl ) return ret ;
187191
188192 const buf = this . term . buffer . active ;
193+ const viewportY = buf . viewportY || 0 ; // Get the current scroll position
194+
189195 for ( var y = yi ; y < yl ; y ++ ) {
190196 var line = this . screen . lines [ y ] ;
191197 if ( ! line ) continue ;
192198
193- var bufferY = y - yi ;
199+ var bufferY = y - yi + viewportY ; // Account for scroll position
194200 var bufferLine = buf . getLine ( bufferY ) ;
195201 if ( ! bufferLine ) continue ;
196202
@@ -264,6 +270,30 @@ class Terminal extends Box {
264270 }
265271 }
266272
273+ scrollTo ( line : number ) : void {
274+ if ( this . term && typeof this . term . scrollToLine === 'function' ) {
275+ this . term . scrollToLine ( line ) ;
276+ }
277+ }
278+
279+ scroll ( offset : number ) : void {
280+ if ( this . term && typeof this . term . scrollLines === 'function' ) {
281+ this . term . scrollLines ( offset ) ;
282+ }
283+ }
284+
285+ scrollToTop ( ) : void {
286+ if ( this . term && typeof this . term . scrollToTop === 'function' ) {
287+ this . term . scrollToTop ( ) ;
288+ }
289+ }
290+
291+ scrollToBottom ( ) : void {
292+ if ( this . term && typeof this . term . scrollToBottom === 'function' ) {
293+ this . term . scrollToBottom ( ) ;
294+ }
295+ }
296+
267297 kill ( ) {
268298 if ( this . pty ) this . pty . kill ( ) ;
269299 if ( this . term ) this . term . dispose ( ) ;
0 commit comments