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:
@@ -1,6 +1,5 @@
|
||||
#include "text_box.h"
|
||||
#include "gui/canvas.h"
|
||||
#include <m-string.h>
|
||||
#include <furi.h>
|
||||
#include <gui/elements.h>
|
||||
#include <stdint.h>
|
||||
@@ -12,7 +11,7 @@ struct TextBox {
|
||||
typedef struct {
|
||||
const char* text;
|
||||
char* text_pos;
|
||||
string_t text_formatted;
|
||||
FuriString* text_formatted;
|
||||
int32_t scroll_pos;
|
||||
int32_t scroll_num;
|
||||
TextBoxFont font;
|
||||
@@ -66,17 +65,17 @@ static void text_box_insert_endline(Canvas* canvas, TextBoxModel* model) {
|
||||
if(line_width + glyph_width > text_width) {
|
||||
line_num++;
|
||||
line_width = 0;
|
||||
string_push_back(model->text_formatted, '\n');
|
||||
furi_string_push_back(model->text_formatted, '\n');
|
||||
}
|
||||
line_width += glyph_width;
|
||||
} else {
|
||||
line_num++;
|
||||
line_width = 0;
|
||||
}
|
||||
string_push_back(model->text_formatted, symb);
|
||||
furi_string_push_back(model->text_formatted, symb);
|
||||
}
|
||||
line_num++;
|
||||
model->text = string_get_cstr(model->text_formatted);
|
||||
model->text = furi_string_get_cstr(model->text_formatted);
|
||||
model->text_pos = (char*)model->text;
|
||||
if(model->focus == TextBoxFocusEnd && line_num > 5) {
|
||||
// Set text position to 5th line from the end
|
||||
@@ -140,7 +139,7 @@ TextBox* text_box_alloc() {
|
||||
with_view_model(
|
||||
text_box->view, (TextBoxModel * model) {
|
||||
model->text = NULL;
|
||||
string_init_set_str(model->text_formatted, "");
|
||||
model->text_formatted = furi_string_alloc_set("");
|
||||
model->formatted = false;
|
||||
model->font = TextBoxFontText;
|
||||
return true;
|
||||
@@ -154,7 +153,7 @@ void text_box_free(TextBox* text_box) {
|
||||
|
||||
with_view_model(
|
||||
text_box->view, (TextBoxModel * model) {
|
||||
string_clear(model->text_formatted);
|
||||
furi_string_free(model->text_formatted);
|
||||
return true;
|
||||
});
|
||||
view_free(text_box->view);
|
||||
@@ -172,7 +171,7 @@ void text_box_reset(TextBox* text_box) {
|
||||
with_view_model(
|
||||
text_box->view, (TextBoxModel * model) {
|
||||
model->text = NULL;
|
||||
string_set_str(model->text_formatted, "");
|
||||
furi_string_set(model->text_formatted, "");
|
||||
model->font = TextBoxFontText;
|
||||
model->focus = TextBoxFocusStart;
|
||||
return true;
|
||||
@@ -186,8 +185,8 @@ void text_box_set_text(TextBox* text_box, const char* text) {
|
||||
with_view_model(
|
||||
text_box->view, (TextBoxModel * model) {
|
||||
model->text = text;
|
||||
string_reset(model->text_formatted);
|
||||
string_reserve(model->text_formatted, strlen(text));
|
||||
furi_string_reset(model->text_formatted);
|
||||
furi_string_reserve(model->text_formatted, strlen(text));
|
||||
model->formatted = false;
|
||||
return true;
|
||||
});
|
||||
|
Reference in New Issue
Block a user