@@ -231,8 +231,17 @@ char *config_entry_editor(const char *title, const char *orig_entry) {
231231 print ("\n" );
232232 if (menu_branding [0 ] != '\0' ) {
233233 terms [0 ]-> get_cursor_pos (terms [0 ], & x , & y );
234- set_cursor_pos_helper ((terms [0 ]-> cols - strlen (menu_branding )) / 2 , y );
235- print ("\e[3%sm%s\e[0m" , menu_branding_colour , menu_branding );
234+ {
235+ size_t branding_len = strlen (menu_branding );
236+ size_t max_len = terms [0 ]-> cols - 2 ;
237+ if (branding_len <= max_len ) {
238+ set_cursor_pos_helper ((terms [0 ]-> cols - branding_len ) / 2 , y );
239+ print ("\e[3%sm%s\e[0m" , menu_branding_colour , menu_branding );
240+ } else {
241+ set_cursor_pos_helper (1 , y );
242+ print ("\e[3%sm%S...\e[0m" , menu_branding_colour , menu_branding , (size_t )(max_len - 3 ));
243+ }
244+ }
236245 print ("\n\n" );
237246 }
238247 terms [0 ]-> get_cursor_pos (terms [0 ], & x , & y );
@@ -1360,8 +1369,17 @@ noreturn void _menu(bool first_run) {
13601369 print ("\n" );
13611370 if (menu_branding [0 ] != '\0' ) {
13621371 terms [0 ]-> get_cursor_pos (terms [0 ], & x , & y );
1363- set_cursor_pos_helper ((terms [0 ]-> cols - strlen (menu_branding )) / 2 , y );
1364- print ("\e[3%sm%s\e[0m" , menu_branding_colour , menu_branding );
1372+ {
1373+ size_t branding_len = strlen (menu_branding );
1374+ size_t max_len = terms [0 ]-> cols - 2 ;
1375+ if (branding_len <= max_len ) {
1376+ set_cursor_pos_helper ((terms [0 ]-> cols - branding_len ) / 2 , y );
1377+ print ("\e[3%sm%s\e[0m" , menu_branding_colour , menu_branding );
1378+ } else {
1379+ set_cursor_pos_helper (1 , y );
1380+ print ("\e[3%sm%S...\e[0m" , menu_branding_colour , menu_branding , (size_t )(max_len - 3 ));
1381+ }
1382+ }
13651383 print ("\n\n\n\n" );
13661384 }
13671385 }
0 commit comments