mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-07-30 02:18:11 -07:00
Merge branch 'dev' of https://github.com/DarkFlippers/unleashed-firmware into xfw-dev
This commit is contained in:
@@ -83,6 +83,7 @@ static bool browser_path_trim(FuriString* path) {
|
||||
return is_root;
|
||||
}
|
||||
static void browser_parse_ext_filter(ExtFilterArray_t ext_filter, const char* filter_str) {
|
||||
ExtFilterArray_reset(ext_filter);
|
||||
if(!filter_str) {
|
||||
return;
|
||||
}
|
||||
@@ -94,7 +95,6 @@ static void browser_parse_ext_filter(ExtFilterArray_t ext_filter, const char* fi
|
||||
|
||||
size_t str_offset = 0;
|
||||
FuriString* ext_temp = furi_string_alloc();
|
||||
ExtFilterArray_reset(ext_filter);
|
||||
while(1) {
|
||||
size_t ext_len = strcspn(&filter_str[str_offset], "|");
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include <furi.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define TEXT_BOX_MAX_SYMBOL_WIDTH (10)
|
||||
#define TEXT_BOX_LINE_WIDTH (120)
|
||||
|
||||
struct TextBox {
|
||||
View* view;
|
||||
|
||||
@@ -78,13 +81,11 @@ static void text_box_insert_endline(Canvas* canvas, TextBoxModel* model) {
|
||||
const char* str = model->text;
|
||||
size_t line_num = 0;
|
||||
|
||||
const size_t text_width = 120;
|
||||
|
||||
while(str[i] != '\0') {
|
||||
char symb = str[i++];
|
||||
if(symb != '\n') {
|
||||
size_t glyph_width = canvas_glyph_width(canvas, symb);
|
||||
if(line_width + glyph_width > text_width) {
|
||||
if(line_width + glyph_width > TEXT_BOX_LINE_WIDTH) {
|
||||
line_num++;
|
||||
line_width = 0;
|
||||
furi_string_push_back(model->text_formatted, '\n');
|
||||
@@ -212,6 +213,7 @@ void text_box_reset(TextBox* text_box) {
|
||||
furi_string_set(model->text_formatted, "");
|
||||
model->font = TextBoxFontText;
|
||||
model->focus = TextBoxFocusStart;
|
||||
model->formatted = false;
|
||||
},
|
||||
true);
|
||||
}
|
||||
@@ -219,6 +221,8 @@ void text_box_reset(TextBox* text_box) {
|
||||
void text_box_set_text(TextBox* text_box, const char* text) {
|
||||
furi_assert(text_box);
|
||||
furi_assert(text);
|
||||
size_t str_length = strlen(text);
|
||||
size_t formating_margin = str_length * TEXT_BOX_MAX_SYMBOL_WIDTH / TEXT_BOX_LINE_WIDTH;
|
||||
|
||||
with_view_model(
|
||||
text_box->view,
|
||||
@@ -226,7 +230,7 @@ void text_box_set_text(TextBox* text_box, const char* text) {
|
||||
{
|
||||
model->text = text;
|
||||
furi_string_reset(model->text_formatted);
|
||||
furi_string_reserve(model->text_formatted, strlen(text));
|
||||
furi_string_reserve(model->text_formatted, str_length + formating_margin);
|
||||
model->formatted = false;
|
||||
},
|
||||
true);
|
||||
|
||||
Reference in New Issue
Block a user