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

Go to the source code of this file.

Macros

#define TUI_SESSION_SPLASH_TAGLINE_WITH_VERSION_BUFFER_SIZE   128
#define TUI_SESSION_SPLASH_PLAIN_TAGLINE_BUFFER_SIZE   512
#define TUI_SESSION_SPLASH_PLAIN_UPDATE_BUFFER_SIZE   1024
#define TUI_SESSION_SPLASH_PLAIN_CONNECTION_BUFFER_SIZE   512

Functions

void ui_session_splash_render (frame_buffer_t *buf, terminal_size_t term_size, void *user_data)

Macro Definition Documentation

◆ TUI_SESSION_SPLASH_PLAIN_CONNECTION_BUFFER_SIZE

#define TUI_SESSION_SPLASH_PLAIN_CONNECTION_BUFFER_SIZE   512

Definition at line 6 of file session_splash.c.

Referenced by ui_session_splash_render().

◆ TUI_SESSION_SPLASH_PLAIN_TAGLINE_BUFFER_SIZE

#define TUI_SESSION_SPLASH_PLAIN_TAGLINE_BUFFER_SIZE   512

Definition at line 4 of file session_splash.c.

Referenced by ui_session_splash_render().

◆ TUI_SESSION_SPLASH_PLAIN_UPDATE_BUFFER_SIZE

#define TUI_SESSION_SPLASH_PLAIN_UPDATE_BUFFER_SIZE   1024

Definition at line 5 of file session_splash.c.

Referenced by ui_session_splash_render().

◆ TUI_SESSION_SPLASH_TAGLINE_WITH_VERSION_BUFFER_SIZE

#define TUI_SESSION_SPLASH_TAGLINE_WITH_VERSION_BUFFER_SIZE   128

Definition at line 3 of file session_splash.c.

Referenced by ui_session_splash_render().

Function Documentation

◆ ui_session_splash_render()

void ui_session_splash_render ( frame_buffer_t * buf,
terminal_size_t term_size,
void * user_data )

Definition at line 19 of file session_splash.c.

