diff --git a/applications/archive/archive_views.c b/applications/archive/archive_views.c index 3cd66543..56e31971 100644 --- a/applications/archive/archive_views.c +++ b/applications/archive/archive_views.c @@ -48,7 +48,7 @@ static void render_item_menu(Canvas* canvas, ArchiveViewModel* model) { } void archive_trim_file_ext(string_t name) { - size_t str_len = strlen(string_get_cstr(name)); + size_t str_len = string_size(name); char* buff_ptr = stringi_get_cstr(name); char* end = buff_ptr + str_len; while(end > buff_ptr && *end != '.' && *end != '\\' && *end != '/') { diff --git a/applications/gui/elements.c b/applications/gui/elements.c index fd4e5d77..e0a667e5 100644 --- a/applications/gui/elements.c +++ b/applications/gui/elements.c @@ -184,11 +184,35 @@ void elements_multiline_text_aligned( do { end = strchr(start, '\n'); + if(end) { string_set_strn(str, start, end - start); } else { string_set_str(str, start); } + + uint16_t len_px = canvas_string_width(canvas, string_get_cstr(str)); + uint8_t px_left = + canvas_width(canvas) - (x - (horizontal == AlignCenter ? len_px / 2 : 0)); + + // hacky + if(len_px > px_left) { + string_t buff; + string_init_set(buff, str); + size_t s_len = string_size(str); + uint8_t end_pos = s_len - ((len_px - px_left) / (len_px / s_len) + 2); + + string_left(buff, end_pos); + string_cat(buff, "-"); + string_right(str, end_pos); + + canvas_draw_str_aligned(canvas, x, y, horizontal, vertical, string_get_cstr(buff)); + string_clear(buff); + + start = end + 1; + y += font_height; + } + canvas_draw_str_aligned(canvas, x, y, horizontal, vertical, string_get_cstr(str)); start = end + 1; y += font_height; @@ -271,7 +295,7 @@ void elements_string_fit_width(Canvas* canvas, string_t string, uint8_t width) { uint16_t len_px = canvas_string_width(canvas, string_get_cstr(string)); if(len_px > width) { - size_t s_len = strlen(string_get_cstr(string)); + size_t s_len = string_size(string); uint8_t end_pos = s_len - ((len_px - width) / ((len_px / s_len) + 2) + 2); string_mid(string, 0, end_pos); diff --git a/applications/gui/modules/file_select.c b/applications/gui/modules/file_select.c index a4a0db08..9c398865 100644 --- a/applications/gui/modules/file_select.c +++ b/applications/gui/modules/file_select.c @@ -40,7 +40,7 @@ static void file_select_draw_callback(Canvas* canvas, void* _model) { string_t string_buff; const uint8_t item_height = 16; const uint8_t item_width = 123; - const uint8_t max_width = 100; + const uint8_t text_max_width = 115; canvas_clear(canvas); canvas_set_font(canvas, FontSecondary); @@ -61,7 +61,7 @@ static void file_select_draw_callback(Canvas* canvas, void* _model) { } string_init_set(string_buff, model->filename[i]); - elements_string_fit_width(canvas, string_buff, max_width); + elements_string_fit_width(canvas, string_buff, text_max_width); canvas_draw_str( canvas, 6, (i * item_height) + item_height - 4, string_get_cstr(string_buff)); diff --git a/applications/ibutton/helpers/key-info.h b/applications/ibutton/helpers/key-info.h index 1eaf54c3..20ee7e1d 100644 --- a/applications/ibutton/helpers/key-info.h +++ b/applications/ibutton/helpers/key-info.h @@ -2,7 +2,7 @@ #include static const uint8_t IBUTTON_KEY_DATA_SIZE = 8; -static const uint8_t IBUTTON_KEY_NAME_SIZE = 64; +static const uint8_t IBUTTON_KEY_NAME_SIZE = 22; enum class iButtonKeyType : uint8_t { KeyDallas, diff --git a/applications/ibutton/scene/ibutton-scene-delete-confirm.cpp b/applications/ibutton/scene/ibutton-scene-delete-confirm.cpp index e7430fd7..622a377f 100644 --- a/applications/ibutton/scene/ibutton-scene-delete-confirm.cpp +++ b/applications/ibutton/scene/ibutton-scene-delete-confirm.cpp @@ -41,7 +41,7 @@ void iButtonSceneDeleteConfirm::on_enter(iButtonApp* app) { break; } - dialog_ex_set_text(dialog_ex, app->get_text_store(), 64, 26, AlignCenter, AlignCenter); + dialog_ex_set_text(dialog_ex, app->get_text_store(), 64, 20, AlignCenter, AlignCenter); dialog_ex_set_left_button_text(dialog_ex, "Back"); dialog_ex_set_right_button_text(dialog_ex, "Delete"); dialog_ex_set_result_callback(dialog_ex, callback); diff --git a/applications/ibutton/scene/ibutton-scene-emulate.cpp b/applications/ibutton/scene/ibutton-scene-emulate.cpp index 62839b54..598b5f26 100644 --- a/applications/ibutton/scene/ibutton-scene-emulate.cpp +++ b/applications/ibutton/scene/ibutton-scene-emulate.cpp @@ -51,17 +51,17 @@ void iButtonSceneEmulate::on_enter(iButtonApp* app) { switch(line_count) { case 3: - popup_set_header(popup, "iButton", 92, 18, AlignCenter, AlignBottom); - popup_set_text(popup, app->get_text_store(), 92, 22, AlignCenter, AlignTop); + popup_set_header(popup, "iButton", 82, 18, AlignCenter, AlignBottom); + popup_set_text(popup, app->get_text_store(), 82, 22, AlignCenter, AlignTop); break; default: - popup_set_header(popup, "iButton", 92, 24, AlignCenter, AlignBottom); - popup_set_text(popup, app->get_text_store(), 92, 28, AlignCenter, AlignTop); + popup_set_header(popup, "iButton", 82, 24, AlignCenter, AlignBottom); + popup_set_text(popup, app->get_text_store(), 82, 28, AlignCenter, AlignTop); break; } - popup_set_icon(popup, 10, 10, I_iButtonKey_49x44); + popup_set_icon(popup, 2, 10, I_iButtonKey_49x44); view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewPopup); app->get_key_worker()->start_emulate(app->get_key()); diff --git a/applications/ibutton/scene/ibutton-scene-save-name.cpp b/applications/ibutton/scene/ibutton-scene-save-name.cpp index 1bb614cf..04230332 100644 --- a/applications/ibutton/scene/ibutton-scene-save-name.cpp +++ b/applications/ibutton/scene/ibutton-scene-save-name.cpp @@ -22,7 +22,7 @@ void iButtonSceneSaveName::on_enter(iButtonApp* app) { text_input_set_header_text(text_input, "Name the key"); text_input_set_result_callback( - text_input, callback, app, app->get_text_store(), app->get_text_store_size()); + text_input, callback, app, app->get_text_store(), IBUTTON_KEY_NAME_SIZE); view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewTextInput); } diff --git a/applications/ibutton/scene/ibutton-scene-write-success.cpp b/applications/ibutton/scene/ibutton-scene-write-success.cpp index f66181a4..7c0b60ef 100644 --- a/applications/ibutton/scene/ibutton-scene-write-success.cpp +++ b/applications/ibutton/scene/ibutton-scene-write-success.cpp @@ -11,7 +11,7 @@ void iButtonSceneWriteSuccess::on_enter(iButtonApp* app) { auto callback = cbc::obtain_connector(this, &iButtonSceneWriteSuccess::popup_callback); popup_set_icon(popup, 0, 12, I_iButtonDolphinVerySuccess_108x52); - popup_set_text(popup, "Successful writing!", 47, 14, AlignLeft, AlignBottom); + popup_set_text(popup, "Successfully written!", 44, 14, AlignLeft, AlignBottom); popup_set_callback(popup, callback); popup_set_context(popup, app); diff --git a/applications/ibutton/scene/ibutton-scene-write.cpp b/applications/ibutton/scene/ibutton-scene-write.cpp index 6c109aa1..d05dd2c3 100644 --- a/applications/ibutton/scene/ibutton-scene-write.cpp +++ b/applications/ibutton/scene/ibutton-scene-write.cpp @@ -46,17 +46,17 @@ void iButtonSceneWrite::on_enter(iButtonApp* app) { switch(line_count) { case 3: - popup_set_header(popup, "iButton", 92, 18, AlignCenter, AlignBottom); - popup_set_text(popup, app->get_text_store(), 92, 22, AlignCenter, AlignTop); + popup_set_header(popup, "iButton", 82, 18, AlignCenter, AlignBottom); + popup_set_text(popup, app->get_text_store(), 82, 22, AlignCenter, AlignTop); break; default: - popup_set_header(popup, "iButton", 92, 24, AlignCenter, AlignBottom); - popup_set_text(popup, app->get_text_store(), 92, 28, AlignCenter, AlignTop); + popup_set_header(popup, "iButton", 82, 24, AlignCenter, AlignBottom); + popup_set_text(popup, app->get_text_store(), 82, 28, AlignCenter, AlignTop); break; } - popup_set_icon(popup, 10, 10, I_iButtonKey_49x44); + popup_set_icon(popup, 2, 10, I_iButtonKey_49x44); view_manager->switch_to(iButtonAppViewManager::Type::iButtonAppViewPopup); diff --git a/lib/args/args.c b/lib/args/args.c index e8953a86..59344a08 100644 --- a/lib/args/args.c +++ b/lib/args/args.c @@ -3,14 +3,14 @@ size_t args_get_first_word_length(string_t args) { size_t ws = string_search_char(args, ' '); if(ws == STRING_FAILURE) { - ws = strlen(string_get_cstr(args)); + ws = string_size(args); } return ws; } size_t args_length(string_t args) { - return strlen(string_get_cstr(args)); + return string_size(args); } bool args_read_string_and_trim(string_t args, string_t word) {