diff options
Diffstat (limited to 'src/user/mkpopup/main.cpp')
-rw-r--r-- | src/user/mkpopup/main.cpp | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/src/user/mkpopup/main.cpp b/src/user/mkpopup/main.cpp index 5e3310c..8b3746c 100644 --- a/src/user/mkpopup/main.cpp +++ b/src/user/mkpopup/main.cpp @@ -1,41 +1,35 @@ #include <raleigh/w/padding.h> #include <raleigh/w/label.h> -#include <raleigh/w/vbox.h> #include <raleigh/window.h> -#include <knob/block.h> using namespace raleigh; -widget *make_line(const char *str) { - return new label(str); -} - void main(const char *text) { - dllist<widget &> 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; + char *unescaped = new char[strlen(text) + 1]; + char *ui = unescaped; + while (1) { + const uint32_t len = str_find_any(text, "\\"); + if (len) { + blockcpy(ui, text, len); + text += len; + ui += len; + } + if (!*text) + break; + if (text[1] == 'n') { + *(ui++) = '\n'; + text += 2; + } + else { + *(ui++) = '\\'; + ++text; } } + *ui = '\0'; - vbox box(box_widgets); - padding p(box, 4); + label l(unescaped); + delete[] unescaped; + padding p(l, 4); window w(p); w.show(); |