browser.c: Fix bar width floating point calculation

In some cases the bar width may be 1 block short due to imprecise
floating point calculations. i.e. (max_width * a) / a != max_width,
whereas (max_width * (a/a)) == max_width. Or, at least, that's what I've
observed so far.
This commit is contained in:
Yorhel 2021-05-23 14:26:27 +02:00
parent a6b4aead43
commit ebeee7be01

View file

@ -160,7 +160,7 @@ static void browse_draw_graph(struct dir *n, int *x) {
/* graph (10+ columns) */ /* graph (10+ columns) */
if(graph == 1 || graph == 3) { if(graph == 1 || graph == 3) {
uic_set(c == UIC_SEL ? UIC_GRAPH_SEL : UIC_GRAPH); uic_set(c == UIC_SEL ? UIC_GRAPH_SEL : UIC_GRAPH);
o = (int)((float)bar_size*(float)(show_as ? n->asize : n->size) / (float)(show_as ? dirlist_maxa : dirlist_maxs)); o = (int)((float)bar_size*((float)(show_as ? n->asize : n->size) / (float)(show_as ? dirlist_maxa : dirlist_maxs)));
for(i=0; i<bar_size; i++) for(i=0; i<bar_size; i++)
addch(i < o ? '#' : ' '); addch(i < o ? '#' : ' ');
} }