-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract common ui_stream functions in ui_stream_common for clarity
Remove redundant code
- Loading branch information
1 parent
1d12e8f
commit ea83d89
Showing
7 changed files
with
87 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/build | ||
/_build | ||
/app/.target | ||
/app/bin | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// Created by ajinkyaraj on 14/09/24. | ||
// | ||
#include "exception.h" | ||
#include "globals.h" | ||
#include "ui_strings.h" | ||
#include "ui_stream.h" | ||
|
||
size_t | ||
tz_ui_stream_push_all(tz_ui_cb_type_t cb_type, const char *title, | ||
const char *value, tz_ui_layout_type_t layout_type, | ||
tz_ui_icon_t icon) | ||
{ | ||
size_t obuflen; | ||
size_t i = 0; | ||
|
||
FUNC_ENTER(("cb_type=%d title=%s value=%s", cb_type, title, value)); | ||
|
||
obuflen = strlen(value); | ||
do { | ||
i += tz_ui_stream_push(cb_type, title, value + i, layout_type, icon); | ||
PRINTF("[DEBUG] pushed %d in total\n", i); | ||
} while (i < obuflen); | ||
|
||
FUNC_LEAVE(); | ||
return i; | ||
} | ||
|
||
size_t | ||
tz_ui_stream_push(tz_ui_cb_type_t cb_type, const char *title, | ||
const char *value, tz_ui_layout_type_t layout_type, | ||
tz_ui_icon_t icon) | ||
{ | ||
return tz_ui_stream_pushl(cb_type, title, value, -1, layout_type, icon); | ||
} | ||
|
||
tz_ui_cb_type_t | ||
tz_ui_stream_get_cb_type(void) | ||
{ | ||
tz_ui_stream_t *s = &global.stream; | ||
size_t bucket = s->current % TZ_UI_STREAM_HISTORY_SCREENS; | ||
|
||
return s->screens[bucket].cb_type; | ||
} | ||
|
||
void | ||
push_str(const char *text, size_t len, char **out) | ||
{ | ||
bool can_fit = false; | ||
|
||
TZ_PREAMBLE(("%s", text)); | ||
|
||
if (len == 0) { | ||
*out = NULL; | ||
TZ_SUCCEED(); | ||
} | ||
|
||
TZ_CHECK(ui_strings_can_fit(len, &can_fit)); | ||
while (!can_fit) { | ||
TZ_CHECK(drop_last_screen()); | ||
TZ_CHECK(ui_strings_can_fit(len, &can_fit)); | ||
} | ||
|
||
TZ_CHECK(ui_strings_push(text, len, out)); | ||
|
||
TZ_POSTAMBLE; | ||
} | ||
|
||
void | ||
tz_ui_stream_close(void) | ||
{ | ||
tz_ui_stream_t *s = &global.stream; | ||
|
||
FUNC_ENTER(("full=%d", s->full)); | ||
if (s->full) { | ||
PRINTF("trying to close already closed stream display"); | ||
THROW(EXC_UNKNOWN); | ||
} | ||
s->full = true; | ||
|
||
FUNC_LEAVE(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters