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

Go to the source code of this file.

Data Structures

struct  notice_snapshot_t

Macros

#define FIRST_USE_LINE_COUNT   64
#define FIRST_USE_LINE_BYTES   512
#define FIRST_USE_CONTENT_COLUMNS   66

Functions

int ui_notice_render (frame_buffer_t *buffer, const char *text, ui_notice_severity_t severity, int cols, bool unicode, bool color)
const char * ui_notice_title (const void *data)
asciichat_error_t ui_notice_present (ui_notice_severity_t severity, const char *text)
asciichat_error_t ui_notice_present_first_use (const char *title, const char *text, const char *marker_path)
void ui_notice_frame_presented (const void *data)
ui_notice_key_result_t ui_notice_first_use_key (const void *data, int key)
void ui_notice_first_use_complete (const void *data)
bool ui_notice_confirm (ui_notice_severity_t severity, const char *text, unsigned timeout_seconds)
bool ui_notice_confirm_kind (ui_prompt_kind_t kind, ui_notice_severity_t severity, const char *text, unsigned timeout_seconds)
ui_prompt_kind_t ui_notice_prompt_kind (void)
ui_notice_severity_t ui_notice_prompt_severity (void)
void ui_notice_flush_snapshot (int fd, const void *data)
void ui_notice_dismiss (void)

Macro Definition Documentation

◆ FIRST_USE_CONTENT_COLUMNS

#define FIRST_USE_CONTENT_COLUMNS   66

Definition at line 214 of file notice.c.

◆ FIRST_USE_LINE_BYTES

#define FIRST_USE_LINE_BYTES   512

Definition at line 213 of file notice.c.

◆ FIRST_USE_LINE_COUNT

#define FIRST_USE_LINE_COUNT   64

Definition at line 212 of file notice.c.

Function Documentation

◆ ui_notice_confirm()

bool ui_notice_confirm ( ui_notice_severity_t severity,
const char * text,
unsigned timeout_seconds )

Explicitly styled yes/no prompt; default remains No.

Definition at line 542 of file notice.c.

543 {
544 return ui_notice_confirm_kind(UI_PROMPT_CONFIRMATION, severity, text,
545 timeout_seconds);
546}
bool ui_notice_confirm_kind(ui_prompt_kind_t kind, ui_notice_severity_t severity, const char *text, unsigned timeout_seconds)
Definition notice.c:548

References ui_notice_confirm_kind().

◆ ui_notice_confirm_kind()

bool ui_notice_confirm_kind ( ui_prompt_kind_t kind,
ui_notice_severity_t severity,
const char * text,
unsigned timeout_seconds )

Definition at line 548 of file notice.c.

550 {
551 ui_prompt_kind_t previous_kind = g_prompt_kind;
552 g_prompt_kind = kind;
553 ui_notice_severity_t previous = g_prompt_severity;
554 g_prompt_severity = severity;
555 if (terminal_can_prompt_user(!GET_OPTION(snapshot_mode)))
556 log_msg(severity == UI_NOTICE_FATAL ? LOG_FATAL
557 : severity == UI_NOTICE_DANGER ? LOG_ERROR
558 : severity == UI_NOTICE_WARNING ? LOG_WARN
559 : LOG_INFO,
560 __FILE__, __LINE__, __func__, "%s", text);
561 else
562 ui_notice_log(severity, __FILE__, __LINE__, __func__,
563 "CONFIRMATION REQUIRED", "%s", text);
564 bool accepted = platform_prompt_yes_no_timeout(text, false, timeout_seconds);
565 g_prompt_kind = previous_kind;
566 g_prompt_severity = previous;
567 return accepted;
568}
void log_msg(log_level_t level, const char *file, int line, const char *func, const char *fmt,...)
Log a message at a specific level.
Definition log/log.c:1313
#define GET_OPTION(field)
Definition options.h:1339
void ui_notice_log(ui_notice_severity_t severity, const char *file, int line, const char *func, const char *title, const char *format,...)
Definition log/log.c:1296
#define LOG_FATAL
Definition log/types.h:47
#define LOG_ERROR
Definition log/types.h:46
#define LOG_WARN
Definition log/types.h:45
#define LOG_INFO
Definition log/types.h:44
ui_notice_severity_t
Definition notice.h:13
@ UI_NOTICE_WARNING
Definition notice.h:15
@ UI_NOTICE_DANGER
Definition notice.h:16
@ UI_NOTICE_FATAL
Definition notice.h:17
bool terminal_can_prompt_user(bool user_setting)
bool platform_prompt_yes_no_timeout(const char *question, bool default_yes, unsigned timeout_seconds)
Definition util.c:95

References GET_OPTION, LOG_ERROR, LOG_FATAL, LOG_INFO, log_msg(), LOG_WARN, platform_prompt_yes_no_timeout(), terminal_can_prompt_user(), UI_NOTICE_DANGER, UI_NOTICE_FATAL, ui_notice_log(), and UI_NOTICE_WARNING.

Referenced by action_completions(), config_create_default(), discovery_keys_verify_change(), prompt_unknown_host(), prompt_unknown_host_no_identity(), and ui_notice_confirm().

◆ ui_notice_dismiss()

void ui_notice_dismiss ( void )

Definition at line 593 of file notice.c.

void ui_controller_remove(ui_screen_t screen)
@ UI_SCREEN_NOTICE

References ui_controller_remove(), and UI_SCREEN_NOTICE.

◆ ui_notice_first_use_complete()

void ui_notice_first_use_complete ( const void * data)

Definition at line 523 of file notice.c.

523 {
524 const notice_snapshot_t *notice = data;
525 if (!notice || !notice->marker_offset)
526 return;
528 FILE *marker = platform_fopen("first-use instructions",
529 notice->text + notice->marker_offset, "w");
530 if (!marker) {
531 log_warn("Could not save first-use instructions state; the notice may "
532 "appear again: %s",
533 notice->text + notice->marker_offset);
534 } else if (fclose(marker) != 0) {
535 log_warn("Could not finish saving first-use instructions state; the notice "
536 "may appear again: %s",
537 notice->text + notice->marker_offset);
538 }
540}
void errno_scope_end(asciichat_errno_scope_t scope, asciichat_errno_outcome_t outcome)
asciichat_errno_scope_t errno_scope_begin(void)
@ ASCIICHAT_ERRNO_DISMISSED
FILE * platform_fopen(const char *name, const char *filename, const char *mode)
Definition filesystem.c:18
#define log_warn(...)
Log a WARN message.
Definition log/log.h:591
When code needs to work with asciichat errno snapshot, it keeps total, copied here instead of scatter...
size_t marker_offset
Definition notice.c:186

References ASCIICHAT_ERRNO_DISMISSED, errno_scope_begin(), errno_scope_end(), log_warn, notice_snapshot_t::marker_offset, platform_fopen(), and notice_snapshot_t::text.

Referenced by ui_controller_first_use_key().

◆ ui_notice_first_use_key()

ui_notice_key_result_t ui_notice_first_use_key ( const void * data,
int key )

Definition at line 498 of file notice.c.

498 {
499 notice_snapshot_t *notice = (notice_snapshot_t *)data;
500 if (!notice || !notice->marker_offset)
502 if (key == KEY_ESCAPE || key == 'q' || key == 3)
504 if (key == KEY_QUESTION)
505 return UI_NOTICE_KEY_HELP;
506 int page = atomic_load(&notice->page);
507 int pages = atomic_load(&notice->pages);
508 if (key == KEY_LEFT && page > 0) {
509 atomic_store(&notice->presented_page, -1);
510 atomic_store(&notice->page, page - 1);
511 } else if ((key == '\r' || key == '\n' || key == KEY_RIGHT) && pages > 0 &&
512 atomic_load(&notice->presented_page) == page) {
513 if (page + 1 < pages) {
514 atomic_store(&notice->presented_page, -1);
515 atomic_store(&notice->page, page + 1);
516 } else if (key == '\r' || key == '\n') {
518 }
519 }
521}
@ UI_NOTICE_KEY_HELP
Definition notice.h:43
@ UI_NOTICE_KEY_ORDINARY
Definition notice.h:41
@ UI_NOTICE_KEY_DISMISS
Definition notice.h:44
@ UI_NOTICE_KEY_COMPLETE
Definition notice.h:45
@ UI_NOTICE_KEY_HANDLED
Definition notice.h:42
atomic_int page
Definition notice.c:188
atomic_int presented_page
Definition notice.c:190
atomic_int pages
Definition notice.c:189

References notice_snapshot_t::marker_offset, notice_snapshot_t::page, notice_snapshot_t::pages, notice_snapshot_t::presented_page, UI_NOTICE_KEY_COMPLETE, UI_NOTICE_KEY_DISMISS, UI_NOTICE_KEY_HANDLED, UI_NOTICE_KEY_HELP, and UI_NOTICE_KEY_ORDINARY.

