-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·60 lines (51 loc) · 1.21 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Notepad</title>
<style>
textarea {
width: 100vw;
height: 100vh;
padding: 0;
border: 0;
outline: 0;
margin: 0;
position: absolute;
top: 0;
left: 0;
}
</style>
</head>
<body>
<textarea id="cmdIn"></textarea>
<script>
const {
ipcRenderer
} = require('electron')
const buffer = document.getElementById('cmdIn')
let prompt = ""
function updateBuffer(data) {
buffer.value = buffer.value + data;
}
window.addEventListener('keypress', (e) => {
if (e.keyCode === 13) {
let cmd = cmdIn.value.split('\n').pop().split(prompt).slice(1).join()
if (cmd && cmd.length > 0) {
ipcRenderer.send('msg', cmd)
} else {
buffer.value = buffer.value.split("\n").slice(0,-1).join("\n") + "\n" + prompt
}
}
})
ipcRenderer.on('asynchronous-reply', (event, arg) => {
updateBuffer(arg)
})
ipcRenderer.on('cwd', (event, arg) => {
prompt = arg + "$ "
updateBuffer(prompt)
})
ipcRenderer.send('cwd')
</script>
</body>
</html>