diff options
Diffstat (limited to 'src/user/include')
-rw-r--r-- | src/user/include/knob/ipc.h | 2 | ||||
-rw-r--r-- | src/user/include/libterm/command.h | 68 | ||||
-rw-r--r-- | src/user/include/libterm/readline.h (renamed from src/user/include/terminal/readline.h) | 4 | ||||
-rw-r--r-- | src/user/include/libterm/terminal.h | 35 | ||||
-rw-r--r-- | src/user/include/pland/pcrt.h | 1 | ||||
-rw-r--r-- | src/user/include/pland/syscall.h | 20 | ||||
-rw-r--r-- | src/user/include/popups/popup.h | 3 | ||||
-rw-r--r-- | src/user/include/terminal/terminal.h | 57 |
8 files changed, 118 insertions, 72 deletions
diff --git a/src/user/include/knob/ipc.h b/src/user/include/knob/ipc.h index 3eab562..335959d 100644 --- a/src/user/include/knob/ipc.h +++ b/src/user/include/knob/ipc.h @@ -5,7 +5,7 @@ //blocking, returns early if other process is dead. //return value is number of bytes written. -uint32_t try_send_ipc(_task_handle_t to, void *buffer, uint32_t size); +uint32_t try_send_ipc(_task_handle_t to, const void *buffer, uint32_t size); //blocking, returns early if other process is dead. //return value is number of bytes read. 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 diff --git a/src/user/include/terminal/readline.h b/src/user/include/libterm/readline.h index 9046610..b1d5b0a 100644 --- a/src/user/include/terminal/readline.h +++ b/src/user/include/libterm/readline.h @@ -1,5 +1,5 @@ -#ifndef TERMINAL_READLINE_H -#define TERMINAL_READLINE_H +#ifndef LIBTERM_READLINE_H +#define LIBTERM_READLINE_H #include <stdint.h> diff --git a/src/user/include/libterm/terminal.h b/src/user/include/libterm/terminal.h new file mode 100644 index 0000000..19bd517 --- /dev/null +++ b/src/user/include/libterm/terminal.h @@ -0,0 +1,35 @@ +#ifndef LIBTERM_TERMINAL_H +#define LIBTERM_TERMINAL_H + +#include <pland/syscall.h> + +#include <stdarg.h> +#include <stdint.h> + +void term_set_dimensions(uint32_t width, uint32_t height); +void term_get_dimensions(uint32_t *width, uint32_t *height); + +void term_paint(); +void term_clear(); + +void term_set_color(uint8_t fg, uint8_t bg); +void term_set_cursor(uint32_t new_y, uint32_t new_x); + +void term_cursor_left(); +void term_cursor_right(); +void term_cursor_up(); +void term_cursor_down(); + +void term_add_char(char ch); +void term_add_sn_no_ww(const char *s, uint32_t n); +void term_add_sz_no_ww(const char *sz); +void term_add_sz(const char *sz); + +void term_addf_no_ww_v(const char *fmt, va_list args); +void term_addf_no_ww(const char *fmt, ...); +void term_addf_v(const char *fmt, va_list args); +void term_addf(const char *fmt, ...); + +struct key_packet term_get_key_blocking(); + +#endif
\ No newline at end of file diff --git a/src/user/include/pland/pcrt.h b/src/user/include/pland/pcrt.h index 42158cd..795738e 100644 --- a/src/user/include/pland/pcrt.h +++ b/src/user/include/pland/pcrt.h @@ -17,5 +17,6 @@ void __pcrt_quit() __attribute__ ((noreturn)); extern _task_handle_t calling_task; extern _task_handle_t stdio_task; +extern _task_handle_t this_task; #endif diff --git a/src/user/include/pland/syscall.h b/src/user/include/pland/syscall.h index 6d327d5..6870865 100644 --- a/src/user/include/pland/syscall.h +++ b/src/user/include/pland/syscall.h @@ -39,8 +39,8 @@ enum _scn { _SCN_PAINT_WINDOW, _SCN_GET_WIN_ACTION, _SCN_WAIT_FOR_ACTION, - _SCN_WAIT_IPC_SEND, - _SCN_WAIT_FOR_ANY_IPC, + _SCN_WAIT_IPC_SENT, + _SCN_WAIT_ANY_IPC_SENT, _SCN_FIND_UNREAD_IPC, _SCN_WAIT_IPC_READ, _SCN_IS_TASK_RUNNING @@ -137,7 +137,7 @@ static inline uint32_t _ipc_send(_task_handle_t handle, uint32_t count, const vo } static inline uint32_t _ipc_read(_task_handle_t handle, uint32_t count, void *buffer) { - return _sc3(_SCN_IPC_SEND, handle, count, (uint32_t)buffer); + return _sc3(_SCN_IPC_READ, handle, count, (uint32_t)buffer); } static inline void *_allocate_ram(uint32_t pages) { @@ -184,11 +184,11 @@ static inline void _delete_window(_window_handle_t window) { _sc1(_SCN_DELETE_WINDOW, (uint32_t)window); } -static inline void _resize_window(_window_handle_t window, uint16_t width, uint16_t height) { - _sc3(_SCN_RESIZE_WINDOW, (uint32_t)window, width, height); +static inline void _resize_window(_window_handle_t window, uint16_t width, uint16_t height, const void *pixel_buffer) { + _sc4(_SCN_RESIZE_WINDOW, (uint32_t)window, width, height, (uint32_t)pixel_buffer); } -static inline void _reassign_pixbuf(_window_handle_t window, void *pixel_buffer) { +static inline void _reassign_pixbuf(_window_handle_t window, const void *pixel_buffer) { _sc2(_SCN_REASSIGN_PIXBUF, (uint32_t)window, (uint32_t)pixel_buffer); } @@ -204,16 +204,16 @@ static inline void _wait_for_action() { _sc0(_SCN_WAIT_FOR_ACTION); } -static inline void _wait_ipc_send(_task_handle_t sending_task) { - _sc1(_SCN_WAIT_IPC_SEND, sending_task); +static inline void _wait_ipc_sent(_task_handle_t sending_task) { + _sc1(_SCN_WAIT_IPC_SENT, sending_task); } static inline void _system_log(const char *sz) { _sc1(_SCN_SYSTEM_LOG, (uint32_t)sz); } -static inline void _wait_for_any_ipc() { - _sc0(_SCN_WAIT_FOR_ANY_IPC); +static inline void _wait_for_any_ipc_sent() { + _sc0(_SCN_WAIT_ANY_IPC_SENT); } static inline _task_handle_t _find_unread_ipc() { diff --git a/src/user/include/popups/popup.h b/src/user/include/popups/popup.h index 1a3c531..9a39997 100644 --- a/src/user/include/popups/popup.h +++ b/src/user/include/popups/popup.h @@ -11,8 +11,7 @@ struct popup { struct key_packet quit_as; //terminated by one with .key_id == 0 - struct key_packet *quit_binds; - bool free_quit_binds; + const struct key_packet *quit_binds; }; void handle_actions(struct popup *p); diff --git a/src/user/include/terminal/terminal.h b/src/user/include/terminal/terminal.h deleted file mode 100644 index 1782173..0000000 --- a/src/user/include/terminal/terminal.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef TERMINAL_TERMINAL_H -#define TERMINAL_TERMINAL_H - -#include <libfont/fonts.h> - -#include <pland/syscall.h> - -#include <stdarg.h> -#include <stdint.h> - -struct terminal { - _window_handle_t window; - uint8_t *pixbuf; - uint32_t window_width; - uint32_t window_height; - - struct font_info *font; - - uint32_t cols; - uint32_t rows; - char *charbuf; - - uint32_t cursor_y; - uint32_t cursor_x; - - uint8_t fg; - uint8_t bg; -}; - -struct terminal *make_term(struct font_info *font, uint32_t cols, uint32_t rows); -void del_term(struct terminal *term); - -extern struct terminal *active_term; - -void paint_term(); - -void set_color(uint8_t fg, uint8_t bg); -void clear_term(); - -void move_cursor(uint32_t new_y, uint32_t new_x); - -void cursor_left(); -void cursor_right(); -void cursor_up(); -void cursor_down(); - -void term_newline(); -void term_add_char(char ch); -void term_add_sz_no_ww(const char *sz); -void term_add_sz(const char *sz); - -void term_addf_no_ww_v(const char *fmt, va_list args); -void term_addf_no_ww(const char *fmt, ...); -void term_addf_v(const char *fmt, va_list args); -void term_addf(const char *fmt, ...); - -#endif
\ No newline at end of file |