-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinputSystem.js
More file actions
74 lines (70 loc) · 3.18 KB
/
inputSystem.js
File metadata and controls
74 lines (70 loc) · 3.18 KB
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
var Settings = {
OutputFile: null,
OutputFilePath: "",
debugMode: false,
jsonMode: false,
warningMessages: "",
nowLine: 0,
nowFile: null,
noWarnings: false,
beforeLog_once: null,
result: null,
warningMessagesRaw: "",
relativeFilePath: null,
noRepeat:false,
enableBinary:false
};
function writeLine(...lines) {
for (let i = 0; i < lines.length; i++) {
if (Settings.OutputFile != null) {
// ## ERROR:
if (lines[i] == null) continue;
if (lines[i].startsWith("## SyntaxError: ")) {
if (Settings.noWarnings) return;
Settings.warningMessagesRaw += (lines[i] + " in file " + Settings.OutputFilePath + "")
+ "\r\n";
Settings.warningMessages += "\n" + ("\x1B[31m" + lines[i] + " \x1B[34min file \x1B[36m\x1B[4m" + Settings.OutputFilePath + "\x1B[0m");
} else if (lines[i].startsWith("## ERROR: ")) {
if (Settings.noWarnings) return;
Settings.warningMessagesRaw += (lines[i] + " in file " + Settings.OutputFilePath + "")
+ "\r\n";
Settings.warningMessages += "\n" + ("\x1B[31m" + lines[i] + " \x1B[34min file \x1B[36m\x1B[4m" + Settings.OutputFilePath + "\x1B[0m");
} else if (lines[i].startsWith("## WARNING")) {
if (Settings.noWarnings) return;
Settings.warningMessagesRaw += (lines[i] + " in file " + Settings.OutputFilePath + "") + "\r\n";
Settings.warningMessages += "\n" + ("\x1B[33m" + lines[i] + " \x1B[34min file \x1B[36m\x1B[4m" + Settings.OutputFilePath + "\x1B[0m");
} else if (lines[i].startsWith("## Error")) {
if (Settings.noWarnings) return;
Settings.warningMessagesRaw += (lines[i] + " in file " + Settings.OutputFilePath + "") + "\r\n";
Settings.warningMessages += "\n" + ("\x1B[31m" + lines[i] + " \x1B[34min file \x1B[36m\x1B[4m" + Settings.OutputFilePath + "\x1B[0m");
}
if (!Settings.hasLog) Settings.hasLog = true;
if (Settings.beforeLog_once != null) {
Settings.OutputFile.write(Settings.beforeLog_once);
Settings.beforeLog_once = null;
}
Settings.OutputFile.write(lines[i] + "\r\n");
} else {
if (!Settings.hasLog) Settings.hasLog = true;
if (lines[i].startsWith("## ERROR:")) console.log("\x1B[31m")
else if (lines[i].startsWith("## Error")) console.log("\x1B[31m")
else if (lines[i].startsWith("## WARNING")) {
console.log("\x1B[33m");
} else if (lines[i].startsWith("## SyntaxError: ")) {
console.log("\x1B[31m")
}
if (Settings.beforeLog_once != null) {
console.log(Settings.beforeLog_once);
Settings.beforeLog_once = null;
}
console.log(lines[i] + "\x1B[0m");
}
}
}
function writeDebugLine(...lines) {
if (!Settings.debugMode) return;
for (let i = 0; i < lines.length; i++) {
console.log(lines[i])
}
}
module.exports = { writeDebugLine, writeLine, Settings }