@@ -12,7 +12,7 @@ import { config, setContext } from '../util';
1212
1313import { extensionContext } from '../extension' ;
1414
15- import { FocusPlotMessage , InMessage , OutMessage , ToggleStyleMessage , UpdatePlotMessage , HidePlotMessage , AddPlotMessage , PreviewPlotLayout , PreviewPlotLayoutMessage } from './webviewMessages' ;
15+ import { FocusPlotMessage , InMessage , OutMessage , ToggleStyleMessage , UpdatePlotMessage , HidePlotMessage , AddPlotMessage , PreviewPlotLayout , PreviewPlotLayoutMessage , ToggleFullWindowMessage } from './webviewMessages' ;
1616
1717import { isHost , rHostService , shareBrowser } from '../liveshare' ;
1818
@@ -22,6 +22,7 @@ const commands = [
2222 'openExternal' ,
2323 'showIndex' ,
2424 'toggleStyle' ,
25+ 'toggleFullWindow' ,
2526 'togglePreviewPlots' ,
2627 'exportPlot' ,
2728 'nextPlot' ,
@@ -83,6 +84,7 @@ export class HttpgdManager {
8384 this . viewerOptions . previewPlotLayout = conf . get < PreviewPlotLayout > ( 'plot.defaults.plotPreviewLayout' , 'multirow' ) ;
8485 this . viewerOptions . refreshTimeoutLength = conf . get ( 'plot.timing.refreshInterval' , 10 ) ;
8586 this . viewerOptions . resizeTimeoutLength = conf . get ( 'plot.timing.resizeInterval' , 100 ) ;
87+ this . viewerOptions . fullWindow = conf . get ( 'plot.defaults.fullWindowMode' , false ) ;
8688 this . viewerOptions . token = token ;
8789 const viewer = new HttpgdViewer ( host , this . viewerOptions ) ;
8890 this . viewers . unshift ( viewer ) ;
@@ -171,16 +173,16 @@ export class HttpgdManager {
171173 void viewer . focusPlot ( stringArg ) ;
172174 break ;
173175 } case 'nextPlot' : {
174- viewer . nextPlot ( boolArg ) ;
176+ void viewer . nextPlot ( boolArg ) ;
175177 break ;
176178 } case 'prevPlot' : {
177- viewer . prevPlot ( boolArg ) ;
179+ void viewer . prevPlot ( boolArg ) ;
178180 break ;
179181 } case 'lastPlot' : {
180- viewer . nextPlot ( true ) ;
182+ void viewer . nextPlot ( true ) ;
181183 break ;
182184 } case 'firstPlot' : {
183- viewer . prevPlot ( true ) ;
185+ void viewer . prevPlot ( true ) ;
184186 break ;
185187 } case 'resetPlots' : {
186188 viewer . resetPlots ( ) ;
@@ -209,6 +211,9 @@ export class HttpgdManager {
209211 } case 'openExternal' : {
210212 void viewer . openExternal ( ) ;
211213 break ;
214+ } case 'toggleFullWindow' : {
215+ void viewer . toggleFullWindow ( ) ;
216+ break ;
212217 } default : {
213218 break ;
214219 }
@@ -267,6 +272,9 @@ export class HttpgdViewer implements IHttpgdViewer {
267272
268273 readonly defaultPreviewPlotLayout : PreviewPlotLayout = 'multirow' ;
269274 previewPlotLayout : PreviewPlotLayout ;
275+
276+ readonly defaultFullWindow : boolean = false ;
277+ fullWindow : boolean ;
270278
271279 // Custom file to be used instead of `styleOverwrites.css`
272280 customOverwriteCssPath ?: string ;
@@ -360,6 +368,8 @@ export class HttpgdViewer implements IHttpgdViewer {
360368 this . stripStyles = this . defaultStripStyles ;
361369 this . defaultPreviewPlotLayout = options . previewPlotLayout ?? this . defaultPreviewPlotLayout ;
362370 this . previewPlotLayout = this . defaultPreviewPlotLayout ;
371+ this . defaultFullWindow = options . fullWindow ?? this . defaultFullWindow ;
372+ this . fullWindow = this . defaultFullWindow ;
363373 this . resizeTimeoutLength = options . refreshTimeoutLength ?? this . resizeTimeoutLength ;
364374 this . refreshTimeoutLength = options . refreshTimeoutLength ?? this . refreshTimeoutLength ;
365375 this . api . start ( ) ;
@@ -397,7 +407,9 @@ export class HttpgdViewer implements IHttpgdViewer {
397407
398408 // focus a specific plot id
399409 public async focusPlot ( id ?: PlotId ) : Promise < void > {
400- this . activePlot = id ;
410+ if ( id ) {
411+ this . activePlot = id ;
412+ }
401413 const plt = this . plots [ this . activeIndex ] ;
402414 if ( plt . height !== this . viewHeight * this . scale || plt . width !== this . viewHeight * this . scale ) {
403415 await this . refreshPlots ( ) ;
@@ -416,13 +428,13 @@ export class HttpgdViewer implements IHttpgdViewer {
416428 }
417429
418430 // navigate through plots (supply `true` to go to end/beginning of list)
419- public nextPlot ( last ?: boolean ) : void {
431+ public async nextPlot ( last ?: boolean ) : Promise < void > {
420432 this . activeIndex = last ? this . plots . length - 1 : this . activeIndex + 1 ;
421- this . _focusPlot ( ) ;
433+ await this . focusPlot ( ) ;
422434 }
423- public prevPlot ( first ?: boolean ) : void {
435+ public async prevPlot ( first ?: boolean ) : Promise < void > {
424436 this . activeIndex = first ? 0 : this . activeIndex - 1 ;
425- this . _focusPlot ( ) ;
437+ await this . focusPlot ( ) ;
426438 }
427439
428440 // restore closed plots, reset zoom, redraw html
@@ -468,6 +480,15 @@ export class HttpgdViewer implements IHttpgdViewer {
468480 } ;
469481 this . postWebviewMessage ( msg ) ;
470482 }
483+
484+ public toggleFullWindow ( force ?: boolean ) : void {
485+ this . fullWindow = force ?? ! this . fullWindow ;
486+ const msg : ToggleFullWindowMessage = {
487+ message : 'toggleFullWindow' ,
488+ useFullWindow : this . fullWindow
489+ } ;
490+ this . postWebviewMessage ( msg ) ;
491+ }
471492
472493 public togglePreviewPlots ( force ?: PreviewPlotLayout ) : void {
473494 if ( force ) {
@@ -664,6 +685,8 @@ export class HttpgdViewer implements IHttpgdViewer {
664685 this . webviewPanel ??= this . makeNewWebview ( ) ;
665686 this . webviewPanel . webview . html = '' ;
666687 this . webviewPanel . webview . html = this . makeHtml ( ) ;
688+ // make sure that fullWindow is set correctly:
689+ this . toggleFullWindow ( this . fullWindow ) ;
667690 void this . setContextValues ( true ) ;
668691 }
669692
0 commit comments