File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -116,7 +116,35 @@ function refitTerminal() {
116116 window . requestAnimationFrame ( ( ) => {
117117 window . requestAnimationFrame ( ( ) => {
118118 if ( state . fitter ) {
119+ // We need to get the main viewport height and calculate what the size of the terminal pane should be
120+
121+ // Get the height of the header, footer, and serial bar to determine the height of the terminal
122+ let siteHeader = document . getElementById ( 'site-header' ) ;
123+ let mobileHeader = document . getElementById ( 'mobile-header' ) ;
124+ let headerHeight = siteHeader . offsetHeight ;
125+ if ( siteHeader . style . display === 'none' ) {
126+ headerHeight = mobileHeader . offsetHeight ;
127+ }
128+ let foorterBarHeight = document . getElementById ( 'footer-bar' ) . offsetHeight ;
129+ let serialBarHeight = document . getElementById ( 'serial-bar' ) . offsetHeight ;
130+ let viewportHeight = window . innerHeight ;
131+ let terminalHeight = viewportHeight - headerHeight - foorterBarHeight - serialBarHeight ;
132+
133+ // Fit the terminal to the new size (works good for growing)
119134 state . fitter . fit ( ) ;
135+
136+ // Fix the terminal screen height if it's too big
137+ let screen = document . querySelector ( '.xterm-screen' ) ;
138+ if ( screen && ( terminalHeight < screen . offsetHeight ) ) {
139+ // xterm-screen is 17px per row and 9px per column
140+ let rows = Math . floor ( terminalHeight / 17 ) ;
141+ if ( rows < 0 ) {
142+ rows = 0 ;
143+ }
144+ if ( rows < state . fitter . proposeDimensions ( ) . rows ) {
145+ screen . style . height = ( rows * 17 ) + 'px' ;
146+ }
147+ }
120148 }
121149 } ) ;
122150 } ) ;
You can’t perform that action at this time.
0 commit comments