From 5fcf57739e68a8b5053e03778aaee0eed445babd Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 11 Mar 2021 22:00:22 -0500 Subject: settings editor, and lots of changes in service of that --- src/user/mkpopup/main.c | 36 ------------------------------------ src/user/mkpopup/main.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 36 deletions(-) delete mode 100644 src/user/mkpopup/main.c create mode 100644 src/user/mkpopup/main.cpp (limited to 'src/user/mkpopup') diff --git a/src/user/mkpopup/main.c b/src/user/mkpopup/main.c deleted file mode 100644 index 05ea4e3..0000000 --- a/src/user/mkpopup/main.c +++ /dev/null @@ -1,36 +0,0 @@ -#include - -#include - -#include -#include - -void main(const char *text) { - uint32_t required_new_length = 0; - bool needs_new = false; - for (const char *c = text; c[0]; ++c) { - ++required_new_length; - if ((c[0] == '\\') && (c[1] == 'n')) { - ++c; - needs_new = true; - } - } - - if (needs_new) { - char *new_text = get_block(required_new_length); - const char *ci; - char *co; - for (ci = text, co = new_text; *ci; ++ci, ++co) - if ((ci[0] == '\\') && (ci[1] == 'n')) { - *co = '\n'; - ++ci; - } - else - *co = *ci; - text = new_text; - } - - struct popup p; - info_popup(&p, text, (_pixel_t){.r = 0, .g = 0, .b = 0}, (_pixel_t){.r = 0xbf, .g = 0xbf, .b = 0xbf}); - make_modal(&p); -} \ No newline at end of file diff --git a/src/user/mkpopup/main.cpp b/src/user/mkpopup/main.cpp new file mode 100644 index 0000000..5e3310c --- /dev/null +++ b/src/user/mkpopup/main.cpp @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include + +using namespace raleigh; + +widget *make_line(const char *str) { + return new label(str); +} + +void main(const char *text) { + dllist box_widgets; + + char *const data = strdup(text); + + char *this_string = data; + while (*this_string) { + char *i = this_string; + while (1) { + if (!i[0]) { + box_widgets.add_back(*make_line(this_string)); + this_string = i; + break; + } + if ((i[0] == '\\') && (i[1] == 'n')) { + i[0] = '\0'; + box_widgets.add_back(*make_line(this_string)); + this_string = i + 2; + break; + } + ++i; + } + } + + vbox box(box_widgets); + padding p(box, 4); + window w(p); + + w.show(); + start_runtime(); +} \ No newline at end of file -- cgit v1.2.3