diff options
author | Benji Dial <benji6283@gmail.com> | 2021-02-16 20:38:53 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-02-16 20:38:53 -0500 |
commit | 47513bd32c256c4f35e3a8ced7d9fd7e15903530 (patch) | |
tree | cafdf75d52a954814726e07445063c41bb6599f9 /src/user/include/libterm/command.h | |
parent | bd7facc4b5f53481dc85a15ba123361b2758655b (diff) | |
download | portland-os-47513bd32c256c4f35e3a8ced7d9fd7e15903530.tar.gz |
terminal application with ipc, shift+pause state dumper, hello world for terminal, meminfo popup program
Diffstat (limited to 'src/user/include/libterm/command.h')
-rw-r--r-- | src/user/include/libterm/command.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/user/include/libterm/command.h b/src/user/include/libterm/command.h new file mode 100644 index 0000000..7587306 --- /dev/null +++ b/src/user/include/libterm/command.h @@ -0,0 +1,68 @@ +#ifndef LIBTERM_COMMAND_H +#define LIBTERM_COMMAND_H + +#include <libterm/terminal.h> + +#include <knob/ipc.h> + +#include <keypack.h> + +#include <stdbool.h> +#include <stdint.h> + +//set to stdio task by default +extern _task_handle_t term_task; + +struct terminal_command { + enum { + SET_DIMENSIONS, + GET_DIMENSIONS, + PAINT, + CLEAR, + SET_COLOR, + SET_CURSOR, + CURSOR_LEFT, + CURSOR_RIGHT, + CURSOR_UP, + CURSOR_DOWN, + ADD_CHAR, + ADD_SN, + ADD_SN_NO_WORDWRAP, + GET_KEY + } kind; + + union { + struct { + uint32_t y; + uint32_t x; + } as_coords; + struct { + uint8_t fg; + uint8_t bg; + } as_color; + char as_char; + uint32_t as_uint; + }; +} __attribute__ ((__packed__)); + +union terminal_response { + struct { + uint32_t y; + uint32_t x; + } as_coords; + struct key_packet as_key; +} __attribute__ ((__packed__)); + +//returns false if terminal has died +static inline bool try_send_command(struct terminal_command *cmd) { + return try_send_ipc(term_task, cmd, sizeof(struct terminal_command)) + == sizeof(struct terminal_command); +} + +//returns false if terminal has died +static inline bool try_get_response(union terminal_response *rs) { + return try_read_ipc(term_task, rs, sizeof(union terminal_response)) + == sizeof(union terminal_response); +} + +#endif
\ No newline at end of file |