-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathww.dnh
47 lines (47 loc) · 1.09 KB
/
ww.dnh
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
// because mkm was a dumbo at word wrapping
// THAT'S IT, FUCK MANUAL WORD WRAPPING
function ObjText_SetTextWW(text, string, maxStrLen) {
let right = 0;
let lastSpace = -1;
let len = length(string);
let prog = "";
let saved = "";
let cw = 0;
let prevls = 0;
while (right < len) {
let c = string[right];
if (c == ' ') {lastSpace = right; saved = prog; prog = prog ~ " ";}
else if (c == '&') {
while (string[right] != ';') {prog = prog ~ [string[right]]; right++;}
prog = prog ~ ";";
}
else if (c == '[') {
let tagCons = "";
while (string[right] != ']') {
prog = prog ~ [string[right]];
tagCons = tagCons ~ [string[right]];
right++; cw++;
}
prog = prog ~ "]";
if (tagCons == "[r") {
lastSpace = right;
saved = prog;
cw = 0;
}
}
else {prog = prog ~ [c];}
ObjText_SetText(text, prog);
//WriteLog(prog);
if (cw > maxStrLen) {
if (prevls != lastSpace) {
prog = saved ~ "[r]";
right = lastSpace;
prevls = lastSpace;
}
cw = 0;
}
right++;
cw++;
}
ObjText_SetText(text, prog);
}