Escape number signs to prevent unwanted newlines

This commit is contained in:
Izwzyzx 2021-10-17 22:26:37 -05:00
parent 4c0abf49e1
commit 901f2fc817
3 changed files with 7 additions and 4 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
*.gmk
*.gm81
*.gb1
gittogmk
gmktogit
gmksplit.jar

Binary file not shown.

View File

@ -9,16 +9,18 @@ str=argument0;
logw=argument1;
loop=true;
// Escape number signs to prevent unwanted newlines
str=string_replace_all(str,"#","\#");
while (loop){
if(string_width(str)>logw){
// The string is too long to be displayed on one line.
if(string_pos(" ",str)&&(string_width(string_copy(str,1,string_pos(" ",str)))<logw)){
// There's a space before str exceeds the display width
i=string_length(str);
repeat(string_length(str)){
if((string_char_at(str,i)==" ")&&(string_width(string_copy(str,1,i))<logw)){
chatLog=chatLog+string_replace_all(string_copy(str,1,i-1),"#","\#")+EOL;
chatLog=chatLog+string_copy(str,1,i-1)+EOL;
str=string_delete(str,1,i);
break;
}
@ -30,7 +32,7 @@ while (loop){
repeat(string_length(str)){
if(string_width(string_copy(str,1,i))<logw){
str=string_insert("-",str,i-1);
chatLog=chatLog+string_replace_all(string_copy(str,1,i-1),"#","\#")+EOL;
chatLog=chatLog+string_copy(str,1,i-1)+EOL;
str=string_delete(str,1,i);
break;
}
@ -40,7 +42,7 @@ while (loop){
} else {
// The string will fit, just add it to the log.
chatLog=chatLog+string_replace_all(str,"#","\#")+EOL;
chatLog=chatLog+str+EOL;
loop=false;
}