X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flibgame%2Fgadgets.c;h=e788b754366263ee773818a0f8362cba0880f7a2;hb=4a0a9d29b36c9367444191a3e6c5ab9fc7b5ae4f;hp=fcfd235e509fa07a37a8ade24c17a3e2e6c90f81;hpb=0c5427e607bcc1b34dde35616d39c768fc4be184;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index fcfd235e..e788b754 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -2354,6 +2354,18 @@ boolean HandleGadgetsKeyInput(Key key) strcpy(text, gi->textinput.value); strcpy(&gi->textinput.value[cursor_pos], &text[cursor_pos + 1]); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); + } + else if (key == KSYM_Home && cursor_pos > 0) + { + gi->textinput.cursor_position = 0; + + DrawGadget(gi, DG_PRESSED, gi->direct_draw); + } + else if (key == KSYM_End && cursor_pos < text_length) + { + gi->textinput.cursor_position = text_length; + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } } @@ -2363,6 +2375,7 @@ boolean HandleGadgetsKeyInput(Key key) int text_length = strlen(gi->textarea.value); int area_ysize = gi->textarea.ysize; int cursor_x_pref = gi->textarea.cursor_x_preferred; + int cursor_x = gi->textarea.cursor_x; int cursor_y = gi->textarea.cursor_y; int cursor_pos = gi->textarea.cursor_position; char letter = getCharFromKey(key); @@ -2414,6 +2427,25 @@ boolean HandleGadgetsKeyInput(Key key) strcpy(text, gi->textarea.value); strcpy(&gi->textarea.value[cursor_pos], &text[cursor_pos + 1]); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); + } + else if (key == KSYM_Home && cursor_x > 0) + { + setTextAreaCursorPosition(gi, gi->textarea.cursor_position - cursor_x); + + DrawGadget(gi, DG_PRESSED, gi->direct_draw); + } + else if (key == KSYM_End && cursor_pos < text_length) + { + int last_cursor_pos = cursor_pos; + + while (gi->textarea.value[cursor_pos] != '\0' && + gi->textarea.value[cursor_pos] != '\n') + cursor_pos++; + + setTextAreaCursorPosition(gi, gi->textarea.cursor_position + cursor_pos - + last_cursor_pos); + DrawGadget(gi, DG_PRESSED, gi->direct_draw); } }