- mvwaddstr(scr->main_ncw, nc_scr_pos_title, 1, scr->frame.title);
+ ltitle_len = strlen(scr->frame.ltitle);
+ rtitle_len = scr->frame.rtitle ? strlen(scr->frame.rtitle) : 0;
+
+ /* if both ltitle and rtitle don't fit, trim rtitle */
+ if (ltitle_len + rtitle_len + nc_scr_pos_lrtitle_space > COLS - 2)
+ rtitle_len = COLS - 2 - ltitle_len - nc_scr_pos_lrtitle_space;
+
+ mvwaddstr(scr->main_ncw, nc_scr_pos_title, 1, scr->frame.ltitle);
+ mvwaddnstr(scr->main_ncw, nc_scr_pos_title, COLS - rtitle_len - 1,
+ scr->frame.rtitle, rtitle_len);