From 04965ae9d218c24c33220dae7f60503e003ff763 Mon Sep 17 00:00:00 2001 From: Duncan Frost Date: Thu, 16 Oct 2014 21:50:03 +0100 Subject: [PATCH] Added home, end key. Now uses host window colours. --- src/input.c | 3 +-- src/platform/osinterface.c | 6 ++++++ src/windows/text_input.c | 18 +++++++++--------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/input.c b/src/input.c index d68d2ab269..4a97219c64 100644 --- a/src/input.c +++ b/src/input.c @@ -1631,8 +1631,7 @@ void game_handle_keyboard_input() else{ w = window_find_by_class(WC_TEXTINPUT); if (w != NULL){ - void(*fp)(int, rct_window*) = (void*)(int)w->event_handlers[WE_TEXT_INPUT]; - (*fp)(key,w); + ((void(*)(int, rct_window*))w->event_handlers[WE_TEXT_INPUT])(key,w); } else{ handle_shortcut(key); diff --git a/src/platform/osinterface.c b/src/platform/osinterface.c index 22e3069c15..3a64ca9abe 100644 --- a/src/platform/osinterface.c +++ b/src/platform/osinterface.c @@ -437,6 +437,12 @@ void osinterface_process_messages() gTextInputCursorPosition--; gTextInputLength--; } + if (e.key.keysym.sym == SDLK_END){ + gTextInputCursorPosition = gTextInputLength; + } + if (e.key.keysym.sym == SDLK_HOME){ + gTextInputCursorPosition = 0; + } if (e.key.keysym.sym == SDLK_DELETE && gTextInputLength > 0 && gTextInput && gTextInputCursorPosition != gTextInputLength){ memmove(gTextInput + gTextInputCursorPosition, gTextInput + gTextInputCursorPosition + 1, gTextInputMaxLength - gTextInputCursorPosition - 1); gTextInput[gTextInputMaxLength - 1] = '\0'; diff --git a/src/windows/text_input.c b/src/windows/text_input.c index 237e6d34c4..cba850a4f5 100644 --- a/src/windows/text_input.c +++ b/src/windows/text_input.c @@ -46,11 +46,11 @@ enum WINDOW_TEXT_INPUT_WIDGET_IDX { // 0x9DE4E0 static rct_widget window_text_input_widgets[] = { - { WWT_FRAME, 0, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE }, - { WWT_CAPTION, 0, 1, WW - 2, 1, 14, STR_OPTIONS, STR_WINDOW_TITLE_TIP }, - { WWT_CLOSEBOX, 0, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, - { WWT_DROPDOWN_BUTTON, 0, WW - 80, WW - 10, WH - 21, WH - 10, STR_CANCEL, STR_NONE }, - { WWT_DROPDOWN_BUTTON, 0, 10, 80, WH - 21, WH - 10, STR_OK, STR_NONE }, + { WWT_FRAME, 1, 0, WW - 1, 0, WH - 1, STR_NONE, STR_NONE }, + { WWT_CAPTION, 1, 1, WW - 2, 1, 14, STR_OPTIONS, STR_WINDOW_TITLE_TIP }, + { WWT_CLOSEBOX, 1, WW - 13, WW - 3, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, + { WWT_DROPDOWN_BUTTON, 1, WW - 80, WW - 10, WH - 21, WH - 10, STR_CANCEL, STR_NONE }, + { WWT_DROPDOWN_BUTTON, 1, 10, 80, WH - 21, WH - 10, STR_OK, STR_NONE }, { WIDGETS_END } }; @@ -136,9 +136,9 @@ void window_text_input_open(rct_window* call_w, int call_widget, rct_string_id t osinterface_start_text_input(text_input, MAX_TEXTINPUT); window_init_scroll_widgets(w); - w->colours[0] = 7; - w->colours[1] = 7; - w->colours[2] = 1; + w->colours[0] = call_w->colours[0]; + w->colours[1] = call_w->colours[1]; + w->colours[2] = call_w->colours[2]; } /** @@ -192,7 +192,7 @@ static void window_text_input_paint(){ gfx_fill_rect_inset(dpi, w->x + 10, y, w->x + WW - 10, y + 12, w->colours[1], 0x60); y += 1; - gfx_draw_string(dpi, text_input, w->colours[2], w->x + 12, y); + gfx_draw_string(dpi, text_input, w->colours[1], w->x + 12, y); // Make a copy of the string for measuring the width. char temp_string[32] = { 0 };