ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
ui/layout.c
Go to the documentation of this file.
2#include <limits.h>
3asciichat_error_t ui_layout_measure(terminal_size_t size, int header, int detail, int footer, ui_layout_t *out) {
4 if (!out || size.cols < 1 || size.rows < 1 || header < 0 || detail < 0 || footer < 0 || header > INT_MAX - detail ||
5 header + detail > INT_MAX - footer)
6 return SET_ERRNO(ERROR_INVALID_PARAM, "Invalid TUI geometry or fixed row counts");
7 int chrome = header + detail + footer;
8 *out = (ui_layout_t){.body_row = header + 1,
9 .body_rows = size.rows > chrome ? size.rows - chrome : 0,
10 .detail_row = size.rows - detail - footer + 1,
11 .footer_row = size.rows - footer + 1};
12 if (out->detail_row < 1)
13 out->detail_row = 1;
14 if (out->footer_row < 1)
15 out->footer_row = 1;
16 return ASCIICHAT_OK;
17}
#define SET_ERRNO(code,...)
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:44
@ ASCIICHAT_OK
Definition error_codes.h:46
@ ERROR_INVALID_PARAM
static bool size_t gotel_query_t * out
Definition queries.h:8
asciichat_error_t ui_layout_measure(terminal_size_t size, int header, int detail, int footer, ui_layout_t *out)
Definition ui/layout.c:3