X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fgadgets.c;h=94fe74551cdd58ed60a001afd742c412cc2e1735;hb=e89a21e95b3cb84d1515c0fb3378ce902a48c1c8;hp=fcfd235e509fa07a37a8ade24c17a3e2e6c90f81;hpb=e567cb7fd1d4e5b41778326253f736f6f30f14c5;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index fcfd235e..94fe7455 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -1629,8 +1629,7 @@ void ClickOnGadget(struct GadgetInfo *gi, int button) boolean HandleGadgets(int mx, int my, int button) { - static unsigned int pressed_delay = 0; - static unsigned int pressed_delay_value = GADGET_FRAME_DELAY; + static DelayCounter pressed_delay = { GADGET_FRAME_DELAY }; static int last_button = 0; static int last_mx = 0, last_my = 0; static int pressed_mx = 0, pressed_my = 0; @@ -1756,7 +1755,7 @@ boolean HandleGadgets(int mx, int my, int button) (button != 0 && last_gi != NULL && new_gi == last_gi); gadget_pressed_delay_reached = - DelayReached(&pressed_delay, pressed_delay_value); + DelayReached(&pressed_delay); gadget_released = (release_event && last_gi != NULL); gadget_released_inside = (gadget_released && new_gi == last_gi); @@ -1937,12 +1936,12 @@ boolean HandleGadgets(int mx, int my, int button) ResetDelayCounter(&pressed_delay); // start gadget delay with longer delay after first click on gadget - pressed_delay_value = GADGET_FRAME_DELAY_FIRST; + pressed_delay.value = GADGET_FRAME_DELAY_FIRST; } else // gadget hold pressed for some time { // after first repeated gadget click, continue with shorter delay value - pressed_delay_value = GADGET_FRAME_DELAY; + pressed_delay.value = GADGET_FRAME_DELAY; } if (gi->type & GD_TYPE_SCROLLBAR && !gadget_dragging) @@ -2354,6 +2353,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 +2374,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 +2426,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); } }