From cfebeede6013d926170da3a646965c115911a647 Mon Sep 17 00:00:00 2001 From: dageavtobusnick <71216640+dageavtobusnick@users.noreply.github.com> Date: Mon, 3 Feb 2025 22:48:43 +0500 Subject: [PATCH 1/2] =?UTF-8?q?bugfix:=20tgui=20input=20text=20=D0=B1?= =?UTF-8?q?=D0=BE=D0=BB=D0=B5=D0=B5=20=D0=BD=D0=B5=20=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B5=D0=B7=D0=B0=D0=B5=D1=82=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=8B=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=B5=20=D0=B2=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/modules/admin/verbs/modifyvariables.dm | 10 +++++----- code/modules/paperwork/paper.dm | 2 +- code/modules/tgui/tgui_input/text_input.dm | 15 +++++++++------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/code/modules/admin/verbs/modifyvariables.dm b/code/modules/admin/verbs/modifyvariables.dm index 63968a02d10..82a97653f8d 100644 --- a/code/modules/admin/verbs/modifyvariables.dm +++ b/code/modules/admin/verbs/modifyvariables.dm @@ -96,12 +96,12 @@ GLOBAL_LIST_INIT(VVpixelmovement, list("step_x", "step_y", "step_size", "bound_h switch(.["class"]) if(VV_TEXT) - .["value"] = tgui_input_text(src, "Введите текст:", "Текст", current_value, encode = FALSE) + .["value"] = tgui_input_text(src, "Введите текст:", "Текст", current_value, encode = FALSE, trim = FALSE) if(.["value"] == null) .["class"] = null return if(VV_MESSAGE) - .["value"] = tgui_input_text(src, "Введите текст:", "Текст", current_value, multiline = TRUE, encode = FALSE) + .["value"] = tgui_input_text(src, "Введите текст:", "Текст", current_value, multiline = TRUE, encode = FALSE, trim = FALSE) if(.["value"] == null) .["class"] = null return @@ -236,7 +236,7 @@ GLOBAL_LIST_INIT(VVpixelmovement, list("step_x", "step_y", "step_size", "bound_h return .["type"] = type var/list/arguments - + if(tgui_alert(usr, "Вы хотите добавить аргументы?", "Новый атом", list("Да", "Нет")) == "Да") arguments = get_callproc_args(FALSE) else @@ -252,7 +252,7 @@ GLOBAL_LIST_INIT(VVpixelmovement, list("step_x", "step_y", "step_size", "bound_h return .["type"] = type var/list/arguments - + if(tgui_alert(usr, "Вы хотите добавить аргументы?", "Новый атом", list("Да", "Нет")) == "Да") arguments = get_callproc_args(FALSE) else @@ -272,7 +272,7 @@ GLOBAL_LIST_INIT(VVpixelmovement, list("step_x", "step_y", "step_size", "bound_h .["type"] = type var/list/arguments - + if(tgui_alert(usr, "Вы хотите добавить аргументы?", "Новый атом", list("Да", "Нет")) == "Да") arguments = get_callproc_args(FALSE) else diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index e36f506ad95..93fc4b8d0fa 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -438,7 +438,7 @@ if(href_list["write"] ) var/id = href_list["write"] /* Becаuse HTML */ - var/input_element = tgui_input_text(usr, "Enter what you want to write:", "Write", multiline = TRUE, max_length = 3000, encode = FALSE) //as message + var/input_element = tgui_input_text(usr, "Enter what you want to write:", "Write", multiline = TRUE, max_length = 3000, encode = FALSE, trim = FALSE) topic_href_write(usr, id, input_element) diff --git a/code/modules/tgui/tgui_input/text_input.dm b/code/modules/tgui/tgui_input/text_input.dm index 128232df71a..249aafdac36 100644 --- a/code/modules/tgui/tgui_input/text_input.dm +++ b/code/modules/tgui/tgui_input/text_input.dm @@ -15,7 +15,7 @@ * * encode - Toggling this determines if input is filtered via html_encode. Setting this to FALSE gives raw input. * * timeout - The timeout of the textbox, after which the modal will close and qdel itself. Set to zero for no timeout. */ -/proc/tgui_input_text(mob/user, message = "", title = "Text Input", default, max_length = MAX_MESSAGE_LEN, multiline = FALSE, encode = TRUE, timeout = 0, ui_state = GLOB.always_state) +/proc/tgui_input_text(mob/user, message = "", title = "Text Input", default, max_length = MAX_MESSAGE_LEN, multiline = FALSE, encode = TRUE, trim = TRUE, timeout = 0, ui_state = GLOB.always_state) if(!user) user = usr @@ -32,16 +32,16 @@ if(user.client?.prefs?.toggles2 & PREFTOGGLE_2_DISABLE_TGUI_INPUT) if(encode) if(multiline) - return stripped_multiline_input(user, message, title, default, max_length) + return stripped_multiline_input(user, message, title, default, max_length, !trim) else - return stripped_input(user, message, title, default, max_length) + return stripped_input(user, message, title, default, max_length, !trim) else if(multiline) return input(user, message, title, default) as message|null else return input(user, message, title, default) as text|null - var/datum/tgui_input_text/text_input = new(user, message, title, default, max_length, multiline, encode, timeout, ui_state) + var/datum/tgui_input_text/text_input = new(user, message, title, default, max_length, multiline, encode, trim, timeout, ui_state) text_input.ui_interact(user) text_input.wait() @@ -62,6 +62,8 @@ var/default /// Whether the input should be stripped using html_encode var/encode + /// Whether the input should be trimmed from whitespaces + var/trim /// The entry that the user has return_typed in. var/entry /// The maximum length for text entry @@ -81,9 +83,10 @@ /// The TGUI UI state that will be returned in ui_state(). Default: always_state var/datum/ui_state/state -/datum/tgui_input_text/New(mob/user, message, title, default, max_length, multiline, encode, timeout, ui_state) +/datum/tgui_input_text/New(mob/user, message, title, default, max_length, multiline, encode, trim, timeout, ui_state) src.default = default src.encode = encode + src.trim = trim src.max_length = max_length src.message = message src.multiline = multiline @@ -171,4 +174,4 @@ return var/converted_entry = encode ? html_encode(entry) : entry - src.entry = trim(converted_entry, max_length + 1) + src.entry = trim? trim(converted_entry, max_length + 1) : trim_length(converted_entry, max_length + 1) From 151497b8885a8fce79b456c22039ac2bf69d9f22 Mon Sep 17 00:00:00 2001 From: dageavtobusnick <71216640+dageavtobusnick@users.noreply.github.com> Date: Sat, 8 Feb 2025 16:28:42 +0500 Subject: [PATCH 2/2] Update code/modules/tgui/tgui_input/text_input.dm Co-authored-by: BeebBeebBoob --- code/modules/tgui/tgui_input/text_input.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/tgui/tgui_input/text_input.dm b/code/modules/tgui/tgui_input/text_input.dm index 249aafdac36..810f678c806 100644 --- a/code/modules/tgui/tgui_input/text_input.dm +++ b/code/modules/tgui/tgui_input/text_input.dm @@ -174,4 +174,4 @@ return var/converted_entry = encode ? html_encode(entry) : entry - src.entry = trim? trim(converted_entry, max_length + 1) : trim_length(converted_entry, max_length + 1) + src.entry = trim ? trim(converted_entry, max_length + 1) : trim_length(converted_entry, max_length + 1)