mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
[MIRROR] Ports TGStation fix to text input trimming (#7973)
Co-authored-by: Runa Dacino <dacinoorder@gmail.com> Co-authored-by: CHOMPStation2 <chompsation2@gmail.com>
This commit is contained in:
10
code/__defines/text.dm
Normal file
10
code/__defines/text.dm
Normal file
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Holds global defines for use in text input procedures
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* stuff like `copytext(input, length(input))` will trim the last character of the input,
|
||||
* because DM does it so it copies until the char BEFORE the `end` arg, so we need to bump `end` by 1 in these cases.
|
||||
*/
|
||||
#define PREVENT_CHARACTER_TRIM_LOSS(integer) (integer + 1)
|
||||
@@ -32,9 +32,9 @@
|
||||
if(!user.client.prefs.tgui_input_mode)
|
||||
if(encode)
|
||||
if(multiline)
|
||||
return stripped_multiline_input(user, message, title, default, max_length)
|
||||
return stripped_multiline_input(user, message, title, default, PREVENT_CHARACTER_TRIM_LOSS(max_length))
|
||||
else
|
||||
return stripped_input(user, message, title, default, max_length)
|
||||
return stripped_input(user, message, title, default, PREVENT_CHARACTER_TRIM_LOSS(max_length))
|
||||
else
|
||||
if(multiline)
|
||||
return input(user, message, title, default) as message|null
|
||||
@@ -159,4 +159,4 @@
|
||||
/datum/tgui_input_text/proc/set_entry(entry)
|
||||
if(!isnull(entry))
|
||||
var/converted_entry = encode ? html_encode(entry) : entry
|
||||
src.entry = trim(converted_entry, max_length)
|
||||
src.entry = trim(converted_entry, PREVENT_CHARACTER_TRIM_LOSS(max_length))
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
#include "code\__defines\subsystems.dm"
|
||||
#include "code\__defines\supply.dm"
|
||||
#include "code\__defines\targeting.dm"
|
||||
#include "code\__defines\text.dm"
|
||||
#include "code\__defines\tgs.config.dm"
|
||||
#include "code\__defines\tgs.dm"
|
||||
#include "code\__defines\tgui.dm"
|
||||
|
||||
Reference in New Issue
Block a user