Escape number signs to prevent unwanted newlines
This commit is contained in:
parent
4c0abf49e1
commit
901f2fc817
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,6 @@
|
||||
*.gmk
|
||||
*.gm81
|
||||
*.gb1
|
||||
gittogmk
|
||||
gmktogit
|
||||
gmksplit.jar
|
||||
|
Binary file not shown.
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user