From 45c8395839e1bf11750e5caaaa01db9a0310dc99 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Fri, 14 Nov 2025 19:03:01 +0000 Subject: [PATCH] fix bug git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@725 b9cfdab3-6d41-4d17-bbe4-086880011989 --- include/Mw/TypeDefs.h | 1 + src/dialog/colorpicker.c | 4 ++-- src/dialog/filechooser.c | 4 ++-- src/widget/entry.c | 14 ++++++++++++++ src/widget/listbox.c | 2 ++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/include/Mw/TypeDefs.h b/include/Mw/TypeDefs.h index 2767b3f..ee6b4ff 100644 --- a/include/Mw/TypeDefs.h +++ b/include/Mw/TypeDefs.h @@ -102,6 +102,7 @@ struct _MwMenu { struct _MwEntry { int cursor; int right; + int length; MwPoint mouse; }; diff --git a/src/dialog/colorpicker.c b/src/dialog/colorpicker.c index 6f49e9d..ff5c383 100644 --- a/src/dialog/colorpicker.c +++ b/src/dialog/colorpicker.c @@ -343,8 +343,8 @@ MwWidget MwColorPicker(MwWidget handle, const char* title) { color_picker_t* wheel; MwWidget window; MwSizeHints sh; - int ww = MwGetInteger(handle, MwNwidth); - int wh = MwGetInteger(handle, MwNheight); + int ww = handle == NULL ? 0 : MwGetInteger(handle, MwNwidth); + int wh = handle == NULL ? 0 : MwGetInteger(handle, MwNheight); int wx; int wy; diff --git a/src/dialog/filechooser.c b/src/dialog/filechooser.c index c334afc..519e956 100644 --- a/src/dialog/filechooser.c +++ b/src/dialog/filechooser.c @@ -459,8 +459,8 @@ static void scan(MwWidget handle, const char* path, int record) { MwWidget MwFileChooser(MwWidget handle, const char* title) { MwWidget window; MwPoint p; - int ww = MwGetInteger(handle, MwNwidth); - int wh = MwGetInteger(handle, MwNheight); + int ww = handle == NULL ? 0 : MwGetInteger(handle, MwNwidth); + int wh = handle == NULL ? 0 : MwGetInteger(handle, MwNheight); int w, h; filechooser_t* fc = malloc(sizeof(*fc)); char* path; diff --git a/src/widget/entry.c b/src/widget/entry.c index e14c180..c012e9e 100644 --- a/src/widget/entry.c +++ b/src/widget/entry.c @@ -6,6 +6,7 @@ static int create(MwWidget handle) { t->cursor = 0; t->right = 0; + t->length = 0; handle->internal = t; MwSetDefault(handle); @@ -135,11 +136,24 @@ static void key(MwWidget handle, int code) { free(out); } + t->length = MwUTF8Length(MwGetText(handle, MwNtext)); + MwForceRender(handle); } static void prop_change(MwWidget handle, const char* prop) { if(strcmp(prop, MwNtext) == 0 || strcmp(prop, MwNhideInput) == 0) MwForceRender(handle); + + if(strcmp(prop, MwNtext) == 0) { + MwEntry t = handle->internal; + int len = MwUTF8Length(MwGetText(handle, MwNtext)); + if(len < t->cursor) { + t->cursor = len; + } else if(t->length == t->cursor) { + t->cursor = len; + } + t->length = len; + } } MwClassRec MwEntryClassRec = { diff --git a/src/widget/listbox.c b/src/widget/listbox.c index 09717e9..f0058eb 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -458,6 +458,8 @@ static void mwListBoxResetImpl(MwWidget handle) { lb->selected = -1; + MwSetInteger(lb->vscroll, MwNvalue, 0); + resize(handle); MwForceRender(lb->frame); }