mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-26 05:54:46 -07:00
Update text_input.c
This commit is contained in:
@@ -138,7 +138,7 @@ static bool char_is_lowercase(char letter) {
|
||||
static char char_to_uppercase(const char letter) {
|
||||
if(letter == '_') {
|
||||
return 0x20;
|
||||
} else if(islower(letter)) {
|
||||
} else if(isalpha(letter)) {
|
||||
return (letter - 0x20);
|
||||
} else {
|
||||
return letter;
|
||||
@@ -309,9 +309,7 @@ static void text_input_handle_ok(TextInput* text_input, TextInputModel* model, b
|
||||
char selected = get_selected_char(model);
|
||||
size_t text_length = strlen(model->text_buffer);
|
||||
|
||||
bool toogle_case = text_length == 0;
|
||||
if(shift) toogle_case = !toogle_case;
|
||||
if(toogle_case) {
|
||||
if(shift) {
|
||||
selected = char_to_uppercase(selected);
|
||||
}
|
||||
|
||||
@@ -331,6 +329,9 @@ static void text_input_handle_ok(TextInput* text_input, TextInputModel* model, b
|
||||
text_length = 0;
|
||||
}
|
||||
if(text_length < (model->text_buffer_size - 1)) {
|
||||
if(text_length == 0 && char_is_lowercase(selected)) {
|
||||
selected = char_to_uppercase(selected);
|
||||
}
|
||||
model->text_buffer[text_length] = selected;
|
||||
model->text_buffer[text_length + 1] = 0;
|
||||
}
|
||||
@@ -567,4 +568,4 @@ void* text_input_get_validator_callback_context(TextInput* text_input) {
|
||||
void text_input_set_header_text(TextInput* text_input, const char* text) {
|
||||
with_view_model(
|
||||
text_input->view, TextInputModel * model, { model->header = text; }, true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user