diff options
Diffstat (limited to 'src/user/meminfo')
-rw-r--r-- | src/user/meminfo/meminfo.cpp | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/src/user/meminfo/meminfo.cpp b/src/user/meminfo/meminfo.cpp index 03f7ae9..c750e8b 100644 --- a/src/user/meminfo/meminfo.cpp +++ b/src/user/meminfo/meminfo.cpp @@ -1,49 +1,24 @@ -#include <raleigh/w/padding.h> -#include <raleigh/w/vbox.h> #include <raleigh/w/label.h> - #include <raleigh/runtime.h> #include <raleigh/window.h> - #include <pland/syscall.h> #include <knob/format.h> -#include <pland/pcrt.h> using namespace raleigh; -label *kmem; -label *umem; +label *l; void refresh(window_tag_t) { - char *const kstr = format("kernel memory free: %uk", _kernel_dynamic_area_left() * 4); - char *const ustr = format("userspace memory free: %uk / %uk", _total_userspace_left() * 4, _total_userspace_size() * 4); - - kmem->change_value(kstr); - umem->change_value(ustr); - - free_block(kstr); - free_block(ustr); + char *fmt = format("Kernel memory free: %ukB\nUser memory free: %ukB\nF5 to refresh, Alt+F4 to quit", _kernel_dynamic_area_left() * 4, _total_userspace_left() * 4); + l->change_value(fmt); + free_block(fmt); } void main() { - kmem = new label(""); - umem = new label(""); - label msg("press Alt+F4 to quit, or F5 to refresh"); - - padding pkmem(*kmem, 1); - padding pumem(*umem, 1); - padding pmsg(msg, 1); - - dllist<widget &> ll; - ll.add_front(pmsg); - ll.add_front(pumem); - ll.add_front(pkmem); - vbox box(ll); - - padding pbox(box, 3); - window w(pbox); - w.add_keybind((struct key_packet){.key_id = key_packet::KEY_F5, .modifiers = key_packet::NO_MODS}, &refresh); + l = new label(""); + window w(*l); + w.add_keybind((key_packet){.key_id = key_packet::KEY_F5, .modifiers = key_packet::NO_MODS}, &refresh); refresh(0); w.show(); |