include/console/report.h View source View on GitHub
struct report_line {
char *buf;
size_t cap;
size_t len;
size_t col;
size_t max_col;
size_t glyph_at;
bool full;
bool truncated;
};
struct report_target {
struct report_panes *panes;
struct report_box *box;
uint16_t width;
uint8_t indent;
uint8_t pane;
};
struct report_box {
struct report_target target;
uint16_t inner;
};
struct report_fields {
struct report_target target;
uint8_t per_row;
uint8_t in_row;
uint8_t keyw;
uint8_t valw;
struct report_line line;
char storage[REPORT_LINE_MAX];
};
struct report_panes {
uint8_t n;
uint16_t width[REPORT_PANES_MAX];
const char *title[REPORT_PANES_MAX];
uint8_t title_sev[REPORT_PANES_MAX];
uint16_t nrows[REPORT_PANES_MAX];
uint32_t dropped[REPORT_PANES_MAX];
bool stacked;
bool undivided;
char text[REPORT_PANES_MAX][REPORT_PANE_ROWS][REPORT_PANE_LINE_MAX];
bool rule[REPORT_PANES_MAX][REPORT_PANE_ROWS];
};
void report_line_init(struct report_line *l, char *buf, size_t cap, size_t max_col);
void report_line_reset(struct report_line *l);
void report_line_puts(struct report_line *l, const char *s);
void report_line_printf(struct report_line *l, const char *fmt);
void report_line_vprintf(struct report_line *l, const char *fmt, va_list ap);
void report_line_pad_to(struct report_line *l, size_t col);
void report_line_repeat(struct report_line *l, const char *glyph, size_t n);
void report_line_field(struct report_line *l, const char *s, size_t width);
void report_line_right(struct report_line *l, const char *s);
const char * report_line_str(const struct report_line *l);
size_t report_line_width(const struct report_line *l);
bool report_line_truncated(const struct report_line *l);
size_t report_strwidth(const char *s);
struct report_target report_console(void);
struct report_target report_console_indent(uint16_t indent);
struct report_target report_pane(struct report_panes *panes, uint32_t pane);
struct report_target report_target_indent(struct report_target tgt, uint16_t indent);
uint16_t report_target_width(const struct report_target *tgt);
void report_puts(struct report_target *tgt, const char *s);
void report_printf(struct report_target *tgt, const char *fmt);
void report_blank(struct report_target *tgt);
void report_line_emit(struct report_target *tgt, struct report_line *l);
void report_rule(struct report_target *tgt, const char *title);
void report_rule_sev(struct report_target *tgt, enum term_sev sev, const char *title);
void report_wrap(struct report_target *tgt, const char *text);
void report_wrap_printf(struct report_target *tgt, const char *fmt);
void report_box_open(struct report_box *b, struct report_target target, const char *title, uint16_t inner);
void report_box_printf(struct report_box *b, const char *fmt);
struct report_target report_box_body(struct report_box *b);
void report_box_close(struct report_box *b);
bool report_section_begin(const char *name);
bool report_section_begin_at(struct report_target *tgt, const char *name);
bool report_section_claim(const char *name);
bool report_section_claim_at(struct report_target *tgt, const char *name);
void report_section_end(void);
const char * report_section_current(void);
void report_fields_begin(struct report_fields *g, struct report_target target, uint32_t keyw, uint32_t valw);
void report_field(struct report_fields *g, const char *key, const char *fmt);
void report_field_full(struct report_fields *g, const char *key, const char *fmt);
void report_fields_end(struct report_fields *g);
void report_panes_begin(struct report_panes *panes, uint32_t n, const uint8_t *weights);
void report_panes_undivided(struct report_panes *panes);
void report_panes_title(struct report_panes *panes, uint32_t pane, enum term_sev sev, const char *title);
void report_panes_top(struct report_panes *panes);
void report_panes_bottom(struct report_panes *panes, enum term_sev sev, const char *title);
void report_panes_carry(struct report_panes *panes);
void report_panes_flush(struct report_panes *panes);
uint16_t report_pane_rows(const struct report_panes *panes, uint32_t pane);
uint16_t report_panes_rows_max(const struct report_panes *panes);
struct report_panes * report_panes_panic(void);
void report_enter_panic(void);
#define REPORT_LINE_MAX 1024
#define REPORT_LINE(name, width) \
char name##_storage[REPORT_LINE_MAX]; \
struct report_line name; \
report_line_init(&name, name##_storage, sizeof(name##_storage), (width))
#define REPORT_FIELD_GAP 2
#define REPORT_PANES_MAX 3
#define REPORT_PANE_ROWS 48
#define REPORT_PANE_LINE_MAX 384
#define REPORT_PANE_MIN_WIDTH 24
#define REPORT_PANE_GAP 3