import Renderer , { IRendererState } from "./render" ; import { IPossiblyUntitledFile , IDirEntryMeta } from "@common/files" ; export class RendererIpcHandlers { private _renderer : Renderer ; constructor ( renderer ) { this . _renderer = renderer ; } async menuFileSave ( ) { return this . _renderer . _editor ?. saveCurrentFile ( false ) ; } async menuFileSaveAs ( ) { return this . _renderer . _editor ?. saveCurrentFile ( true ) ; } async fileTreeChanged ( fileTree ) { console . log ( "RenderIPC :: fileTreeChanged" , fileTree . map ( val => val . name ) ) ; this . _renderer . setFileTree ( fileTree ) ; } async fileDidSave ( data ) { return this . _renderer . _editor ?. handleFileDidSave ( ) ; } async fileDidOpen ( file ) { return this . _renderer . setCurrentFile ( file ) ; } async navHistoryChanged ( history ) { this . _renderer . setNavHistory ( history ) ; } returns async requestFileClose ( ) { if ( ! this . _renderer . _editor ) { console . error ( "no editor to close!" ) ; return ; } let result = await this . _renderer . _editor . closeAndDestroy ( ) ; return ; } rejects async requestClose ( ) { todo return this . requestFileClose ( ) ; } async applyThemeCss ( cssString ) { this . _renderer . applyThemeCss ( cssString ) ; } } export type RendererIpcEvents = keyof RendererIpcHandlers ;