summaryrefslogtreecommitdiff
path: root/src/user
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-02-17 00:13:06 -0500
committerBenji Dial <benji6283@gmail.com>2021-02-17 00:13:06 -0500
commit642c3c69a69220170e2f68c2bf6c898e6cb5b20b (patch)
tree853c4f59c859912f73ede4ab36d89d2b3e9ed0f0 /src/user
parentbe05b9b23f988f934af2fd49976fd97c22dfc19a (diff)
downloadportland-os-642c3c69a69220170e2f68c2bf6c898e6cb5b20b.tar.gz
win+space, mkpopup
Diffstat (limited to 'src/user')
-rw-r--r--src/user/meminfo/meminfo.c2
-rw-r--r--src/user/mkpopup/main.c36
-rw-r--r--src/user/popups/info.c7
3 files changed, 39 insertions, 6 deletions
diff --git a/src/user/meminfo/meminfo.c b/src/user/meminfo/meminfo.c
index 124a136..4dbd6bf 100644
--- a/src/user/meminfo/meminfo.c
+++ b/src/user/meminfo/meminfo.c
@@ -15,7 +15,7 @@ redo:
"kernel memory free: %uk\n"
"userspace memory free: %uk / %uk\n"
"Escape to quit, F5 to refresh.",
- 0x10, 0x08,
+ 0x10, 0x07,
_kernel_dynamic_area_left() * 4,
_total_userspace_left() * 4,
_total_userspace_size() * 4
diff --git a/src/user/mkpopup/main.c b/src/user/mkpopup/main.c
new file mode 100644
index 0000000..5b56889
--- /dev/null
+++ b/src/user/mkpopup/main.c
@@ -0,0 +1,36 @@
+#include <popups/info.h>
+
+#include <knob/heap.h>
+
+#include <stdbool.h>
+#include <stdint.h>
+
+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, 0x10, 0x07);
+ make_modal(&p);
+} \ No newline at end of file
diff --git a/src/user/popups/info.c b/src/user/popups/info.c
index 9a24ad5..5b3f6ae 100644
--- a/src/user/popups/info.c
+++ b/src/user/popups/info.c
@@ -11,9 +11,6 @@
#define PADDING 6
#define FONT "berry"
-#define BG_COLOR 0x07
-#define FG_COlOR 0x10
-
static const struct font_info *info_font = 0;
static const struct key_packet info_quits[] = {
@@ -48,7 +45,7 @@ void info_popup(struct popup *into, const char *msg, uint8_t fg, uint8_t bg) {
for (uint32_t y = 0; y < height; ++y)
for (uint32_t x = 0; x < pitch; ++x)
- pixbuf[y * pitch + x] = BG_COLOR;
+ pixbuf[y * pitch + x] = bg;
uint32_t my = 0;
uint32_t mx = 0;
@@ -59,7 +56,7 @@ void info_popup(struct popup *into, const char *msg, uint8_t fg, uint8_t bg) {
mx = 0;
}
else
- put_char(info_font, *msg, pixbuf + (my * info_font->space_height + PADDING) * pitch + mx++ * info_font->space_width + PADDING, pitch, BG_COLOR, FG_COlOR);
+ 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;