19 {
20 const ui_splash_view_t *ctx = (const ui_splash_view_t *)user_data;
21 if (!ctx) {
22 return;
23 }
24 bool unicode = terminal_should_use_utf8(GET_OPTION(force_utf8));
25
26 if (ctx->discovery.enabled) {
28 (int)(ctx->animation.seconds * 60), ctx->use_colors);
29 return;
30 }
31
33 snprintf(tagline_with_version, sizeof(tagline_with_version), "Video chat in your terminal + %s",
34 ASCII_CHAT_VERSION_STRING);
35 const char *tagline = tagline_with_version;
36 frame_buffer_render_divider(buf, term_size.cols - 1, unicode, ctx->use_colors);
37 invitation_render_logo(buf, term_size.cols - 1, (int)(ctx->animation.seconds * 60), ctx->use_colors, false);
38
39 // Line 6: Tagline (centered, truncated if too long)
41 int tagline_len = (int)strlen(tagline);
42 int tagline_pad = (term_size.cols - tagline_len) / 2;
43 if (tagline_pad < 0) {
44 tagline_pad = 0;
45 }
46
47 int tpos = 0;
48 for (int j = 0; j < tagline_pad && tpos < (int)sizeof(plain_tagline) - 1; j++) {
49 plain_tagline[tpos++] = ' ';
50 }
51 snprintf(plain_tagline + tpos, sizeof(plain_tagline) - tpos, "%s", tagline);
52
53 // Check visible width and truncate if needed
54 int tagline_visible_width = display_width(plain_tagline);
55 if (tagline_visible_width < 0) {
56 tagline_visible_width = (int)strlen(plain_tagline);
57 }
58 if (term_size.cols > 0 && tagline_visible_width >= term_size.cols) {
59 plain_tagline[term_size.cols - 1] = '\0';
60 }
61
62 frame_buffer_printf(buf, "%s\n", plain_tagline);
63
64 // Line 7: Update notification (if available)
65 if (ctx->update_notification[0] != '\0') {
67 int update_len = (int)strlen(ctx->update_notification);
68 int update_pad = (term_size.cols - update_len) / 2;
69 if (update_pad < 0) {
70 update_pad = 0;
71 }
72
73 int upos = 0;
74 for (int j = 0; j < update_pad && upos < (int)sizeof(plain_update) - 1; j++) {
75 plain_update[upos++] = ' ';
76 }
77 snprintf(plain_update + upos, sizeof(plain_update) - upos, "%s", ctx->update_notification);
78
79 // Check visible width and truncate if needed
80 int update_visible_width = display_width(plain_update);
81 if (update_visible_width < 0) {
82 update_visible_width = (int)strlen(plain_update);
83 }
84 if (term_size.cols > 0 && update_visible_width >= term_size.cols) {
85 plain_update[term_size.cols - 1] = '\0';
86 }
87
88 // Print in yellow/warning color
89 frame_buffer_printf(buf, "%s\n", colored_string(LOG_COLOR_WARN, plain_update));
90 }
91
92 // Line 8 (or 7 if no update): Connection target (centered, truncated if too long)
93 const char *connection_target = ctx->connection_target;
94
96 int connection_len = (int)strlen(connection_target);
97 int connection_pad = (term_size.cols - connection_len) / 2;
98 if (connection_pad < 0) {
99 connection_pad = 0;
100 }
101
102 int cpos = 0;
103 for (int j = 0; j < connection_pad && cpos < (int)sizeof(plain_connection) - 1; j++) {
104 plain_connection[cpos++] = ' ';
105 }
106 snprintf(plain_connection + cpos, sizeof(plain_connection) - cpos, "%s", connection_target);
107
108 // Check visible width and truncate if needed
109 int connection_visible_width = display_width(plain_connection);
110 if (connection_visible_width < 0) {
111 connection_visible_width = (int)strlen(plain_connection);
112 }
113 if (term_size.cols > 0 && connection_visible_width >= term_size.cols) {
114 plain_connection[term_size.cols - 1] = '\0';
115 }
116
117 frame_buffer_printf(buf, "%s\n", plain_connection);
118
120 static const char spin[] = "|/-\\";
121 const char *text = "Checking for updates...";
122 int pad = term_size.cols - (int)strlen(text) - 3;
123 if (pad < 0)
124 pad = 0;
125 frame_buffer_printf(buf, "%*s%c %s\n", pad, "", spin[((int)(ctx->animation.seconds * 8)) % 4], text);
126 }
127
128 // Bottom border
129 frame_buffer_render_divider(buf, term_size.cols - 1, unicode, ctx->use_colors);
130}
void frame_buffer_render_divider(frame_buffer_t *buf, int width, bool use_utf8, bool use_colors)
void frame_buffer_printf(frame_buffer_t *buf, const char *fmt,...)
Printf-style append to the buffer.
@ LOG_COLOR_WARN
Definition log/log.h:151
#define GET_OPTION(field)
Safely get a specific option field (lock-free read).
Definition options.h:1336
bool update_banner_is_checking(void)
const char * colored_string(log_color_t color, const char *text)
Build a colored string for terminal output.
Definition string.c:284
int display_width(const char *text)
Calculate the visible display width of text with ANSI escape codes.
void invitation_render_logo(frame_buffer_t *buf, int cols, int frame, bool colors, bool compact)
Definition invitation.c:34
void invitation_render(frame_buffer_t *buf, terminal_size_t size, const char *session, bool joining, int frame, bool colors)
Definition invitation.c:58
#define TUI_SESSION_SPLASH_PLAIN_CONNECTION_BUFFER_SIZE
#define TUI_SESSION_SPLASH_PLAIN_TAGLINE_BUFFER_SIZE
#define TUI_SESSION_SPLASH_PLAIN_UPDATE_BUFFER_SIZE
#define TUI_SESSION_SPLASH_TAGLINE_WITH_VERSION_BUFFER_SIZE

References ui_splash_view_t::animation, colored_string(), ui_splash_view_t::connection_target, ui_splash_view_t::discovery, display_width(), ui_discovery_view_t::enabled, frame_buffer_printf(), frame_buffer_render_divider(), GET_OPTION, invitation_render(), invitation_render_logo(), ui_discovery_view_t::joining, LOG_COLOR_WARN, animation_sample_t::seconds, ui_discovery_view_t::session_string, TUI_SESSION_SPLASH_PLAIN_CONNECTION_BUFFER_SIZE, TUI_SESSION_SPLASH_PLAIN_TAGLINE_BUFFER_SIZE, TUI_SESSION_SPLASH_PLAIN_UPDATE_BUFFER_SIZE, TUI_SESSION_SPLASH_TAGLINE_WITH_VERSION_BUFFER_SIZE, update_banner_is_checking(), ui_splash_view_t::update_notification, and ui_splash_view_t::use_colors.