summaryrefslogtreecommitdiff
path: root/src/user/popups/info.c
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-03-11 22:00:22 -0500
committerBenji Dial <benji6283@gmail.com>2021-03-11 22:00:22 -0500
commit5fcf57739e68a8b5053e03778aaee0eed445babd (patch)
treee7a8bab18668d112e58b1b48190195035c71fa8a /src/user/popups/info.c
parent0f2398d1f622cce37925f52d978d92e6cce1c7a9 (diff)
downloadportland-os-5fcf57739e68a8b5053e03778aaee0eed445babd.tar.gz
settings editor, and lots of changes in service of that
Diffstat (limited to 'src/user/popups/info.c')
-rw-r--r--src/user/popups/info.c77
1 files changed, 0 insertions, 77 deletions
diff --git a/src/user/popups/info.c b/src/user/popups/info.c
deleted file mode 100644
index eac155b..0000000
--- a/src/user/popups/info.c
+++ /dev/null
@@ -1,77 +0,0 @@
-#include <popups/popup.h>
-
-#include <libfont/fonts.h>
-
-#include <knob/format.h>
-#include <knob/heap.h>
-
-#include <stdint.h>
-#include <stdarg.h>
-
-#define PADDING 6
-#define FONT "fixed-10"
-
-static const struct font_info *info_font = 0;
-
-static const struct key_packet info_quits[] = {
- { .key_id = KEY_ESCAPE, .modifiers = NO_MODS },
- { .key_id = 0 }
-};
-
-void info_popup(struct popup *into, const char *msg, _pixel_t fg, _pixel_t bg) {
- if (!info_font)
- info_font = get_font(FONT);
-
- uint32_t w = 0, h = 1, lw = 0;
- for (const char *i = msg; *i; ++i)
- if (*i == '\n') {
- ++h;
- if (lw > w)
- w = lw;
- lw = 0;
- }
- else
- ++lw;
- if (lw > w)
- w = lw;
-
- into->has_quit = false;
- into->quit_binds = (struct key_packet *)info_quits;
-
- const uint32_t pitch = info_font->space_width * w + 2 * PADDING;
- const uint32_t height = info_font->space_height * h + 2 * PADDING;
-
- _pixel_t *const pixbuf = get_block(pitch * height * 4);
-
- for (uint32_t y = 0; y < height; ++y)
- for (uint32_t x = 0; x < pitch; ++x)
- pixbuf[y * pitch + x] = bg;
-
- uint32_t my = 0;
- uint32_t mx = 0;
- --msg;
- while (*++msg) {
- if (*msg == '\n') {
- ++my;
- mx = 0;
- }
- else
- put_char(info_font, *msg, pixbuf + (my * info_font->space_height + PADDING) * pitch + mx++ * info_font->space_width + PADDING, pitch, bg, fg);
- }
-
- into->pixbuf = pixbuf;
- into->handle = _new_window(pitch, height, pixbuf);
-}
-
-void info_popupf_v(struct popup *into, const char *text, _pixel_t fg, _pixel_t bg, va_list args) {
- char *const msg = format_v(text, args);
- info_popup(into, msg, fg, bg);
- free_block(msg);
-}
-
-void info_popupf(struct popup *into, const char *text, _pixel_t fg, _pixel_t bg, ...) {
- va_list args;
- va_start(args, bg);
- info_popupf_v(into, text, fg, bg, args);
- va_end(args);
-} \ No newline at end of file