diff options
author | Joursoir <chat@joursoir.net> | 2021-12-15 15:08:09 +0300 |
---|---|---|
committer | Joursoir <chat@joursoir.net> | 2021-12-15 15:08:09 +0300 |
commit | 8d1a606a1260f32e1e49b3d1d4f35c51b7dc8742 (patch) | |
tree | 1e4a0789b4790ae56e9c77b311a8c3d75bb44d58 /Library/UefiShellUfmCommandLib/widget/input.c | |
parent | 07a1c8f9511cfac7202904a4e07e6f9f8a228d06 (diff) | |
download | ufm-8d1a606a1260f32e1e49b3d1d4f35c51b7dc8742.tar.gz ufm-8d1a606a1260f32e1e49b3d1d4f35c51b7dc8742.tar.bz2 ufm-8d1a606a1260f32e1e49b3d1d4f35c51b7dc8742.zip |
widget/input: copy the define text to the buffer
Diffstat (limited to 'Library/UefiShellUfmCommandLib/widget/input.c')
-rw-r--r-- | Library/UefiShellUfmCommandLib/widget/input.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Library/UefiShellUfmCommandLib/widget/input.c b/Library/UefiShellUfmCommandLib/widget/input.c index 7531321..3fbb1b2 100644 --- a/Library/UefiShellUfmCommandLib/widget/input.c +++ b/Library/UefiShellUfmCommandLib/widget/input.c @@ -8,6 +8,7 @@ struct widget_input *input_alloc(struct screen *scr, INT32 x, INT32 y, INT32 width, INT32 attr, CONST CHAR16 *def_text) { struct widget_input *in; + UINTN text_length; ASSERT(scr != NULL); @@ -24,10 +25,11 @@ struct widget_input *input_alloc(struct screen *scr, INT32 x, INT32 y, whline(in->win, 0, 0, 0, attr, 0); mvwprintf(in->win, 0, 0, def_text); - in->point = 0; + text_length = StrLen(def_text); + in->point = text_length > width ? width : text_length; in->max_size = width; - in->buf_len = 0; - in->buffer = AllocateZeroPool((in->max_size + 1) * sizeof(CHAR16)); + in->buf_len = in->point; + in->buffer = AllocateCopyPool((in->max_size + 1) * sizeof(CHAR16), def_text); if(!in->buffer) { input_release(in); return NULL; |