From d71dc0c346098ea9c0665ec4668c4f41ec707df3 Mon Sep 17 00:00:00 2001 From: Kaian Date: Sat, 20 Feb 2016 20:11:32 +0100 Subject: [PATCH] cf: fix scrollbar length --- src/curses/ui_call_flow.c | 21 ++++++++++++++------- src/curses/ui_call_flow.h | 2 ++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/curses/ui_call_flow.c b/src/curses/ui_call_flow.c index a66da67..05975ca 100644 --- a/src/curses/ui_call_flow.c +++ b/src/curses/ui_call_flow.c @@ -172,7 +172,14 @@ call_flow_draw(ui_t *ui) call_flow_draw_preview(ui); // Draw the scrollbar - info->scroll.max = vector_count(info->darrows); + vector_iter_t it = vector_iterator(info->darrows); + call_flow_arrow_t *arrow = NULL; + info->scroll.max = info->scroll.pos = 0; + while ((arrow = vector_iterator_next(&it))) { + if (vector_iterator_current(&it) == info->first_arrow) + info->scroll.pos = info->scroll.max; + info->scroll.max += call_flow_arrow_height(ui, arrow); + } ui_scrollbar_draw(info->scroll); // Redraw flow win @@ -321,12 +328,12 @@ call_flow_draw_arrows(ui_t *ui) // If no active call, use the fist one (if exists) if (info->cur_arrow == -1 && vector_count(info->darrows)) { - info->cur_arrow = info->scroll.pos = 0; + info->cur_arrow = info->first_arrow = 0; } // Draw arrows vector_iter_t it = vector_iterator(info->darrows); - vector_iterator_set_current(&it, info->scroll.pos - 1); + vector_iterator_set_current(&it, info->first_arrow - 1); while ((arrow = vector_iterator_next(&it))) { // Stop if we have reached the bottom of the screen if (cline >= getmaxy(info->flow_win)) @@ -1272,8 +1279,8 @@ call_flow_move(ui_t *ui, int arrowindex) // If we are out of the bottom of the displayed list // refresh it starting in the next call - if (info->cur_arrow - info->scroll.pos == getmaxy(info->flow_win)/2) { - info->scroll.pos++; + if (info->cur_arrow - info->first_arrow == getmaxy(info->flow_win)/2) { + info->first_arrow++; } } } else { @@ -1283,8 +1290,8 @@ call_flow_move(ui_t *ui, int arrowindex) break; // If we are out of the top of the displayed list // refresh it starting in the previous (in fact current) call - if (info->cur_arrow == info->scroll.pos) { - info->scroll.pos--; + if (info->cur_arrow == info->first_arrow) { + info->first_arrow--; } // Move current call position info->cur_arrow--; diff --git a/src/curses/ui_call_flow.h b/src/curses/ui_call_flow.h index 5fde041..c832f4a 100644 --- a/src/curses/ui_call_flow.h +++ b/src/curses/ui_call_flow.h @@ -132,6 +132,8 @@ struct call_flow_info { vector_t *arrows; //! List of displayed arrows vector_t *darrows; + //! First displayed arrow in the list + int first_arrow; //! Current arrow index where the cursor is int cur_arrow; //! Selected arrow to compare