Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomicSponge committed May 27, 2024
1 parent 6ecc350 commit df8fa5b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
11 changes: 11 additions & 0 deletions electron/lib/ScriptBuffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ export class ScriptBuffer extends EventEmitter {
throw error
}
})

// Listen for clear events
this.on('script-buffer-clear', () => {
ScriptBuffer.#buffer = []
try {
this.#save()
} catch (error:any) {
throw new ScriptBufferError(error.message, this.#write)
}
this.emit('script-buffer-updated')
})
}

/**
Expand Down
18 changes: 18 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ const buildMenu = ():Menu => {
label: `Show Output Buffer`,
click: () => { bufferWindow() }
}))
bufferMenu.append(new MenuItem({ type: 'separator' }))

bufferMenu.append(new MenuItem({
label: `Save as JSON`,
Expand Down Expand Up @@ -374,6 +375,23 @@ const buildMenu = ():Menu => {
}
}
}))
bufferMenu.append(new MenuItem({ type: 'separator' }))

bufferMenu.append(new MenuItem({
label: 'Clear Buffer',
click: async () => {
const { response } = await dialog.showMessageBox({
type: 'question',
title: `${appInfo.name} - Confirm`,
buttons: [ 'Yes', 'No' ],
message: 'Are you sure you want to clear the buffer?'
})
if (response === 0) {
resBuff.emit('script-buffer-clear')
bufferWin?.webContents.send('send-buffer-data', resBuff.read())
}
}
}))

menu.append(new MenuItem({ label: `Output Buffer`, submenu: bufferMenu}))
menu.append(new MenuItem({
Expand Down

0 comments on commit df8fa5b

Please sign in to comment.