console/libgnt/gnttextview.c

changeset 14193
fcfd3eea2160
parent 14185
394aa8aa00a3
child 14283
7dc594b6a6db
equal deleted inserted replaced
14192:c62e2ffb987e 14193:fcfd3eea2160
24 gnt_text_view_draw(GntWidget *widget) 24 gnt_text_view_draw(GntWidget *widget)
25 { 25 {
26 GntTextView *view = GNT_TEXT_VIEW(widget); 26 GntTextView *view = GNT_TEXT_VIEW(widget);
27 int i = 0; 27 int i = 0;
28 GList *lines; 28 GList *lines;
29 int showing, position, rows, scrcol; 29 int rows, scrcol;
30 30
31 werase(widget->window); 31 werase(widget->window);
32 32
33 for (i = 0, lines = view->list; i < widget->priv.height && lines; i++, lines = lines->next) 33 for (i = 0, lines = view->list; i < widget->priv.height && lines; i++, lines = lines->next)
34 { 34 {
49 49
50 scrcol = widget->priv.width - 1; 50 scrcol = widget->priv.width - 1;
51 rows = widget->priv.height - 2; 51 rows = widget->priv.height - 2;
52 if (rows > 0) 52 if (rows > 0)
53 { 53 {
54 54 int total = g_list_length(g_list_first(view->list));
55 showing = rows * rows / g_list_length(g_list_first(view->list)) + 1; 55 int showing, position, up, down;
56
57 showing = rows * rows / total + 1;
56 showing = MIN(rows, showing); 58 showing = MIN(rows, showing);
57 59
58 position = showing * g_list_length(view->list) / rows; 60 total -= rows;
61 up = g_list_length(lines);
62 down = total - up;
63
64 position = (rows - showing) * up / MAX(1, up + down);
59 position = MAX((lines != NULL), position); 65 position = MAX((lines != NULL), position);
60 66
61 if (showing + position > rows) 67 if (showing + position > rows)
62 position = rows - showing; 68 position = rows - showing;
63 69

mercurial