-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.qml
330 lines (257 loc) · 7.63 KB
/
main.qml
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import "Components" as Comp
import "Components/customs" as Cust
ApplicationWindow {
id: mainWindow
visible: true
width: screen.width
height: screen.desktopAvailableHeight - 48
color: "#f1f1f1"
flags: Qt.FramelessWindowHint | Qt.Window
// Application
property int current_tab: 0
property QtObject tab_view
property QtObject tab_bar
property var textComp: []
property var tab_headers: ["First Layout"]
// Editor
property string word
property var breaks: []
property string words: ""
property string prop_text: ""
property int tab_width: 0
// FileSystem
property var file_names: ["First Layout"]
property string opening_file: ""
property url cwd
property bool saved: false
property string full_text
// Runner
property bool sing_running
property bool project_running
// Application
signal createNewTab()
signal startNewDocument(string file_contents)
signal updateList(int pos, int ind, string value)
// Editor
signal spacePressed(string full_text, string curr_char, string line, int cur_pos, var ln_breaks)
signal enterPressed(string full_text,int cur_pos)
signal charPressed(string full_text, string curr_char, string line, int cur_pos, var ln_breaks)
signal backspacePressed(string some_text, int cur_pos)
signal tabPressed(string some_text, int cur_pos, bool pure)
signal mousePressed(int cur_pos)
signal count()
// FileSystem
signal openBtnPressed()
signal openFile(string file)
signal updateFileName(string file)
signal saveBtnPressed(string fulltext)
signal save(string filename)
// Runner
signal runSingleFile()
signal runProject()
// Application
onCreateNewTab: {
tab_view.addChild('../TextComponent.qml', tab_bar, 'tv')
}
onStartNewDocument: {
createNewTab()
var ind = tab_headers.length - 1
textComp[ind].text = file_contents
updateFileName(opening_file)
updateList(1, ind, opening_file)
}
onUpdateList: {
var headers
var files
if(pos == 0) {
tab_headers[ind] = value
headers = tab_headers
tab_headers = new Object(headers)
} else if(pos == 1) {
file_names[ind] = value
files = file_names
file_names = new Object(file_names)
}
if(pos == 2) {
tab_headers[ind] = value
headers = tab_headers
tab_headers = new Object(headers)
file_names[ind] = value
files = file_names
file_names = new Object(file_names)
}
}
Component.onCompleted: {
Connector.startUp()
}
// Editor
onSpacePressed: {
Connector.pressed_space(full_text, curr_char, line, cur_pos, ln_breaks)
}
onEnterPressed: {
breaks.push(textComp.cursorPosition)
Connector.pressed_enter(full_text, cur_pos)
}
onCharPressed: {
Connector.pressed_char(full_text, curr_char, line, cur_pos, ln_breaks)
}
onBackspacePressed: {
Connector.pressed_backspace(some_text, cur_pos)
}
onTabPressed: {
Connector.pressed_tab(some_text, cur_pos, pure)
}
onMousePressed: {
Connector.pressed_mouse(cur_pos)
}
onCount: {
var tComp = textComp[current_tab]
Connector.editor_count(tComp.getText(0, tComp.length), tComp.cursor_position)
}
// FileSystem
onOpenBtnPressed: {
o_Dialog.open()
}
onOpenFile: {
opening_file = file
Connector.read_file(file)
}
onUpdateFileName: {
// Update File name with real name
var ind = file_names.length - 1
var splits = file.split("/")
var last_id = splits.length - 1
var name = splits[last_id]
updateList(0, ind, name)
}
onSaveBtnPressed: {
full_text = fulltext
var filename = file_names[current_tab]
if (filename === "Untitled") {
s_Dialog.open()
} else {
save(filename)
}
}
onSave: {
Connector.save_file(filename, full_text)
}
// Runner
onRunSingleFile: {
var fileName = file_names[current_tab];
Connector.run_single_file(fileName);
}
onRunProject: {
Connector.run_project(mainFile);
}
FontLoader {
id: font_mat
source: "fonts/materialdesignicons-webfont.ttf"
}
Comp.Settings { id: settings }
menuBar: Comp.MainMenu {}
header: Rectangle {
width: parent.width
height: 36
color: "transparent"
Comp.Toolbar {}
}
Rectangle {
width: parent.width
height: parent.height
color: "transparent"
// the rectangle beneath
Rectangle {
id: main_content_rect
anchors.fill: parent
anchors.leftMargin: 12
anchors.rightMargin: 12
color: "transparent"
// the main layout
RowLayout {
width: parent.width
height: parent.height
Comp.CenterBlock {
Layout.fillWidth: true
Layout.fillHeight: true
}
Rectangle {
Layout.preferredWidth: main_content_rect.width / 4
Layout.fillHeight: true
border.color: "#45777777"
/*Comp.PropertiesBlock {
Layout.preferredWidth: main_content_rect.width / 4
Layout.fillHeight: true
visible: false
}*/
}
}
}
// the rectangle onTop
Rectangle {
width: parent.width
height: parent.height
color: "transparent"
}
}
footer: Rectangle {
width: parent.width
height: 24
color: "indigo"
Text {
text: prop_text
color: "white"
}
}
Comp.OpenDialog { id: o_Dialog }
Comp.SaveDialog { id: s_Dialog }
Connections {
target: Connector
onSend_base_html: {
//textComp.text = startUp
}
onSendCoOrd: {
var ret = returnCoOrd
prop_text = "Line: " + ret[0] + ", Col: " + ret[1]
}
onEnter_return: {
var ret = return_enter
var tComp = textComp[current_tab]
tComp.insert(tComp.cursorPosition, ret)
Connector.wake_enter_up(tComp.getText(0, tComp.length), tComp.cursorPosition, breaks)
}
onBackspace_return: {
var ret = return_backspace
var tComp = textComp[current_tab]
tComp.remove(ret[0], ret[1])
Connector.wake_enter_up(tComp.getText(0, tComp.length), tComp.cursorPosition, breaks)
}
onBacktab_return: {
var ret = return_backtab
textComp[current_tab].remove(ret[0], ret[1])
}
onWakeUp: {
var ret = _pressed_mouse
Connector.wake_me_up(textComp[current_tab].cursorPosition)
}
onCompletedProcess: {
var ret = return_completed
if(ret === "save") {
saved = true
}
}
onOpenedFile: {
var conts = return_contents
// Start New Document
startNewDocument(conts)
}
onCheckedVocab: {
var ret = return_vocab
textComp[current_tab].text = ret
count()
}
}
}