diff options
author | Benji Dial <benji6283@gmail.com> | 2021-03-08 14:46:19 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-03-08 14:46:19 -0500 |
commit | 8221fd5451f094defa9866f98026b74a969f7693 (patch) | |
tree | 9f0e9595fd15bdecbe667f823deded7428547b44 /src/user/meminfo/meminfo.cpp | |
parent | 1a5ece4f52ef17c7c868e95eb26e98137d5cab6f (diff) | |
download | portland-os-8221fd5451f094defa9866f98026b74a969f7693.tar.gz |
resizable widgets, default widget implementation for some functions, reimplementing meminfo in raleigh
Diffstat (limited to 'src/user/meminfo/meminfo.cpp')
-rw-r--r-- | src/user/meminfo/meminfo.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/user/meminfo/meminfo.cpp b/src/user/meminfo/meminfo.cpp new file mode 100644 index 0000000..2b035a4 --- /dev/null +++ b/src/user/meminfo/meminfo.cpp @@ -0,0 +1,51 @@ +#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; + +void refresh(window &w) { + 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); +} + +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, RGB(bf, bf, bf), (bool (*)(window &))&__pcrt_quit); + w.add_keybind((struct key_packet){.key_id = key_packet::KEY_F5, .modifiers = key_packet::NO_MODS}, &refresh); + + refresh(w); + + w.show(); + start_runtime(); +}
\ No newline at end of file |