From 3959e07ffd9680c9a9efce7720435134ba073f85 Mon Sep 17 00:00:00 2001 From: Sam Tupy Date: Wed, 30 Oct 2024 23:12:48 -0500 Subject: [PATCH] add form.get_text_cursor and fix some whitespace trimming bugs in ini --- release/include/form.nvgt | 16 ++++++++++++++++ release/include/ini.nvgt | 2 ++ 2 files changed, 18 insertions(+) diff --git a/release/include/form.nvgt b/release/include/form.nvgt index db228d84..f70e4f56 100644 --- a/release/include/form.nvgt +++ b/release/include/form.nvgt @@ -1616,6 +1616,22 @@ class audio_form { } return c_form[control_index].text; } + int get_text_cursor(int control_index) { + form_error = 0; + if (!active) { + form_error = form_error_no_window; + return -1; + } + if ((control_index < 0) || (control_index > c_form.length() - 1)) { + form_error = form_error_invalid_index; + return -1; + } + if (c_form[control_index].type != ct_input) { + form_error = form_error_invalid_control; + return -1; + } + return c_form[control_index].cursor; + } bool set_text(int control_index, string new_text) { form_error = 0; if (!active) { diff --git a/release/include/ini.nvgt b/release/include/ini.nvgt index 810c202e..8227a125 100644 --- a/release/include/ini.nvgt +++ b/release/include/ini.nvgt @@ -146,6 +146,7 @@ class ini { if (is_escape) is_escape = false; } + identifier.trim_whitespace_right_this(); // So at this point string identifier contains the name of the new section, so add the previous one and start this one. this.sections.insert_last(tmp_section); if (tmp_section.name != "") { @@ -179,6 +180,7 @@ class ini { if (is_escape) is_escape = false; } + identifier.trim_whitespace_this(); // If an identifier was found, it's pretty safe to finally add the key to the section! if (found_identifier) tmp_section.set_string(identifier, value, true);