M*LIB: non-inlined strings, FuriString primitive (#1795)
* Quicksave 1 * Header stage complete * Source stage complete * Lint & merge fixes * Includes * Documentation step 1 * FBT: output free size considering BT STACK * Documentation step 2 * py lint * Fix music player plugin * unit test stage 1: string allocator, mem, getters, setters, appends, compare, search. * unit test: string equality * unit test: string replace * unit test: string start_with, end_with * unit test: string trim * unit test: utf-8 * Rename * Revert fw_size changes * Simplify CLI backspace handling * Simplify CLI character insert * Merge fixes * Furi: correct filenaming and spelling * Bt: remove furi string include Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
#include <gui/gui.h>
|
||||
#include <gui/view_dispatcher.h>
|
||||
#include <gui/modules/empty_screen.h>
|
||||
#include <m-string.h>
|
||||
#include <furi_hal_version.h>
|
||||
#include <furi_hal_region.h>
|
||||
#include <furi_hal_bt.h>
|
||||
@@ -78,11 +77,11 @@ static DialogMessageButton icon2_screen(DialogsApp* dialogs, DialogMessage* mess
|
||||
|
||||
static DialogMessageButton hw_version_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
string_t buffer;
|
||||
string_init(buffer);
|
||||
FuriString* buffer;
|
||||
buffer = furi_string_alloc();
|
||||
const char* my_name = furi_hal_version_get_name_ptr();
|
||||
|
||||
string_cat_printf(
|
||||
furi_string_cat_printf(
|
||||
buffer,
|
||||
"%d.F%dB%dC%d %s:%s %s\n",
|
||||
furi_hal_version_get_hw_version(),
|
||||
@@ -93,26 +92,26 @@ static DialogMessageButton hw_version_screen(DialogsApp* dialogs, DialogMessage*
|
||||
furi_hal_region_get_name(),
|
||||
my_name ? my_name : "Unknown");
|
||||
|
||||
string_cat_printf(buffer, "Serial Number:\n");
|
||||
furi_string_cat_printf(buffer, "Serial Number:\n");
|
||||
const uint8_t* uid = furi_hal_version_uid();
|
||||
for(size_t i = 0; i < furi_hal_version_uid_size(); i++) {
|
||||
string_cat_printf(buffer, "%02X", uid[i]);
|
||||
furi_string_cat_printf(buffer, "%02X", uid[i]);
|
||||
}
|
||||
|
||||
dialog_message_set_header(message, "HW Version Info:", 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, string_get_cstr(buffer), 0, 13, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, furi_string_get_cstr(buffer), 0, 13, AlignLeft, AlignTop);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_text(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_header(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
string_clear(buffer);
|
||||
furi_string_free(buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static DialogMessageButton fw_version_screen(DialogsApp* dialogs, DialogMessage* message) {
|
||||
DialogMessageButton result;
|
||||
string_t buffer;
|
||||
string_init(buffer);
|
||||
FuriString* buffer;
|
||||
buffer = furi_string_alloc();
|
||||
const Version* ver = furi_hal_version_get_firmware_version();
|
||||
const BleGlueC2Info* c2_ver = NULL;
|
||||
#ifdef SRV_BT
|
||||
@@ -120,9 +119,9 @@ static DialogMessageButton fw_version_screen(DialogsApp* dialogs, DialogMessage*
|
||||
#endif
|
||||
|
||||
if(!ver) {
|
||||
string_cat_printf(buffer, "No info\n");
|
||||
furi_string_cat_printf(buffer, "No info\n");
|
||||
} else {
|
||||
string_cat_printf(
|
||||
furi_string_cat_printf(
|
||||
buffer,
|
||||
"%s [%s]\n%s%s [%s] %s\n[%d] %s",
|
||||
version_get_version(ver),
|
||||
@@ -136,11 +135,11 @@ static DialogMessageButton fw_version_screen(DialogsApp* dialogs, DialogMessage*
|
||||
}
|
||||
|
||||
dialog_message_set_header(message, "FW Version Info:", 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, string_get_cstr(buffer), 0, 13, AlignLeft, AlignTop);
|
||||
dialog_message_set_text(message, furi_string_get_cstr(buffer), 0, 13, AlignLeft, AlignTop);
|
||||
result = dialog_message_show(dialogs, message);
|
||||
dialog_message_set_text(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
dialog_message_set_header(message, NULL, 0, 0, AlignLeft, AlignTop);
|
||||
string_clear(buffer);
|
||||
furi_string_free(buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@@ -92,19 +92,19 @@ static void storage_settings_scene_benchmark(StorageSettings* app) {
|
||||
app->fs_api, bench_size[i], bench_data, &bench_w_speed[i]))
|
||||
break;
|
||||
|
||||
if(i > 0) string_cat_printf(app->text_string, "\n");
|
||||
string_cat_printf(app->text_string, "%ub : W %luK ", bench_size[i], bench_w_speed[i]);
|
||||
if(i > 0) furi_string_cat_printf(app->text_string, "\n");
|
||||
furi_string_cat_printf(app->text_string, "%ub : W %luK ", bench_size[i], bench_w_speed[i]);
|
||||
dialog_ex_set_header(dialog_ex, NULL, 0, 0, AlignCenter, AlignCenter);
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter);
|
||||
dialog_ex, furi_string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter);
|
||||
|
||||
if(!storage_settings_scene_bench_read(
|
||||
app->fs_api, bench_size[i], bench_data, &bench_r_speed[i]))
|
||||
break;
|
||||
|
||||
string_cat_printf(app->text_string, "R %luK", bench_r_speed[i]);
|
||||
furi_string_cat_printf(app->text_string, "R %luK", bench_r_speed[i]);
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter);
|
||||
dialog_ex, furi_string_get_cstr(app->text_string), 0, 32, AlignLeft, AlignCenter);
|
||||
}
|
||||
|
||||
free(bench_data);
|
||||
@@ -159,5 +159,5 @@ void storage_settings_scene_benchmark_on_exit(void* context) {
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
|
||||
string_reset(app->text_string);
|
||||
furi_string_reset(app->text_string);
|
||||
}
|
||||
|
@@ -49,13 +49,13 @@ bool storage_settings_scene_factory_reset_on_event(void* context, SceneManagerEv
|
||||
case DialogExResultRight:
|
||||
counter++;
|
||||
if(counter < STORAGE_SETTINGS_SCENE_FACTORY_RESET_CONFIRM_COUNT) {
|
||||
string_printf(
|
||||
furi_string_printf(
|
||||
app->text_string,
|
||||
"%ld presses left",
|
||||
STORAGE_SETTINGS_SCENE_FACTORY_RESET_CONFIRM_COUNT - counter);
|
||||
dialog_ex_set_text(
|
||||
app->dialog_ex,
|
||||
string_get_cstr(app->text_string),
|
||||
furi_string_get_cstr(app->text_string),
|
||||
64,
|
||||
32,
|
||||
AlignCenter,
|
||||
@@ -83,5 +83,5 @@ void storage_settings_scene_factory_reset_on_exit(void* context) {
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
|
||||
string_reset(app->text_string);
|
||||
furi_string_reset(app->text_string);
|
||||
}
|
||||
|
@@ -25,14 +25,14 @@ void storage_settings_scene_internal_info_on_enter(void* context) {
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, storage_error_get_desc(error), 64, 32, AlignCenter, AlignCenter);
|
||||
} else {
|
||||
string_printf(
|
||||
furi_string_printf(
|
||||
app->text_string,
|
||||
"Label: %s\nType: LittleFS\n%lu KB total\n%lu KB free",
|
||||
furi_hal_version_get_name_ptr() ? furi_hal_version_get_name_ptr() : "Unknown",
|
||||
(uint32_t)(total_space / 1024),
|
||||
(uint32_t)(free_space / 1024));
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, string_get_cstr(app->text_string), 4, 4, AlignLeft, AlignTop);
|
||||
dialog_ex, furi_string_get_cstr(app->text_string), 4, 4, AlignLeft, AlignTop);
|
||||
}
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
|
||||
@@ -58,5 +58,5 @@ void storage_settings_scene_internal_info_on_exit(void* context) {
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
|
||||
string_reset(app->text_string);
|
||||
furi_string_reset(app->text_string);
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ void storage_settings_scene_sd_info_on_enter(void* context) {
|
||||
dialog_ex, "Try to reinsert\nor format SD\ncard.", 3, 19, AlignLeft, AlignTop);
|
||||
dialog_ex_set_center_button_text(dialog_ex, "Ok");
|
||||
} else {
|
||||
string_printf(
|
||||
furi_string_printf(
|
||||
app->text_string,
|
||||
"Label: %s\nType: %s\n%lu KB total\n%lu KB free",
|
||||
sd_info.label,
|
||||
@@ -32,7 +32,7 @@ void storage_settings_scene_sd_info_on_enter(void* context) {
|
||||
sd_info.kb_total,
|
||||
sd_info.kb_free);
|
||||
dialog_ex_set_text(
|
||||
dialog_ex, string_get_cstr(app->text_string), 4, 4, AlignLeft, AlignTop);
|
||||
dialog_ex, furi_string_get_cstr(app->text_string), 4, 4, AlignLeft, AlignTop);
|
||||
}
|
||||
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, StorageSettingsViewDialogEx);
|
||||
@@ -70,5 +70,5 @@ void storage_settings_scene_sd_info_on_exit(void* context) {
|
||||
|
||||
dialog_ex_reset(dialog_ex);
|
||||
|
||||
string_reset(app->text_string);
|
||||
furi_string_reset(app->text_string);
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ static StorageSettings* storage_settings_alloc() {
|
||||
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
app->scene_manager = scene_manager_alloc(&storage_settings_scene_handlers, app);
|
||||
string_init(app->text_string);
|
||||
app->text_string = furi_string_alloc();
|
||||
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
view_dispatcher_set_event_callback_context(app->view_dispatcher, app);
|
||||
@@ -60,7 +60,7 @@ static void storage_settings_free(StorageSettings* app) {
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
furi_record_close(RECORD_NOTIFICATION);
|
||||
|
||||
string_clear(app->text_string);
|
||||
furi_string_free(app->text_string);
|
||||
|
||||
free(app);
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ typedef struct {
|
||||
DialogEx* dialog_ex;
|
||||
|
||||
// text
|
||||
string_t text_string;
|
||||
FuriString* text_string;
|
||||
} StorageSettings;
|
||||
|
||||
typedef enum {
|
||||
|
Reference in New Issue
Block a user