Rework symbol keyboard (fix illegal characters)

This commit is contained in:
Willy-JL
2023-04-23 15:32:03 +01:00
parent f351a1e7e8
commit c2791b459b

View File

@@ -102,16 +102,15 @@ static const TextInputKey keyboard_keys_row_3[] = {
};
static const TextInputKey symbol_keyboard_keys_row_1[] = {
{'!', 1, 8},
{'"', 10, 8},
{'#', 19, 8},
{'$', 28, 8},
{'%', 37, 8},
{'&', 46, 8},
{'/', 55, 8},
{'(', 64, 8},
{')', 73, 8},
{'=', 82, 8},
{'!', 2, 8},
{'@', 12, 8},
{'#', 22, 8},
{'$', 32, 8},
{'%', 42, 8},
{'^', 52, 8},
{'&', 62, 8},
{'(', 71, 8},
{')', 81, 8},
{'0', 91, 8},
{'1', 100, 8},
{'2', 110, 8},
@@ -119,15 +118,14 @@ static const TextInputKey symbol_keyboard_keys_row_1[] = {
};
static const TextInputKey symbol_keyboard_keys_row_2[] = {
{'{', 1, 20},
{'}', 10, 20},
{'[', 19, 20},
{']', 28, 20},
{'<', 37, 20},
{'>', 46, 20},
{'\\', 55, 20},
{'@', 64, 20},
{'?', 73, 20},
{'~', 2, 20},
{'+', 12, 20},
{'-', 22, 20},
{'=', 32, 20},
{'[', 42, 20},
{']', 52, 20},
{'{', 62, 20},
{'}', 72, 20},
{BACKSPACE_KEY, 82, 12},
{'4', 100, 20},
{'5', 110, 20},
@@ -136,14 +134,11 @@ static const TextInputKey symbol_keyboard_keys_row_2[] = {
static const TextInputKey symbol_keyboard_keys_row_3[] = {
{SWITCH_KEYBOARD_KEY, 1, 23},
{'+', 13, 32},
{'`', 21, 32},
{'\'', 28, 32},
{'^', 36, 32},
{'*', 44, 32},
{',', 52, 32},
{'.', 59, 32},
{'-', 67, 32},
{'.', 15, 32},
{',', 29, 32},
{';', 41, 32},
{'`', 53, 32},
{'\'', 65, 32},
{ENTER_KEY, 74, 23},
{'7', 100, 32},
{'8', 110, 32},
@@ -291,7 +286,7 @@ static void text_input_view_draw_callback(Canvas* canvas, void* _model) {
canvas_draw_str(canvas, start_pos, 22, "...");
start_pos += 6;
needed_string_width -= 8;
for(uint off = 0;
for(uint32_t off = 0;
!furi_string_empty(str) && canvas_string_width(canvas, cstr) > needed_string_width &&
off < model->cursor_pos;
off++) {
@@ -377,11 +372,16 @@ static void text_input_handle_up(TextInput* text_input, TextInputModel* model) {
UNUSED(text_input);
if(model->selected_row > 0) {
model->selected_row--;
if(model->selected_column >
get_row_size(keyboards[model->selected_keyboard], model->selected_row) - 6 &&
model->selected_row == 0) {
if(model->selected_row == 0 &&
model->selected_column > get_row_size(keyboards[model->selected_keyboard], model->selected_row) - 6) {
model->selected_column = model->selected_column + 1;
}
if(model->selected_row == 1 && model->selected_keyboard == symbol_keyboard.keyboard_index) {
if(model->selected_column > 5)
model->selected_column += 2;
else if(model->selected_column > 1)
model->selected_column += 1;
}
} else {
model->cursor_select = true;
model->clear_default_text = false;
@@ -394,11 +394,16 @@ static void text_input_handle_down(TextInput* text_input, TextInputModel* model)
model->cursor_select = false;
} else if(model->selected_row < keyboard_row_count - 1) {
model->selected_row++;
if(model->selected_column >
get_row_size(keyboards[model->selected_keyboard], model->selected_row) - 4 &&
model->selected_row == 1) {
if(model->selected_row == 1 &&
model->selected_column > get_row_size(keyboards[model->selected_keyboard], model->selected_row) - 4) {
model->selected_column = model->selected_column - 1;
}
if(model->selected_row == 2 && model->selected_keyboard == symbol_keyboard.keyboard_index) {
if(model->selected_column > 7)
model->selected_column -= 2;
else if(model->selected_column > 1)
model->selected_column -= 1;
}
}
}