diff --git a/css/mainview.css b/css/mainview.css index feb4ed2..8aeaa64 100644 --- a/css/mainview.css +++ b/css/mainview.css @@ -2,6 +2,17 @@ body { background: #306a9c; padding: 0; margin: 0; + height: 100%; + width: 100%; + display: flex; + position: fixed; +} + +.app-container { + position: relative; + height: 100%; + flex-grow: 100; + float: right; } .frame { @@ -21,6 +32,13 @@ body { cursor: default; } +.traffic-lights{ + position: relative; + height: 100%; + width: 40px; + float: left; +} + .xbtn, .maxbtn { padding: 2px 4px; diff --git a/css/trafficlights.css b/css/trafficlights.css new file mode 100644 index 0000000..9add511 --- /dev/null +++ b/css/trafficlights.css @@ -0,0 +1,16 @@ +body { + --green: #02b302; + --red: #bd0202; + --yellow: #cfcf03; + background: var(--green); + margin: 0; +} + +#trafficlights { + width: 100vw; + height: 200vw; + position: absolute; + top: 0; + bottom: 0; + margin: auto; +} diff --git a/js/mainview.js b/js/mainview.js index f725d44..05952b5 100644 --- a/js/mainview.js +++ b/js/mainview.js @@ -21,7 +21,8 @@ $('.frame').not(".maximized").resizable({ minWidth: 50, minHeight: 59 }).draggable({ - handle: ".topbar" + handle: ".topbar", + containment: "parent" }); $('.swatches span').click(function () { diff --git a/js/terminal.js b/js/terminal.js index 0e402b9..d1432b8 100644 --- a/js/terminal.js +++ b/js/terminal.js @@ -19,6 +19,8 @@ let ptyProcess = pty.spawn(shell, [], { // Initialize the front end for the shell process let xterm = new Terminal({ cursorBlink: true, + rows: 18, + cols: 100 }); let commandToExecute = null; @@ -49,7 +51,7 @@ messagebus.subscribe(handleMessage, "newcommand"); messagebus.subscribe(handleMessage, "terminal"); xterm.open(document.getElementById('terminal')); -fit.fit(xterm); +//fit.fit(xterm); xterm.on('data', (data) => { if (receiveCount > -1) return; diff --git a/js/trafficlights.js b/js/trafficlights.js new file mode 100644 index 0000000..2d776e3 --- /dev/null +++ b/js/trafficlights.js @@ -0,0 +1,106 @@ +const pty = require('node-pty'); +const os = require('os'); +const Config = require('electron-config'); + +const config = new Config(); +const GIT_PATH = config.get('path'); + +const trafficlightpath = "res/pics/traffic-lights-"; + +const cmdStart = "echo '<<>>';"; +const historyIgnore = "history -d $(history | tail -n 1);"; +const cmdUpdateEnd = "echo '<<>>';\n"; +const cmdMergeEnd = "echo '<<>>';\n"; + +const branchUpdateCheck = "git fetch &> /dev/null; git status | grep 'git pull';"; + +const stashCmd = "git stash &> /dev/null; git stash apply stash@{0} --index &> /dev/null;"; +const mergeSimulateCmd = "git merge --no-commit 2>&1 | grep error; git reset --hard &> /dev/null;"; +const restoreStashCmd = "git stash pop stash@{0} --index &> /dev/null;"; + +const cmdOutMatch = "<<>>\r\n[^]*<<>>"; + +let shell = process.env[os.platform() === 'win32' ? 'COMSPEC' : 'SHELL']; + +let ptyProcess = pty.spawn(shell, [], { + name: 'xterm', + cwd: GIT_PATH, + env: process.env +}); + +function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +let body = document.getElementsByTagName('body')[0]; +let trafficLightsIcon = document.getElementById('trafficlights'); + +let cmdOut = null; +let cmdWrite = false; + +let isMergeError = false; +let isUpdateError = false; + +function resetVars() { + cmdOut = ""; + cmdWrite = true; +} + +ptyProcess.on('data', function(data) { + if (data.match("<<>>\r\n")) { + cmdWrite = false; + gitUpdateCallback(); + } else if (data.match("<<>>\r\n")) { + cmdWrite = false; + gitMergeConflictCallback(); + } + if (cmdWrite) { + cmdOut += data; + } + if (data.match("<<>>\r\n")) { + cmdOut = ""; + cmdWrite = true; + } +}); + +function gitUpdateCheck() { + cmdOut = ""; + ptyProcess.write(cmdStart + branchUpdateCheck + historyIgnore + cmdUpdateEnd); +} + +function gitUpdateCallback() { + if (cmdOut != "") { + body.style.background = "var(--yellow)"; + trafficLightsIcon.src = trafficlightpath + "yellow.png"; + isUpdateError = true; + } else { + isUpdateError = false; + } + gitMergeConflictCheck(); +} + +function gitMergeConflictCheck() { + cmdOut = ""; + ptyProcess.write(cmdStart + stashCmd + mergeSimulateCmd + restoreStashCmd + historyIgnore + cmdMergeEnd); +} + +function gitMergeConflictCallback() { + if (cmdOut != "") { + body.style.background = "var(--red)"; + trafficLightsIcon.src = trafficlightpath + "red.png"; + isMergeError = true; + } else { + isMergeError = false; + } + setGreenIfSafe(); +} + +function setGreenIfSafe() { + if (!isUpdateError && !isMergeError) { + body.style.background = "var(--green)"; + trafficLightsIcon.src = trafficlightpath + "green.png"; + } + setTimeout(gitUpdateCheck, 2000); +} + +gitUpdateCheck(); diff --git a/main.js b/main.js index c43e8f1..eccfd81 100644 --- a/main.js +++ b/main.js @@ -16,12 +16,13 @@ function createWelcomeWindow() { welcomeWindow = new BrowserWindow({ width: 700, height: 600, - frame: false, resizable: false, titleBarStyle: 'customButtonsOnHover', "node-integration": true }); + welcomeWindow.setMenu(null); + welcomeWindow.loadURL(url.format({ pathname: path.join(__dirname, './welcome.html'), protocol: 'file:', diff --git a/mainview.html b/mainview.html index ade3b2a..3859ef3 100644 --- a/mainview.html +++ b/mainview.html @@ -9,47 +9,50 @@ - + +
+ -
-
-
- - - - - +
+
+
+ + + + + +
+
+ +
+
x
-
- +
+
+ +
-
x
-
-
- -
-
-
-
-
-
- - - - - +
+
+
+ + + + + +
+
+ +
+
x
-
- +
+
-
x
-
-
-
diff --git a/res/pics/traffic-lights-green.png b/res/pics/traffic-lights-green.png new file mode 100644 index 0000000..92faff0 Binary files /dev/null and b/res/pics/traffic-lights-green.png differ diff --git a/res/pics/traffic-lights-red.png b/res/pics/traffic-lights-red.png new file mode 100644 index 0000000..96ecff3 Binary files /dev/null and b/res/pics/traffic-lights-red.png differ diff --git a/res/pics/traffic-lights-yellow.png b/res/pics/traffic-lights-yellow.png new file mode 100644 index 0000000..82c5761 Binary files /dev/null and b/res/pics/traffic-lights-yellow.png differ diff --git a/res/pics/traffic-lights.kra b/res/pics/traffic-lights.kra new file mode 100644 index 0000000..204b32d Binary files /dev/null and b/res/pics/traffic-lights.kra differ diff --git a/res/pics/traffic-lights.kra~ b/res/pics/traffic-lights.kra~ new file mode 100644 index 0000000..75a07e4 Binary files /dev/null and b/res/pics/traffic-lights.kra~ differ diff --git a/res/pics/traffic-lights.png b/res/pics/traffic-lights.png new file mode 100644 index 0000000..8e381bf Binary files /dev/null and b/res/pics/traffic-lights.png differ diff --git a/res/pics/traffic-lights.png~ b/res/pics/traffic-lights.png~ new file mode 100644 index 0000000..ceaab8c Binary files /dev/null and b/res/pics/traffic-lights.png~ differ diff --git a/trafficlights.html b/trafficlights.html new file mode 100644 index 0000000..c37463f --- /dev/null +++ b/trafficlights.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + +