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

Go to the source code of this file.

Data Structures

struct  errno_tui_row_t
struct  errno_tui_state_t
 The useful part of errno tui row is in context, resolved_ns, group_id, group_timestamp: together they describe what is pending, who owns it, and how much data is valid. Keep the object with its parent operation and use the parent cleanup path. More...

Macros

#define TUI_ERRNO_STACKS_FOOTER_BUFFER_SIZE   512
#define TUI_ERRNO_STACKS_HEADER_BUFFER_SIZE   768
#define TUI_ERRNO_STACKS_TABS_BUFFER_SIZE   256
#define TUI_ERRNO_STACKS_COLUMNS_BUFFER_SIZE   256
#define TUI_ERRNO_STACKS_THREAD_NAME_BUFFER_SIZE   256
#define TUI_ERRNO_STACKS_THREAD_BUFFER_SIZE   256
#define TUI_ERRNO_STACKS_MESSAGE_BUFFER_SIZE   256
#define TUI_ERRNO_STACKS_USER_BUFFER_SIZE   256
#define TUI_ERRNO_STACKS_AGE_BUFFER_SIZE   96
#define TUI_ERRNO_STACKS_OUTCOMES_BUFFER_SIZE   128
#define TUI_ERRNO_STACKS_CODE_BUFFER_SIZE   48
#define TUI_ERRNO_STACKS_LINE_BUFFER_SIZE   2048
#define ERRNO_TUI_MIN_COLS   88
#define ERRNO_TUI_MIN_ROWS   10
#define ERRNO_TUI_MAX_ROWS    (ASCIICHAT_ERRNO_MAX_FRAMES + ASCIICHAT_ERRNO_HISTORY_SIZE)
#define ERRNO_TUI_TABLE_BASE_WIDTH   114
#define ERRNO_TUI_THREAD_BASE_WIDTH   14
#define ERRNO_TUI_THREAD_MAX_WIDTH   24
#define ERRNO_TUI_MESSAGE_BASE_WIDTH   23
#define ERRNO_TUI_MESSAGE_MAX_WIDTH   38

Enumerations

enum  errno_tui_tab_t { ERRNO_TUI_CURRENT , ERRNO_TUI_HISTORY }

Functions

void ui_errno_stacks_toggle (void)
void ui_errno_stacks_hide (void)
bool ui_errno_stacks_visible (void)
bool ui_errno_stacks_handle_key (keyboard_key_t key)

Macro Definition Documentation

◆ ERRNO_TUI_MAX_ROWS

#define ERRNO_TUI_MAX_ROWS    (ASCIICHAT_ERRNO_MAX_FRAMES + ASCIICHAT_ERRNO_HISTORY_SIZE)

Definition at line 43 of file errno_stacks.c.

43#define ERRNO_TUI_MAX_ROWS \
44 (ASCIICHAT_ERRNO_MAX_FRAMES + ASCIICHAT_ERRNO_HISTORY_SIZE)

◆ ERRNO_TUI_MESSAGE_BASE_WIDTH

#define ERRNO_TUI_MESSAGE_BASE_WIDTH   23

Definition at line 48 of file errno_stacks.c.

◆ ERRNO_TUI_MESSAGE_MAX_WIDTH

#define ERRNO_TUI_MESSAGE_MAX_WIDTH   38

Definition at line 49 of file errno_stacks.c.

◆ ERRNO_TUI_MIN_COLS

#define ERRNO_TUI_MIN_COLS   88

Definition at line 41 of file errno_stacks.c.

◆ ERRNO_TUI_MIN_ROWS

#define ERRNO_TUI_MIN_ROWS   10

Definition at line 42 of file errno_stacks.c.

◆ ERRNO_TUI_TABLE_BASE_WIDTH

#define ERRNO_TUI_TABLE_BASE_WIDTH   114

Definition at line 45 of file errno_stacks.c.

◆ ERRNO_TUI_THREAD_BASE_WIDTH

#define ERRNO_TUI_THREAD_BASE_WIDTH   14

Definition at line 46 of file errno_stacks.c.

◆ ERRNO_TUI_THREAD_MAX_WIDTH

#define ERRNO_TUI_THREAD_MAX_WIDTH   24

Definition at line 47 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_AGE_BUFFER_SIZE

#define TUI_ERRNO_STACKS_AGE_BUFFER_SIZE   96

Definition at line 11 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_CODE_BUFFER_SIZE

#define TUI_ERRNO_STACKS_CODE_BUFFER_SIZE   48

Definition at line 13 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_COLUMNS_BUFFER_SIZE

#define TUI_ERRNO_STACKS_COLUMNS_BUFFER_SIZE   256

Definition at line 6 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_FOOTER_BUFFER_SIZE

#define TUI_ERRNO_STACKS_FOOTER_BUFFER_SIZE   512

Definition at line 3 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_HEADER_BUFFER_SIZE

#define TUI_ERRNO_STACKS_HEADER_BUFFER_SIZE   768

Definition at line 4 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_LINE_BUFFER_SIZE

#define TUI_ERRNO_STACKS_LINE_BUFFER_SIZE   2048

Definition at line 14 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_MESSAGE_BUFFER_SIZE

#define TUI_ERRNO_STACKS_MESSAGE_BUFFER_SIZE   256

Definition at line 9 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_OUTCOMES_BUFFER_SIZE

#define TUI_ERRNO_STACKS_OUTCOMES_BUFFER_SIZE   128

Definition at line 12 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_TABS_BUFFER_SIZE

#define TUI_ERRNO_STACKS_TABS_BUFFER_SIZE   256

Definition at line 5 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_THREAD_BUFFER_SIZE

#define TUI_ERRNO_STACKS_THREAD_BUFFER_SIZE   256

Definition at line 8 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_THREAD_NAME_BUFFER_SIZE

#define TUI_ERRNO_STACKS_THREAD_NAME_BUFFER_SIZE   256

Definition at line 7 of file errno_stacks.c.

◆ TUI_ERRNO_STACKS_USER_BUFFER_SIZE

#define TUI_ERRNO_STACKS_USER_BUFFER_SIZE   256

Definition at line 10 of file errno_stacks.c.

Enumeration Type Documentation

◆ errno_tui_tab_t

Enumerator
ERRNO_TUI_CURRENT 
ERRNO_TUI_HISTORY 

Definition at line 51 of file errno_stacks.c.

errno_tui_tab_t
@ ERRNO_TUI_CURRENT
@ ERRNO_TUI_HISTORY

Function Documentation

◆ ui_errno_stacks_handle_key()

bool ui_errno_stacks_handle_key ( keyboard_key_t key)

Returns true when a visible errno-stack UI consumed the key.

Definition at line 517 of file errno_stacks.c.

517 {
520 return false;
521 if (!state_lock())
522 return false;
523 if (key == KEY_BACKTICK || key == KEY_ESCAPE) {
524 g_state.visible = false;
525 state_unlock();
527 return true;
528 }
529 if (key == '\t') {
530 g_state.tab = g_state.tab == ERRNO_TUI_CURRENT ? ERRNO_TUI_HISTORY
532 ui_selectable_list_reset(&g_state.list);
533 } else if (key == 's' || key == 'S') {
534 g_state.stack_sort = !g_state.stack_sort;
535 ui_selectable_list_reset(&g_state.list);
536 } else if (key == KEY_UP || key == 'k') {
537 ui_selectable_list_move(&g_state.list, g_state.count, g_state.rows, -1);
538 } else if (key == KEY_DOWN || key == 'j') {
539 ui_selectable_list_move(&g_state.list, g_state.count, g_state.rows, 1);
540 } else if (key == 'x' || key == 'X') {
541 errno_tui_state_t state = g_state;
542 state_unlock();
543 if (state.selected_current)
547 publish();
548 return true;
549 } else {
550 state_unlock();
551 return false;
552 }
553 state_unlock();
554 publish();
555 return true;
556}
bool errno_clear_if_current(uint64_t id, uint64_t generation, uint64_t error_id)
bool ui_errno_stacks_visible(void)
void ui_selectable_list_move(ui_selectable_list_t *list, int count, int rows, int delta)
void ui_selectable_list_reset(ui_selectable_list_t *list)
The useful part of errno tui row is in context, resolved_ns, group_id, group_timestamp: together they...
asciichat_error_context_t selected_context
void ui_controller_remove(ui_screen_t screen)
int ui_controller_current_screen(void)
@ UI_SCREEN_ERRNO

References errno_clear_if_current(), ERRNO_TUI_CURRENT, ERRNO_TUI_HISTORY, asciichat_error_context_t::error_id, asciichat_error_context_t::generation, errno_tui_state_t::selected_context, errno_tui_state_t::selected_current, asciichat_error_context_t::thread_id, ui_controller_current_screen(), ui_controller_remove(), ui_errno_stacks_visible(), UI_SCREEN_ERRNO, ui_selectable_list_move(), and ui_selectable_list_reset().

Referenced by ui_status_display_interactive().

◆ ui_errno_stacks_hide()

void ui_errno_stacks_hide ( void )

Definition at line 501 of file errno_stacks.c.

501 {
502 if (!state_lock())
503 return;
504 g_state.visible = false;
505 state_unlock();
507}

References ui_controller_remove(), and UI_SCREEN_ERRNO.

Referenced by ui_controller_toggle_logs().

◆ ui_errno_stacks_toggle()

void ui_errno_stacks_toggle ( void )

Toggle the diagnostic errno-stack terminal UI. Available only in diagnostic builds.

Definition at line 483 of file errno_stacks.c.

483 {
484#if defined(ASCIICHAT_DIAGNOSTIC_UI)
485 if (!state_lock())
486 return;
487 g_state.visible = !g_state.visible;
488 if (g_state.visible)
489 ui_selectable_list_reset(&g_state.list);
490 if (g_state.visible)
491 g_state.output_fd = ui_controller_active_fd();
492 bool visible = g_state.visible;
493 state_unlock();
494 if (visible)
495 publish();
496 else
498#endif
499}
int ui_controller_active_fd(void)

References ui_controller_active_fd(), ui_controller_remove(), UI_SCREEN_ERRNO, and ui_selectable_list_reset().

Referenced by ui_status_display_interactive().

◆ ui_errno_stacks_visible()

bool ui_errno_stacks_visible ( void )

Definition at line 509 of file errno_stacks.c.

509 {
510 if (!state_lock())
511 return false;
512 bool visible = g_state.visible;
513 state_unlock();
514 return visible;
515}

Referenced by ui_errno_stacks_handle_key().