|
|
|
@ -13,6 +13,7 @@ const {parser} = require("./Parser"); |
|
|
|
|
|
|
|
|
|
app.commandLine.appendSwitch("disable-http-cache"); |
|
|
|
|
|
|
|
|
|
const RECENT_FILES = 5; |
|
|
|
|
class Ation { |
|
|
|
|
windowManager; |
|
|
|
|
fontManager; |
|
|
|
@ -21,6 +22,7 @@ class Ation { |
|
|
|
|
watcher; |
|
|
|
|
currentFile; |
|
|
|
|
fileToOpen; |
|
|
|
|
recentFiles; |
|
|
|
|
|
|
|
|
|
constructor() { |
|
|
|
|
if (Ation.Instances > 0) |
|
|
|
@ -31,6 +33,7 @@ class Ation { |
|
|
|
|
this.windowManager = new WindowManager(this); |
|
|
|
|
this.fontManager = new FontManager(); |
|
|
|
|
this.settingsManager = new SettingsManager(this); |
|
|
|
|
this.recentFiles = this.settingsManager.get("recentFiles", []); |
|
|
|
|
this.mainMenu = new MainMenu(this); |
|
|
|
|
|
|
|
|
|
ipcMain.handle("Ation::appVersion", () => AppInfo.version); |
|
|
|
@ -64,6 +67,23 @@ class Ation { |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
addRecentFile(filePath) { |
|
|
|
|
if (this.recentFiles.includes(filePath)) { |
|
|
|
|
const position = this.recentFiles.indexOf(filePath); |
|
|
|
|
|
|
|
|
|
this.recentFiles.splice(position, 1), |
|
|
|
|
this.recentFiles.push(filePath); |
|
|
|
|
} else if (this.recentFiles.length < RECENT_FILES) { |
|
|
|
|
this.recentFiles.push(filePath); |
|
|
|
|
} else { |
|
|
|
|
this.recentFiles.shift(); |
|
|
|
|
this.recentFiles.push(filePath); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.settingsManager.set("recentFiles", this.recentFiles); |
|
|
|
|
this.mainMenu.refresh(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async openFile(filePath = null, change = false) { |
|
|
|
|
if (!this.windowManager.mainWindow) |
|
|
|
|
return null; |
|
|
|
@ -99,8 +119,9 @@ class Ation { |
|
|
|
|
else |
|
|
|
|
this.openFile(this.currentFile, true); |
|
|
|
|
}); |
|
|
|
|
Menu.getApplicationMenu().getMenuItemById("close-file").enabled = this.currentFile !== ""; |
|
|
|
|
this.windowManager.mainWindow.send("Ation::openFile", [basePath, data]); |
|
|
|
|
this.addRecentFile(filePath); |
|
|
|
|
Menu.getApplicationMenu().getMenuItemById("close-file").enabled = this.currentFile !== ""; |
|
|
|
|
} catch (error) { |
|
|
|
|
console.log(error); |
|
|
|
|
return; |
|
|
|
|