-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtextpad.html
executable file
·94 lines (88 loc) · 2.15 KB
/
textpad.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.12/ace.js"
integrity="sha512-GZ1RIgZaSc8rnco/8CXfRdCpDxRCphenIiZ2ztLy3XQfCbQUSCuk8IudvNHxkRA3oUg6q0qejgN/qqyG1duv5Q=="
crossorigin="anonymous"></script>
<style>
*{
font-family: monospace
}
body{
overflow: hidden
}
#editor {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
* {
cursor: var(--cursor) !important;
}
#ace_settingsmenu {
position: absolute;
top: 10px;
left: 10px;
color: white !important;
background-color: #000;
content: "<button></button>";
width: 80vw;
height: 70vh;
overflow: scroll;
font-family: system-ui,sans-serif
}
#path{
font-family: system-ui, menlo, monospace !important;
position: absolute;
bottom:0;
left:0;
width:99vw;
z-index:999;
border:none;
}
</style>
<link rel="stylesheet" href="ui.css">
</head>
<body>
<div id="editor"></div>
<input type="text" id="path" value="" placeholder="File path" />
<script>
path.style.fontFamily="ui-monospace,menlo,monospace"
var e = ace.edit("editor")
e.setOptions({
fontFamily: "ui-monospace,menlo,monospace",
fontSize: 15,
scrollPastEnd:0.5
})
e.setTheme('ace/theme/nord_dark')
var { hmm } = parent
setTimeout(() => {
if(window.arg===undefined)window.arg=""
if (window.arg.startsWith('$open ')) {
path.value=window.arg.slice(6)
e.setValue('' + hmm.pathToJs(window.arg.slice(6)))
if (/\.hmm\/code$/.test(window.arg)) {
e.session.setMode('ace/mode/html')
} else if (window.arg.startsWith("$open /cmd/")) {
e.session.setMode('ace/mode/javascript')
}
}
e.on('change', () => {
if (path.value.startsWith("/")) {
eval(hmm.pathToDot(path.value) + `=decodeURI("${encodeURI(e.getValue())}")`)
}else{
e.blur()
hmm.popup(`Enter a valid file path<br><button>${hmm.t('ui.ok')}</button>`)
}
})
}, 100)
</script>
<script src="ctx.js"></script>
</body>
</html>