Browse Source

Merge pull request #486 from Immediate-Mode-UI/shift-end

Fix Shift + End in nk_edit
Rob Loach 3 years ago
parent
commit
93a057b3fe
4 changed files with 7 additions and 3 deletions
  1. 1 1
      clib.json
  2. 3 1
      nuklear.h
  3. 2 0
      src/CHANGELOG
  4. 1 1
      src/nuklear_text_editor.c

+ 1 - 1
clib.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "nuklear",
   "name": "nuklear",
-  "version": "4.9.6",
+  "version": "4.10.1",
   "repo": "Immediate-Mode-UI/Nuklear",
   "repo": "Immediate-Mode-UI/Nuklear",
   "description": "A small ANSI C gui toolkit",
   "description": "A small ANSI C gui toolkit",
   "keywords": ["gl", "ui", "toolkit"],
   "keywords": ["gl", "ui", "toolkit"],

+ 3 - 1
nuklear.h

@@ -26162,7 +26162,7 @@ nk_textedit_text(struct nk_text_edit *state, const char *text, int total_len)
                                         text+text_len, 1))
                                         text+text_len, 1))
             {
             {
                 nk_textedit_makeundo_insert(state, state->cursor, 1);
                 nk_textedit_makeundo_insert(state, state->cursor, 1);
-                ++state->cursor;
+                state->cursor = NK_MIN(state->cursor + 1, state->string.len);
                 state->has_preferred_x = 0;
                 state->has_preferred_x = 0;
             }
             }
         }
         }
@@ -29656,6 +29656,8 @@ nk_tooltipfv(struct nk_context *ctx, const char *fmt, va_list args)
 ///   - [y]: Minor version with non-breaking API and library changes
 ///   - [y]: Minor version with non-breaking API and library changes
 ///   - [z]: Patch version with no direct changes to the API
 ///   - [z]: Patch version with no direct changes to the API
 ///
 ///
+/// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than
+///                         nk_edit_xxx limit
 /// - 2022/05/27 (4.10.0) - Add nk_input_has_mouse_click_in_button_rect() to fix window move bug
 /// - 2022/05/27 (4.10.0) - Add nk_input_has_mouse_click_in_button_rect() to fix window move bug
 /// - 2022/04/18 (4.9.7)  - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to
 /// - 2022/04/18 (4.9.7)  - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to
 ///                         only trigger when the mouse position was inside the same button on down
 ///                         only trigger when the mouse position was inside the same button on down

+ 2 - 0
src/CHANGELOG

@@ -7,6 +7,8 @@
 ///   - [y]: Minor version with non-breaking API and library changes
 ///   - [y]: Minor version with non-breaking API and library changes
 ///   - [z]: Patch version with no direct changes to the API
 ///   - [z]: Patch version with no direct changes to the API
 ///
 ///
+/// - 2022/08/01 (4.10.1) - Fix cursor jumping back to beginning of text when typing more than
+///                         nk_edit_xxx limit
 /// - 2022/05/27 (4.10.0) - Add nk_input_has_mouse_click_in_button_rect() to fix window move bug
 /// - 2022/05/27 (4.10.0) - Add nk_input_has_mouse_click_in_button_rect() to fix window move bug
 /// - 2022/04/18 (4.9.7)  - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to
 /// - 2022/04/18 (4.9.7)  - Change button behavior when NK_BUTTON_TRIGGER_ON_RELEASE is defined to
 ///                         only trigger when the mouse position was inside the same button on down
 ///                         only trigger when the mouse position was inside the same button on down

+ 1 - 1
src/nuklear_text_editor.c

@@ -394,7 +394,7 @@ nk_textedit_text(struct nk_text_edit *state, const char *text, int total_len)
                                         text+text_len, 1))
                                         text+text_len, 1))
             {
             {
                 nk_textedit_makeundo_insert(state, state->cursor, 1);
                 nk_textedit_makeundo_insert(state, state->cursor, 1);
-                ++state->cursor;
+                state->cursor = NK_MIN(state->cursor + 1, state->string.len);
                 state->has_preferred_x = 0;
                 state->has_preferred_x = 0;
             }
             }
         }
         }