readd_quotes() for TGUI Text Input

This commit is contained in:
Casey
2022-06-19 07:07:51 -04:00
committed by Darlantan
parent e69110c2f9
commit 78f8b46e7d
4 changed files with 260 additions and 11 deletions

View File

@@ -481,20 +481,23 @@
/// Used to get a properly sanitized input, of max_length
/// no_trim is self explanatory but it prevents the input from being trimed if you intend to parse newlines or whitespace.
/proc/stripped_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE)
var/name = input(user, message, title, default) as text|null
var/user_input = input(user, message, title, default) as text|null
if(isnull(user_input))
return
if(no_trim)
return copytext(html_encode(name), 1, max_length)
return copytext(html_encode(user_input), 1, max_length)
else
return trim(html_encode(name), max_length) //trim is "outside" because html_encode can expand single symbols into multiple symbols (such as turning < into &lt;)
return trim(html_encode(user_input), max_length) //trim is "outside" because html_encode can expand single symbols into multiple symbols (such as turning < into &lt;)
// Used to get a properly sanitized multiline input, of max_length
/proc/stripped_multiline_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE)
var/name = input(user, message, title, default) as message|null
var/user_input = input(user, message, title, default) as message|null
if(isnull(user_input))
return
if(no_trim)
return copytext(html_encode(name), 1, max_length)
return copytext(html_encode(user_input), 1, max_length)
else
return trim(html_encode(name), max_length)
return trim(html_encode(user_input), max_length)
//Adds 'char' ahead of 'text' until there are 'count' characters total
/proc/add_leading(text, count, char = " ")