ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
layout.h File Reference

Go to the source code of this file.

Data Structures

struct  ui_layout_t

Functions

asciichat_error_t ui_layout_measure (terminal_size_t size, int header_rows, int detail_rows, int footer_rows, 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.

4 {
5 if (!out || size.cols < 1 || size.rows < 1 || header < 0 || detail < 0 ||
6 footer < 0 || header > INT_MAX - detail ||
7 header + detail > INT_MAX - footer)
9 "Invalid TUI geometry or fixed row counts");
10 int chrome = header + detail + footer;
11 *out = (ui_layout_t){.body_row = header + 1,
12 .body_rows = size.rows > chrome ? size.rows - chrome : 0,
13 .detail_row = size.rows - detail - footer + 1,
14 .footer_row = size.rows - footer + 1};
15 if (out->detail_row < 1)
16 out->detail_row = 1;
17 if (out->footer_row < 1)
18 out->footer_row = 1;
19 return ASCIICHAT_OK;
20}
#define SET_ERRNO(code,...)
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_INVALID_PARAM
static bool size_t gotel_query_t * out
Definition queries.h:10

References ASCIICHAT_OK, ERROR_INVALID_PARAM, out, and SET_ERRNO.

Referenced by tui_stats_render(), and ui_sync_render().