forked from teamsudocode/dexter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
editor.html
172 lines (153 loc) · 5.38 KB
/
editor.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dexter</title>
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono|Roboto:400,500,700" rel="stylesheet">
<link rel='shortcut icon' type='image/x-icon' href='/favicon.ico' />
<link rel="stylesheet" href="./lib/pane1/codemirror.css">
<link rel=stylesheet href="./lib/pane1/dialog.css">
<script src="./lib/pane1/codemirror.js"></script>
<script src="./lib/pane1/dialog.js"></script>
<script src="./lib/pane1/searchcursor.js"></script>
<script src="./lib/pane1/javascript.js"></script>
<script src="./lib/pane1/python.js"></script>
<script src="./lib/pane1/matchbrackets.js"></script>
<script src="./lib/pane1/vim.js"></script>
</head>
<body>
<div class="container">
<div class="nav">
<a href="index.html"><img src="static/img/text-logo.svg"></a>
<span id="status">Listening...</span>
<div class="language">
<p>Active Language</p>
<img src="static/img/english.svg" id="english">
<img src="static/img/hindi.svg" id="hindi">
</div>
</div>
<div class="editors" id="editorspane">
<div class="pane" id="js">
<div> </div>
<div class="title">
<div class="filename"><img src="static/img/js.svg"><span id="jsfile">index.js</span></div>
<div class="actions"><img src="static/img/undo.svg" id="undo"><button>Run<img src="static/img/run.svg"></button></div>
</div>
<div></div>
<div>
<form>
<textarea id="code1" name="code1">
</textarea>
</form>
</div>
</div>
<div class="divider"></div>
<div class="pane" id="python">
<div> </div>
<div class="title">
<div class="filename"><img src="static/img/python.svg"><span id="pyfile">index.py</span></div>
<div class="actions"><img src="static/img/undo.svg" id="undo"><button>Run<img src="static/img/run.svg"></button></div>
</div>
<div></div>
<div>
<textarea id="code2" name="code2">
</textarea>
</div>
</div>
</div>
<div class="preview">
<div class="Loader" id="rec-btn"><img src="static/img/mic.svg"></div>
<div id="text"> </div>
</div>
</div>
</body>
</html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles/editor.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="lib/bravey.min.js"></script>
<script src="js/handlers.js"></script>
<script src="js/mic.js"></script>
<script src="js/parser.js"></script>
<script src="js/index.js"></script>
<script src="js/app.js"></script>
<script>
var editor1 = CodeMirror.fromTextArea(document.getElementById("code1"), {
lineNumbers: true,
keyMap: 'vim',
matchBrackets: true,
autofocus: true,
mode: 'javascript',
showCursorWhenSelecting: true,
inputStyle: "contenteditable"
});
var editor2 = CodeMirror.fromTextArea(document.getElementById("code2"), {
lineNumbers: true,
keyMap: 'vim',
matchBrackets: true,
mode: 'python',
autofocus: true,
showCursorWhenSelecting: true,
inputStyle: "contenteditable",
});
// var commandDisplay = document.getElementById('command-display');
var keys1 = '';
CodeMirror.on(editor1, 'vim-keypress', function(key) {
keys1 = keys1 + key;
// commandDisplay.innerHTML = keys1;
console.log(keys1)
});
CodeMirror.on(editor1, 'vim-command-done', function(e) {
keys1 = '';
// commandDisplay.innerHTML = keys1;
});
//python
var keys2 = '';
CodeMirror.on(editor2, 'vim-keypress', function(key) {
keys2 = keys2 + key;
// commandDisplay.innerHTML = keys1;
console.log(keys2)
});
CodeMirror.on(editor2, 'vim-command-done', function(e) {
keys2 = '';
// commandDisplay.innerHTML = keys1;
});
//insert code in both editors
function _insertTextAtCursor(editor, text) {
var doc = editor.getDoc();
var cursor = doc.getCursor();
doc.replaceRange(text, cursor);
}
//undo and redo
function _undo() {
var doc1 = editor1.getDoc();
var doc2 = editor2.getDoc();
doc1.undo()
doc2.undo()
}
function _redo() {
var doc1 = editor1.getDoc();
var doc2 = editor2.getDoc();
doc1.redo()
doc2.redo()
}
//movement
function _wmoveright(editor) {
let a = editor.doc.cm.execCommand('goWordRight')
}
function _wmoveleft(editor) {
let a = editor.doc.cm.execCommand('goWordLeft')
}
function _lineUp(editor) {
let a = editor.doc.cm.execCommand('goLineUp')
}
function _lineDown(editor) {
let a = editor.doc.cm.execCommand('goLineDown')
}
</script>
// integration
<script>
newApp()
mic.startListening()
</script>