Skip to content
This repository has been archived by the owner on Jul 12, 2022. It is now read-only.

Commit

Permalink
#21 #11 - ondidChange + tiny gui changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Scott committed May 23, 2021
1 parent b549dca commit b9b6011
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function createWindow()
{
// Create the browser window.
const mainWindow = new BrowserWindow({
height: 540,
height: 545,
width: 960,
minHeight: 480,
minWidth: 540,
Expand Down
2 changes: 2 additions & 0 deletions src/views/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ select{
grid-column-start: 3;
grid-column-end: 3;
border-style: hidden;
margin-left: 10px;
margin-right: 10px;
}
#iconFour{
display: flex;
Expand Down
43 changes: 28 additions & 15 deletions src/views/ts/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ import { ipcRenderer } from "electron";
import exports from "../../controllers/themeReader.ts";

const openFiles = new Map<number, YarnFileClass>();
var currentOpenYarnFile: YarnFileClass;

let editor: monaco.editor.IStandaloneCodeEditor;

//Register our new custom language
Expand Down Expand Up @@ -139,12 +141,31 @@ if (containerElement)
boldText?.click();
} );


//Editor specific events
editor.onDidChangeModelContent(e => {

//Check the currentOpenYarnFile against the editor's value
if (currentOpenYarnFile.contents == editor.getValue()){
console.log("they are the same");
currentOpenYarnFile.isSaved = true;
}

else{
console.log("they are not the same");
currentOpenYarnFile.isSaved = false;
}

});
}

//Working file details specific events
const workingFiles = document.getElementById("workingFilesDetail");

if (workingFiles){
console.log("workingFilesExists");

//console.log("workingFilesExists");

workingFiles.addEventListener('click', (event) => {
if(event && event.target && (event.target as HTMLButtonElement).tagName === "BUTTON"){

Expand Down Expand Up @@ -303,20 +324,9 @@ if (colourPick){
}

//Listen for editor commands
window.addEventListener("keydown", (e) =>{
if (e.ctrlKey && e.key === "b"){
boldText?.click();//send bold click event
}

//TODO remove the monaco commands that use these command combinations
// if (e.ctrlKey && e.key === "i"){
// italicText?.click();
// }

// if (e.ctrlKey && e.key === "u"){
// underlineText?.click();
// }
});
// window.addEventListener("keydown", (e) =>{
//No more need for this at this stage
// });



Expand Down Expand Up @@ -355,6 +365,9 @@ function createNewFile()
console.log("IN CREATE NEW FILE");
const newFile:YarnFileClass = new YarnFileClass(null, null, null, false, Date.now());
openFiles.set(newFile.getUniqueIdentifier(), newFile);

currentOpenYarnFile = newFile;

addFileToDisplay(newFile);
editor.setValue(newFile.contents);
}
Expand Down

0 comments on commit b9b6011

Please sign in to comment.