Compare commits
1 Commits
de172f3533
...
adb078a3e2
| Author | SHA1 | Date | |
|---|---|---|---|
|
adb078a3e2
|
@@ -67,6 +67,23 @@ _win_ensure_pad_capacity(ProfWin* window, WINDOW* win, int lines_needed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// upper-bound estimate of rows a message body occupies (hard newlines + soft-wrap), to reserve pad space before printing so a tall message isn't clipped (a clipped height desyncs the scroll offset)
|
||||
static int
|
||||
_win_estimated_lines(WINDOW* win, const char* const message, int indent, int pad_indent)
|
||||
{
|
||||
int usable = getmaxx(win) - (indent + pad_indent);
|
||||
if (usable < 1) {
|
||||
usable = 1;
|
||||
}
|
||||
int newlines = 0;
|
||||
for (const char* p = message; *p; p++) {
|
||||
if (*p == '\n') {
|
||||
newlines++;
|
||||
}
|
||||
}
|
||||
return newlines + utf8_display_len(message) / usable + 2;
|
||||
}
|
||||
static const char* LOADING_MESSAGE = "Loading older messages…";
|
||||
static const char* CONS_WIN_TITLE = "CProof. Type /help for help information.";
|
||||
static const char* XML_WIN_TITLE = "XML Console";
|
||||
@@ -2001,19 +2018,7 @@ _win_print_internal(ProfWin* window, const char* show_char, int pad_indent, GDat
|
||||
}
|
||||
}
|
||||
|
||||
// reserve pad rows for this message's full height so a tall message isn't clipped at the pad bottom (a clipped height desyncs the scroll offset)
|
||||
int usable = getmaxx(window->layout->win) - (indent + pad_indent);
|
||||
if (usable < 1) {
|
||||
usable = 1;
|
||||
}
|
||||
int msg_nl = 0;
|
||||
for (const char* mp = message + offset; *mp; mp++) {
|
||||
if (*mp == '\n') {
|
||||
msg_nl++;
|
||||
}
|
||||
}
|
||||
int est_lines = msg_nl + (int)(utf8_display_len(message + offset) / usable) + 2;
|
||||
_win_ensure_pad_capacity(window, window->layout->win, getcury(window->layout->win) + est_lines);
|
||||
_win_ensure_pad_capacity(window, window->layout->win, getcury(window->layout->win) + _win_estimated_lines(window->layout->win, message + offset, indent, pad_indent));
|
||||
|
||||
if (prefs_get_boolean(PREF_WRAP)) {
|
||||
_win_print_wrapped(window->layout->win, message + offset, indent, pad_indent);
|
||||
|
||||
Reference in New Issue
Block a user