This commit is contained in:
2026-05-28 00:35:15 +03:00
parent 497cc26e38
commit 14c3bf4195

View File

@@ -206,11 +206,16 @@ static void cc_render_message_field(
const unsigned int inner_w = w - x - 2;
const unsigned int inner_h = h - y - 2;
const int max_offset = messages.size > inner_h ? messages.size - inner_h : 0;
if (render_state.scroll_offset > max_offset) render_state.scroll_offset = max_offset;
int max_offset = messages.size > inner_h ? messages.size - inner_h : 0;
if (render_state.scroll_offset > max_offset)
render_state.scroll_offset = max_offset;
if (render_state.scroll_offset < 0)
render_state.scroll_offset = 0;
const int last = messages.size - render_state.scroll_offset;
const int first = last - inner_h > 0 ? last - inner_h : 0;
int last = messages.size - render_state.scroll_offset;
if (last < 0) last = 0;
int first = last - inner_h;
if (first < 0) first = 0;
for (int i = first; i < last; i++) {
mvprintw(y + 1 + (i - first), x + 1, "%-*.*s", inner_w, inner_w, messages.data[i]);