Skip to content

bugfix: tgui input text более не обрезает переносы строки в начале ввода #6526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code/modules/admin/verbs/modifyvariables.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion code/modules/paperwork/paper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
15 changes: 9 additions & 6 deletions code/modules/tgui/tgui_input/text_input.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)