ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
layout.c File Reference

Go to the source code of this file.

Functions

asciichat_error_t ui_layout_measure (terminal_size_t size, int header, int detail, int footer, ui_layout_t *out)

Function Documentation

◆ ui_layout_measure()

asciichat_error_t ui_layout_measure ( terminal_size_t size,
int header_rows,
int detail_rows,
int footer_rows,
ui_layout_t * out )

Fixed chrome with a bounded, possibly empty body viewport.

Definition at line 3 of file ui/layout.c.

3 {
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_OK
Definition error_codes.h:46
@ ERROR_INVALID_PARAM
static bool size_t gotel_query_t * out
Definition queries.h:8

References ASCIICHAT_OK, ERROR_INVALID_PARAM, out, and SET_ERRNO.

Referenced by tui_stats_render(), and ui_sync_render().