From 47513bd32c256c4f35e3a8ced7d9fd7e15903530 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Tue, 16 Feb 2021 20:38:53 -0500 Subject: terminal application with ipc, shift+pause state dumper, hello world for terminal, meminfo popup program --- src/user/include/libterm/command.h | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/user/include/libterm/command.h (limited to 'src/user/include/libterm/command.h') 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 + +#include + +#include + +#include +#include + +//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 -- cgit v1.2.3