Referenced by ui_controller_first_use_key().

◆ ui_notice_flush_snapshot()

void ui_notice_flush_snapshot ( int fd,
const void * snapshot )

Controller teardown writes pending notices to scrollback before releasing them.

Definition at line 576 of file notice.c.

576 {
577 const notice_snapshot_t *notice = data;
578 frame_buffer_t *buffer = frame_buffer_create(0, 0);
579 if (!buffer)
580 return;
581 if (platform_isatty(fd))
582 frame_buffer_append(buffer, "\033[0m\n", 5);
583 terminal_size_t size = {.cols = 80};
584 if (platform_isatty(fd))
585 (void)terminal_get_size_fd(fd, &size);
586 ui_notice_render(buffer, notice->text, notice->severity, size.cols,
587 notice->unicode, notice->color);
588 platform_write_all(fd, frame_buffer_get_content(buffer),
590 frame_buffer_destroy(buffer);
591}
void frame_buffer_append(frame_buffer_t *buf, const char *str, size_t len)
Append raw bytes to the buffer.
void frame_buffer_destroy(frame_buffer_t *buf)
Destroy a frame buffer.
size_t frame_buffer_get_length(const frame_buffer_t *buf)
Get the current content length of the frame buffer.
const char * frame_buffer_get_content(const frame_buffer_t *buf)
Get a pointer to the buffer content.
frame_buffer_t * frame_buffer_create(int rows, int cols)
Create a new frame buffer.
struct frame_buffer frame_buffer_t
Opaque frame buffer handle.
int ui_notice_render(frame_buffer_t *buffer, const char *text, ui_notice_severity_t severity, int cols, bool unicode, bool color)
Definition notice.c:66
int terminal_get_size_fd(int fd, terminal_size_t *size)
ui_notice_severity_t severity
Definition notice.c:182
int platform_isatty(int fd)
Definition util.c:70

References notice_snapshot_t::color, frame_buffer_append(), frame_buffer_create(), frame_buffer_destroy(), frame_buffer_get_content(), frame_buffer_get_length(), platform_isatty(), notice_snapshot_t::severity, terminal_get_size_fd(), notice_snapshot_t::text, ui_notice_render(), and notice_snapshot_t::unicode.

◆ ui_notice_frame_presented()

void ui_notice_frame_presented ( const void * snapshot)

Record which first-use page reached the terminal after a successful frame.

Definition at line 492 of file notice.c.

492 {
493 notice_snapshot_t *notice = (notice_snapshot_t *)data;
494 if (notice && notice->marker_offset)
495 atomic_store(&notice->presented_page, notice->rendered_page);
496}

References notice_snapshot_t::marker_offset, notice_snapshot_t::presented_page, and notice_snapshot_t::rendered_page.

◆ ui_notice_present()

asciichat_error_t ui_notice_present ( ui_notice_severity_t severity,
const char * text )

Present a notice without changing authentication or input policy.

Definition at line 397 of file notice.c.

398 {
399 if (!text)
400 return SET_ERRNO(ERROR_INVALID_PARAM, "Missing notice text");
401 bool tty = platform_isatty(STDERR_FILENO);
402 bool color =
403 !GET_OPTION(strip_ansi) &&
405 bool unicode = tty && terminal_should_use_utf8(GET_OPTION(force_utf8));
406 if (severity != UI_NOTICE_FATAL && tty && ui_controller_is_presenting() &&
407 !ui_controller_is_owner() && !GET_OPTION(snapshot_mode)) {
408 size_t text_bytes = strlen(text) + 1;
409 size_t bytes = sizeof(notice_snapshot_t) + text_bytes;
410 notice_snapshot_t *snapshot = SAFE_MALLOC(bytes, notice_snapshot_t *);
411 if (!snapshot)
412 return SET_ERRNO(ERROR_MEMORY, "Cannot allocate notice");
413 snapshot->severity = severity;
414 snapshot->unicode = unicode;
415 snapshot->color = color;
416 snapshot->started = time_get_ns();
417 snapshot->marker_offset = snapshot->title_offset = 0;
418 atomic_init(&snapshot->page, 0);
419 atomic_init(&snapshot->pages, 0);
420 atomic_init(&snapshot->presented_page, -1);
421 snapshot->rendered_page = -1;
422 snapshot->rendered_cols = snapshot->rendered_rows = 0;
423 memcpy(snapshot->text, text, text_bytes);
424 asciichat_error_t result =
426 (terminal_size_t){.cols = 1, .rows = 1},
427 render_notice, snapshot, bytes);
428 SAFE_FREE(snapshot);
429 return result;
430 }
431 frame_buffer_t *buffer = frame_buffer_create(0, 0);
432 if (!buffer)
433 return SET_ERRNO(ERROR_MEMORY, "Cannot allocate notice buffer");
434 if (severity == UI_NOTICE_FATAL && tty)
435 frame_buffer_append(buffer, "\033[0m\033[?25h\r\n", 12);
436 int cols = tty ? ui_controller_size().cols : 80;
437 ui_notice_render(buffer, text, severity, cols, unicode, color);
439 if (severity == UI_NOTICE_FATAL && !ui_controller_is_owner())
440 ui_controller_finish(STDERR_FILENO, frame_buffer_get_content(buffer),
442 else
443 result =
444 ui_controller_write(STDERR_FILENO, frame_buffer_get_content(buffer),
446 frame_buffer_destroy(buffer);
447 return result;
448}
#define SET_ERRNO(code,...)
#define SAFE_FREE(ptr)
#define SAFE_MALLOC(size, cast)
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
@ ERROR_MEMORY
Definition error_codes.h:55
@ ASCIICHAT_OK
Definition error_codes.h:50
@ ERROR_INVALID_PARAM
#define options_terminal_settings()
Definition options.h:1287
bool terminal_should_color_output(int fd, const terminal_options_t *options)
bool terminal_should_use_utf8(terminal_utf8_setting_t user_setting)
uint64_t started
Definition notice.c:185
size_t title_offset
Definition notice.c:187
asciichat_error_t ui_controller_submit(ui_screen_t screen, int fd, terminal_size_t minimum, ui_render_fn render, const void *snapshot, size_t bytes)
bool ui_controller_is_presenting(void)
bool ui_controller_is_owner(void)
void ui_controller_finish(int fd, const char *data, size_t len)
terminal_size_t ui_controller_size(void)
asciichat_error_t ui_controller_write(int fd, const char *data, size_t len)

References ASCIICHAT_OK, notice_snapshot_t::color, ERROR_INVALID_PARAM, ERROR_MEMORY, frame_buffer_append(), frame_buffer_create(), frame_buffer_destroy(), frame_buffer_get_content(), frame_buffer_get_length(), GET_OPTION, notice_snapshot_t::marker_offset, options_terminal_settings, notice_snapshot_t::page, notice_snapshot_t::pages, platform_isatty(), notice_snapshot_t::presented_page, notice_snapshot_t::rendered_cols, notice_snapshot_t::rendered_page, notice_snapshot_t::rendered_rows, SAFE_FREE, SAFE_MALLOC, SET_ERRNO, notice_snapshot_t::severity, notice_snapshot_t::started, terminal_should_color_output(), terminal_should_use_utf8(), notice_snapshot_t::text, notice_snapshot_t::title_offset, ui_controller_finish(), ui_controller_is_owner(), ui_controller_is_presenting(), ui_controller_size(), ui_controller_submit(), ui_controller_write(), UI_NOTICE_FATAL, ui_notice_render(), UI_SCREEN_NOTICE, and notice_snapshot_t::unicode.

◆ ui_notice_present_first_use()

asciichat_error_t ui_notice_present_first_use ( const char * title,
const char * text,
const char * marker_path )

Show a first-use notice until the user dismisses it.

Definition at line 450 of file notice.c.

452 {
453 if (!title || !text || !marker_path || !platform_isatty(STDERR_FILENO) ||
454 GET_OPTION(snapshot_mode))
455 return SET_ERRNO(
457 "First-use notice requires an interactive terminal and marker path");
458 size_t text_bytes = strlen(text) + 1, title_bytes = strlen(title) + 1,
459 marker_bytes = strlen(marker_path) + 1;
460 if (title_bytes > SIZE_MAX - marker_bytes - sizeof(notice_snapshot_t) ||
461 text_bytes >
462 SIZE_MAX - title_bytes - marker_bytes - sizeof(notice_snapshot_t))
463 return SET_ERRNO(ERROR_BUFFER_OVERFLOW, "First-use notice is too large");
464 size_t bytes =
465 sizeof(notice_snapshot_t) + text_bytes + title_bytes + marker_bytes;
466 notice_snapshot_t *snapshot = SAFE_MALLOC(bytes, notice_snapshot_t *);
467 if (!snapshot)
468 return SET_ERRNO(ERROR_MEMORY, "Cannot allocate first-use notice");
469 snapshot->severity = UI_NOTICE_INFO;
470 snapshot->unicode = terminal_should_use_utf8(GET_OPTION(force_utf8));
471 snapshot->color =
472 !GET_OPTION(strip_ansi) &&
474 snapshot->started = time_get_ns();
475 snapshot->title_offset = text_bytes;
476 snapshot->marker_offset = text_bytes + title_bytes;
477 atomic_init(&snapshot->page, 0);
478 atomic_init(&snapshot->pages, 0);
479 atomic_init(&snapshot->presented_page, -1);
480 snapshot->rendered_page = -1;
481 snapshot->rendered_cols = snapshot->rendered_rows = 0;
482 memcpy(snapshot->text, text, text_bytes);
483 memcpy(snapshot->text + text_bytes, title, title_bytes);
484 memcpy(snapshot->text + snapshot->marker_offset, marker_path, marker_bytes);
486 UI_SCREEN_NOTICE, STDERR_FILENO, (terminal_size_t){.cols = 20, .rows = 8},
487 render_notice, snapshot, bytes);
488 SAFE_FREE(snapshot);
489 return result;
490}
@ ERROR_BUFFER_OVERFLOW
@ UI_NOTICE_INFO
Definition notice.h:14

References notice_snapshot_t::color, ERROR_BUFFER_OVERFLOW, ERROR_INVALID_PARAM, ERROR_MEMORY, GET_OPTION, notice_snapshot_t::marker_offset, options_terminal_settings, notice_snapshot_t::page, notice_snapshot_t::pages, platform_isatty(), notice_snapshot_t::presented_page, notice_snapshot_t::rendered_cols, notice_snapshot_t::rendered_page, notice_snapshot_t::rendered_rows, SAFE_FREE, SAFE_MALLOC, SET_ERRNO, notice_snapshot_t::severity, notice_snapshot_t::started, terminal_should_color_output(), terminal_should_use_utf8(), notice_snapshot_t::text, notice_snapshot_t::title_offset, ui_controller_submit(), UI_NOTICE_INFO, UI_SCREEN_NOTICE, and notice_snapshot_t::unicode.

◆ ui_notice_prompt_kind()

ui_prompt_kind_t ui_notice_prompt_kind ( void )

Definition at line 570 of file notice.c.

570{ return g_prompt_kind; }

◆ ui_notice_prompt_severity()

ui_notice_severity_t ui_notice_prompt_severity ( void )

Definition at line 572 of file notice.c.

572 {
573 return g_prompt_severity;
574}

Referenced by ui_prompt_present_kind().

◆ ui_notice_render()

int ui_notice_render ( frame_buffer_t * buffer,
const char * text,
ui_notice_severity_t severity,
int cols,
bool unicode,
bool color )

Append a complete box, or measure it when buffer is NULL. Returns its row count. Text is plain UTF-8. Terminal control characters are made visible, never executed.

Definition at line 66 of file notice.c.

68 {
69 if (!text)
70 text = "";
71 const char *body = text;
72 text = notice_label(severity);
73 bool rendering_label = true;
74 const char *text_end = text + strlen(text);
75 // Reserve the final column to avoid terminal autowrap at the right border.
76 int width = cols > 81 ? 80 : cols - 1;
77 bool boxed = width >= 8;
78 int content = boxed ? width - 4 : (cols > 2 ? cols - 1 : 2);
79 const char *side = unicode ? "║" : "|";
80 if (buffer && color)
81 frame_buffer_printf(buffer, "\033[1m%s", notice_color(severity));
82 if (boxed)
83 border(buffer, width, UI_POPUP_TOP, unicode, severity, color);
84 int rows = boxed ? 2 : 0;
85 const char *art_end = NULL;
86 const char *word_end = NULL;
87 bool title_word = false;
88 bool first_letter = false;
89 do {
90 // The Keymask formatter identifies complete plain-text blocks; input ANSI
91 // escapes still pass through the normal control-character sanitization.
92 const char *block_end = key_identity_art_end(text);
93 if (block_end)
94 art_end = block_end;
95 bool neutral = art_end && text < art_end;
96 int used = 0;
97 if (buffer && boxed)
98 frame_buffer_printf(buffer, "%s ", side);
99 if (buffer && color && neutral)
100 frame_buffer_append(buffer, "\033[0;39m", 7);
101 while (*text && *text != '\n') {
102 int bytes = utf8_next_char_bytes(text, (size_t)(text_end - text));
103 if (bytes <= 0)
104 bytes = 1;
105 bool control =
106 (unsigned char)*text < 32 || (unsigned char)*text == 127 ||
107 (bytes == 2 && (unsigned char)text[0] == 0xc2 &&
108 (unsigned char)text[1] >= 0x80 && (unsigned char)text[1] <= 0x9f);
109 int cells = control ? 1 : utf8_display_width_n(text, (size_t)bytes);
110 if (cells < 0)
111 cells = 1;
112 if (used + cells > content && used)
113 break;
114 if (buffer) {
115 if (control)
116 frame_buffer_append(buffer, "?", 1);
117 else if (!rendering_label && !neutral) {
118 if (!word_end || text >= word_end) {
119 word_end = text;
120 title_word = (*text >= 'A' && *text <= 'Z') ||
121 (*text >= 'a' && *text <= 'z');
122 first_letter = true;
123 while (*word_end && *word_end != ' ' && *word_end != '\n' &&
124 *word_end != '\t') {
125 unsigned char c = (unsigned char)*word_end;
126 bool letter = (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
127 bool punctuation =
128 strchr(",.;:!?", c) &&
129 (!word_end[1] || word_end[1] == ' ' || word_end[1] == '\n');
130 if (!letter && !punctuation)
131 title_word = false;
132 ++word_end;
133 }
134 }
135 if (title_word && bytes == 1) {
136 char c = *text;
137 if (first_letter && c >= 'a' && c <= 'z')
138 c -= 'a' - 'A';
139 else if (!first_letter && c >= 'A' && c <= 'Z')
140 c += 'a' - 'A';
141 first_letter = false;
142 frame_buffer_append(buffer, &c, 1);
143 } else {
144 frame_buffer_append(buffer, text, (size_t)bytes);
145 }
146 } else
147 frame_buffer_append(buffer, text, (size_t)bytes);
148 }
149 used += cells;
150 text += bytes;
151 }
152 if (buffer) {
153 if (color && neutral)
154 frame_buffer_printf(buffer, "\033[1m%s", notice_color(severity));
155 if (boxed)
156 frame_buffer_printf(buffer, "%*s %s", content - used, "", side);
157 frame_buffer_append(buffer, "\n", 1);
158 }
159 ++rows;
160 if (*text == '\n')
161 ++text;
162 if (!*text) {
163 if (!rendering_label)
164 break;
165 if (boxed) {
166 border(buffer, width, UI_POPUP_SEPARATOR, unicode, severity, color);
167 ++rows;
168 }
169 rendering_label = false;
170 text = body;
171 text_end = text + strlen(text);
172 }
173 } while (true);
174 if (boxed)
175 border(buffer, width, UI_POPUP_BOTTOM, unicode, severity, color);
176 if (buffer && color)
177 frame_buffer_append(buffer, "\033[0m", 4);
178 return rows;
179}
char cells[(512 *256 *2)]
Definition fft.c:22
unsigned int width
Definition fft.c:24
void frame_buffer_printf(frame_buffer_t *buf, const char *fmt,...)
Printf-style append to the buffer.
int utf8_display_width_n(const char *str, size_t max_bytes)
Calculate terminal display width of a UTF-8 string up to byte limit.
Definition utf8.c:106
int utf8_next_char_bytes(const char *str, size_t max_bytes)
Get byte length of next UTF-8 character.
Definition utf8.c:183
const char * key_identity_art_end(const char *text)
@ UI_POPUP_BOTTOM
Definition popup.h:16
@ UI_POPUP_SEPARATOR
Definition popup.h:15
@ UI_POPUP_TOP
Definition popup.h:14

References cells, frame_buffer_append(), frame_buffer_printf(), key_identity_art_end(), UI_POPUP_BOTTOM, UI_POPUP_SEPARATOR, UI_POPUP_TOP, utf8_display_width_n(), utf8_next_char_bytes(), and width.

Referenced by ui_notice_flush_snapshot(), ui_notice_present(), ui_prompt_present_kind(), and ui_prompt_required_rows().

◆ ui_notice_title()

const char * ui_notice_title ( const void * data)

Definition at line 203 of file notice.c.

203 {
204 const notice_snapshot_t *notice = data;
205 return notice->severity == UI_NOTICE_WARNING ? "warning"
206 : notice->severity == UI_NOTICE_DANGER ||
207 notice->severity == UI_NOTICE_FATAL
208 ? "error"
209 : "notice";
210}

References notice_snapshot_t::severity, UI_NOTICE_DANGER, UI_NOTICE_FATAL, and UI_NOTICE_WARNING.