117 point_t srcPoint = {contentRect.
left, contentRect.
top + rowHeight};
164 backspaceChar->
chr =
' ';
174 for (
uint16_t i = 0; i < spacesToNextTabStop; i++)
183 currentChar->
chr = chr;
250 uint16_t startPos = cursorRow < moveBy ? 0 : cursorRow - moveBy;
287 int responseLen =
snprintf(response,
sizeof(response),
"\033[%d;%dR", cursorRow, cursorCol);
310 startRow = cursorRow;
311 startCol = cursorCol;
331 for (
uint16_t row = startRow; row <= endRow; row++)
333 uint16_t colStart = (row == startRow) ? startCol : 0;
335 for (
uint16_t col = colStart; col <= colEnd; col++)
338 screenChar->
chr =
' ';
370 for (
uint16_t col = startCol; col <= endCol; col++)
428 term->
flags &= ~TERMINAL_ITALIC;
431 term->
flags &= ~TERMINAL_UNDERLINE;
434 term->
flags &= ~TERMINAL_BLINK;
437 term->
flags &= ~TERMINAL_INVERSE;
440 term->
flags &= ~TERMINAL_HIDDEN;
443 term->
flags &= ~TERMINAL_STRIKETHROUGH;
485 for (
int j = 0; j < paramLen; j++)
498 for (
uint64_t i = 0; i < length; i++)
560 const char* argv[] = {
"/bin/shell",
NULL};
597 writef(shellNote,
"kill");
716 if (fds[0].revents &
POLLIN)
#define MAX_NAME
Maximum length of names.
uint64_t font_width(const font_t *font, const char *string, uint64_t length)
void font_free(font_t *font)
font_t * font_new(display_t *disp, const char *family, const char *weight, uint64_t size)
uint64_t font_height(const font_t *font)
void display_disconnect(display_t *disp)
Disconnect the display connection.
uint64_t display_poll(display_t *disp, pollfd_t *fds, uint64_t nfds, clock_t timeout)
Poll the display connection for events together with other file descriptors.
uint64_t display_next(display_t *disp, event_t *event, clock_t timeout)
Retrieve the next event from the display connection.
uint64_t display_dispatch(display_t *disp, const event_t *event)
Dispatch an event to the appropriate surface.
void display_push(display_t *disp, surface_id_t target, event_type_t type, void *data, uint64_t size)
Push an event to the display's internal event queue.
void draw_string(drawable_t *draw, const font_t *font, const point_t *point, pixel_t pixel, const char *string, uint64_t length)
Draw a string.
void draw_rect(drawable_t *draw, const rect_t *rect, pixel_t pixel)
Draw a filled rectangle.
void draw_transfer(drawable_t *dest, drawable_t *src, const rect_t *destRect, const point_t *srcPoint)
Transfer pixels from one drawable to another.
void element_set_private(element_t *elem, void *private)
Set private data for an element.
theme_t * element_get_theme(element_t *elem)
Get the theme of an element.
void element_draw_end(element_t *elem, drawable_t *draw)
End drawing to an element.
rect_t element_get_content_rect(element_t *elem)
Get the element's rectangle in local coordinates.
void element_draw_begin(element_t *elem, drawable_t *draw)
Begin drawing to an element.
void * element_get_private(element_t *elem)
Get private data for an element.
theme_t * theme_global_get(void)
Get the global theme.
uint64_t window_set_visible(window_t *win, bool isVisible)
Set the visibility of the window.
surface_id_t window_get_id(window_t *win)
Get the surface ID of the window.
uint64_t window_set_timer(window_t *win, timer_flags_t flags, clock_t timeout)
Set the window timer.
window_t * window_new(display_t *disp, const char *name, const rect_t *rect, surface_type_t type, window_flags_t flags, procedure_t procedure, void *private)
Allocate and initialize a new window.
element_t * window_get_client_element(window_t *win)
Get the client element of the window.
void window_free(window_t *win)
Free a window.
display_t * window_get_display(window_t *win)
Get the display associated with the window.
@ WINDOW_DECO
Enable decorations (titlebar, close/minimize buttons, etc).
uint64_t writef(fd_t fd, const char *_RESTRICT format,...)
Wrapper for writing a formatted string to a file.
#define PIPE_READ
Pipe read end.
uint64_t close(fd_t fd)
System call for closing files.
fd_t openf(const char *_RESTRICT format,...)
Wrapper for opening files with a formatted path.
#define PIPE_WRITE
Pipe write end.
uint64_t read(fd_t fd, void *buffer, uint64_t count)
System call for reading from files.
uint64_t open2(const char *path, fd_t fd[2])
System call for opening 2 file descriptors from one file.
uint64_t write(fd_t fd, const void *buffer, uint64_t count)
System call for writing to files.
@ POLLIN
File descriptor is ready to read.
@ KBD_PRESS
Key press event.
pid_t spawn(const char **argv, const spawn_fd_t *fds, const char *cwd, spawn_attr_t *attr)
System call for creating child processes.
#define SPAWN_FD_END
Spawn fds termination constant.
#define NULL
Pointer error value.
#define ERR
Integer error value.
__UINT64_TYPE__ fd_t
A file descriptor.
static bool ansi_sending_parse(ansi_sending_t *ansi, char chr)
Parse a character for ANSI sending.
static void ansi_sending_init(ansi_sending_t *ansi)
Initialize an ANSI sending structure.
static void ansi_kbd_to_receiving(ansi_receiving_t *ansi, const event_kbd_t *kbd)
Convert a keycode to an ANSI receiving sequence.
void terminal_loop(window_t *win)
Terminal main loop.
#define TERMINAL_BLINK_INTERVAL
Terminal blink rate.
#define TERMINAL_MAX_INPUT
Maximum terminal input length.
#define TERMINAL_COLUMNS
Terminal columns.
#define UEVENT_TERMINAL_DATA
Event sent from the terminals io thread to the main thread when there is data available.
window_t * terminal_new(display_t *disp)
Create a new terminal window.
#define TERMINAL_ROWS
Terminal rows.
EFI_PHYSICAL_ADDRESS buffer
#define RECT_SHRINK(rect, margin)
#define RECT_INIT_DIM(x, y, width, height)
#define RECT_HEIGHT(rect)
_PUBLIC int snprintf(char *_RESTRICT s, size_t n, const char *_RESTRICT format,...)
_PUBLIC void * malloc(size_t size)
_PUBLIC void free(void *ptr)
ANSI receiving structure.
char buffer[ANSI_MAX_LENGTH]
uint8_t parameters[ANSI_MAX_LENGTH]
Opaque display structure.
Opaque element structure.
uint8_t raw[EVENT_MAX_DATA]
Poll file descriptor structure.
fd_t fd
The file descriptor to poll.
Stucture used to duplicate fds in spawn().
fd_t child
The destination file descriptor in the child.
Terminal initialization context.
terminal_char_t * savedCursor
terminal_char_t * prevCursor
terminal_char_t screen[TERMINAL_ROWS][TERMINAL_COLUMNS]
pixel_t bright[THEME_ANSI_COLOR_COUNT]
pixel_t normal[THEME_ANSI_COLOR_COUNT]
Terminal data event structure. struct uevent_terminal_data_t.
char buffer[TERMINAL_MAX_INPUT]
static void terminal_put(terminal_t *term, element_t *elem, drawable_t *draw, char chr)
static void terminal_clear(terminal_t *term, element_t *elem, drawable_t *draw)
static rect_t terminal_char_rect(terminal_t *term, element_t *elem, terminal_char_t *termChar)
static terminal_char_t * terminal_get_char(terminal_t *term, uint16_t row, uint16_t col)
static uint64_t terminal_procedure(window_t *win, element_t *elem, const event_t *event)
static void terminal_char_draw(terminal_t *term, element_t *elem, drawable_t *draw, terminal_char_t *termChar)
static uint64_t terminal_pixel_width(font_t *font)
static void ternminal_execute_ansi(terminal_t *term, element_t *elem, drawable_t *draw, ansi_sending_t *ansi)
static void terminal_cursor_update(terminal_t *term, element_t *elem, drawable_t *draw)
static void terminal_scroll(terminal_t *term, element_t *elem, drawable_t *draw)
static void terminal_handle_input(terminal_t *term, element_t *elem, drawable_t *draw, const event_kbd_t *kbd)
static uint64_t terminal_pixel_height(font_t *font)
static void terminal_handle_output(terminal_t *term, element_t *elem, drawable_t *draw, const char *buffer, uint64_t length)
static point_t terminal_char_pos(terminal_t *term, element_t *elem, terminal_char_t *termChar)
static terminal_char_t terminal_char_create(char chr, pixel_t foreground, pixel_t background, uint16_t row, uint16_t col)
static uint16_t terminal_char_row(terminal_t *term, terminal_char_t *termChar)