From 4c4c128faca10d54af6da25891b2fbbb2b8444e6 Mon Sep 17 00:00:00 2001 From: Aldrik Ramaekers Date: Thu, 6 Feb 2020 19:54:20 +0100 Subject: automated sync --- src/input.c | 2 ++ src/render.c | 2 ++ src/ui.c | 8 ++++++++ src/ui.h | 1 + 4 files changed, 13 insertions(+) diff --git a/src/input.c b/src/input.c index cd68ba5..b5253d2 100644 --- a/src/input.c +++ b/src/input.c @@ -152,6 +152,8 @@ void keyboard_handle_input_string(platform_window *window, keyboard_input *keybo if (ch) { + if (string_equals(ch, "\n")) is_lctrl_down = false; + if (keyboard->input_text_len < MAX_INPUT_LENGTH && !is_lctrl_down) { if (keyboard->has_selection) diff --git a/src/render.c b/src/render.c index 7f61ce8..2694da3 100644 --- a/src/render.c +++ b/src/render.c @@ -136,6 +136,7 @@ s32 render_text_with_selection(font *font, s32 x, s32 y, char *text, color tint, { ch = 0x3f; } + if (ch == '\n') ch = 0xB6; glyph g = font->glyphs[ch]; @@ -197,6 +198,7 @@ s32 render_text_with_cursor(font *font, s32 x, s32 y, char *text, color tint, s3 { ch = 0x3f; } + if (ch == '\n') ch = 0xB6; glyph g = font->glyphs[ch]; diff --git a/src/ui.c b/src/ui.c index 68807fd..a8242cd 100644 --- a/src/ui.c +++ b/src/ui.c @@ -52,6 +52,7 @@ inline textbox_state ui_create_textbox(u16 max_len) state.last_click_cursor_index = -1; state.attempting_to_select = false; state.deselect_on_enter = true; + state.accept_newline = false; return state; } @@ -654,6 +655,12 @@ bool ui_push_textbox(textbox_state *state, char *placeholder) global_ui_context.keyboard->has_selection = false; state->state = false; } + if (state->state && keyboard_is_key_down(global_ui_context.keyboard, KEY_LEFT_CONTROL) && + keyboard_is_key_pressed(global_ui_context.keyboard, KEY_ENTER) && + state->accept_newline) + { + keyboard_handle_input_string(global_ui_context.layout.active_window, global_ui_context.keyboard, "\n"); + } // calculate scissor rectangle if (global_ui_context.layout.scroll->in_scroll) @@ -763,6 +770,7 @@ bool ui_push_textbox(textbox_state *state, char *placeholder) } string_copyn(state->buffer, global_ui_context.keyboard->input_text, state->max_len); + if (global_ui_context.keyboard->cursor > state->max_len) { global_ui_context.keyboard->cursor = state->max_len; diff --git a/src/ui.h b/src/ui.h index cbac631..02655b4 100644 --- a/src/ui.h +++ b/src/ui.h @@ -108,6 +108,7 @@ typedef struct t_textbox_history_entry typedef struct t_textbox_state { bool deselect_on_enter; + bool accept_newline; char *buffer; s32 selection_start_index; bool state; -- cgit v1.2.3-70-g09d2