Skip to content

Commit

Permalink
Set window title to name of current buffer
Browse files Browse the repository at this point in the history
#build
  • Loading branch information
heyman committed Dec 6, 2024
1 parent 62ee0e0 commit 203f966
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
3 changes: 3 additions & 0 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,9 @@ ipcMain.handle('dark-mode:set', (event, mode) => {

ipcMain.handle('dark-mode:get', () => nativeTheme.themeSource)

ipcMain.handle("setWindowTitle", (event, title) => {
win?.setTitle(title)
})

// Initialize note/file library
async function initFileLibrary(win) {
Expand Down
4 changes: 4 additions & 0 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ contextBridge.exposeInMainWorld("heynote", {
async getInitErrors() {
return await ipcRenderer.invoke("getInitErrors")
},

setWindowTitle(title) {
ipcRenderer.invoke("setWindowTitle", title)
},
})


Expand Down
5 changes: 5 additions & 0 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@
currentBufferPath() {
this.focusEditor()
},
currentBufferName() {
window.heynote.setWindowTitle(this.currentBufferName)
},
},
computed: {
...mapState(useHeynoteStore, [
"currentBufferPath",
"currentBufferName",
"showLanguageSelector",
"showBufferSelector",
"showCreateBuffer",
Expand Down
12 changes: 6 additions & 6 deletions src/editor/block/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ export function triggerCursorChange({state, dispatch}) {
}

const emitCursorChange = (editor) => {
const notesStore = useHeynoteStore()
const heynoteStore = useHeynoteStore()
return ViewPlugin.fromClass(
class {
update(update) {
Expand All @@ -430,11 +430,11 @@ const emitCursorChange = (editor) => {

const block = getActiveNoteBlock(update.state)
if (block && cursorLine) {
notesStore.currentCursorLine = cursorLine
notesStore.currentSelectionSize = selectionSize
notesStore.currentLanguage = block.language.name
notesStore.currentLanguageAuto = block.language.auto
notesStore.currentBufferName = editor.name
heynoteStore.currentCursorLine = cursorLine
heynoteStore.currentSelectionSize = selectionSize
heynoteStore.currentLanguage = block.language.name
heynoteStore.currentLanguageAuto = block.language.auto
heynoteStore.currentBufferName = editor.name
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions webapp/bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ const Heynote = {
async getInitErrors() {

},

setWindowTitle(title) {
document.title = title + " - Heynote"
},
}

export { Heynote, ipcRenderer}

0 comments on commit 203f966

Please sign in to comment.