[FL-976] Removing lambdas (#1849)

* Removing lambdas...
* Wake the fk up, Gordon! We have a citadel to burn!
* Here comes the Nihilanth
* Lambda documentation

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Sergey Gavrilov
2022-10-09 03:38:29 +10:00
committed by GitHub
parent 981f7ff8b0
commit 31c0346adc
43 changed files with 1193 additions and 1007 deletions

View File

@@ -21,20 +21,24 @@ typedef struct {
static void text_box_process_down(TextBox* text_box) {
with_view_model(
text_box->view, (TextBoxModel * model) {
text_box->view,
TextBoxModel * model,
{
if(model->scroll_pos < model->scroll_num - 1) {
model->scroll_pos++;
// Search next line start
while(*model->text_pos++ != '\n')
;
}
return true;
});
},
true);
}
static void text_box_process_up(TextBox* text_box) {
with_view_model(
text_box->view, (TextBoxModel * model) {
text_box->view,
TextBoxModel * model,
{
if(model->scroll_pos > 0) {
model->scroll_pos--;
// Reach last symbol of previous line
@@ -46,8 +50,8 @@ static void text_box_process_up(TextBox* text_box) {
model->text_pos++;
}
}
return true;
});
},
true);
}
static void text_box_insert_endline(Canvas* canvas, TextBoxModel* model) {
@@ -137,13 +141,15 @@ TextBox* text_box_alloc() {
view_set_input_callback(text_box->view, text_box_view_input_callback);
with_view_model(
text_box->view, (TextBoxModel * model) {
text_box->view,
TextBoxModel * model,
{
model->text = NULL;
model->text_formatted = furi_string_alloc_set("");
model->formatted = false;
model->font = TextBoxFontText;
return true;
});
},
true);
return text_box;
}
@@ -152,10 +158,7 @@ void text_box_free(TextBox* text_box) {
furi_assert(text_box);
with_view_model(
text_box->view, (TextBoxModel * model) {
furi_string_free(model->text_formatted);
return true;
});
text_box->view, TextBoxModel * model, { furi_string_free(model->text_formatted); }, true);
view_free(text_box->view);
free(text_box);
}
@@ -169,13 +172,15 @@ void text_box_reset(TextBox* text_box) {
furi_assert(text_box);
with_view_model(
text_box->view, (TextBoxModel * model) {
text_box->view,
TextBoxModel * model,
{
model->text = NULL;
furi_string_set(model->text_formatted, "");
model->font = TextBoxFontText;
model->focus = TextBoxFocusStart;
return true;
});
},
true);
}
void text_box_set_text(TextBox* text_box, const char* text) {
@@ -183,31 +188,27 @@ void text_box_set_text(TextBox* text_box, const char* text) {
furi_assert(text);
with_view_model(
text_box->view, (TextBoxModel * model) {
text_box->view,
TextBoxModel * model,
{
model->text = text;
furi_string_reset(model->text_formatted);
furi_string_reserve(model->text_formatted, strlen(text));
model->formatted = false;
return true;
});
},
true);
}
void text_box_set_font(TextBox* text_box, TextBoxFont font) {
furi_assert(text_box);
with_view_model(
text_box->view, (TextBoxModel * model) {
model->font = font;
return true;
});
text_box->view, TextBoxModel * model, { model->font = font; }, true);
}
void text_box_set_focus(TextBox* text_box, TextBoxFocus focus) {
furi_assert(text_box);
with_view_model(
text_box->view, (TextBoxModel * model) {
model->focus = focus;
return true;
});
text_box->view, TextBoxModel * model, { model->focus = focus; }, true);
}