Skip to content

Commit

Permalink
more scrollbar tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
bjia56 committed Jan 30, 2025
1 parent f1999da commit a18960c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/cosmotop_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1715,11 +1715,11 @@ namespace Proc {
else if (cmd_key.starts_with("mousey")) {
const int mouse_y = std::stoi(cmd_key.substr(6));
const int all_proc_height = accumulate(all_proc_heights.begin(), all_proc_heights.end(), 0);
const int target_height = (int)round(all_proc_height * (double)mouse_y / (height - 5));
const int target_height = (int)floor(all_proc_height * (double)mouse_y / (height - 5));
for (int i = 0, acc = 0; i < all_proc_heights.size(); i++) {
acc += all_proc_heights.at(i);
if (acc >= target_height) {
start = max(0, i - 1);
start = min(i + 1, numpids);
selected = 1;
break;
}
Expand Down Expand Up @@ -2166,9 +2166,8 @@ namespace Proc {
//? Draw scrollbar if needed
if (numpids > select_max) {
const int all_proc_height = accumulate(all_proc_heights.begin(), all_proc_heights.end(), 0);
const int rendered_proc_height = accumulate(rendered_proc_heights.begin(), rendered_proc_heights.end(), 0);
const int up_to_start = accumulate(all_proc_heights.begin(), all_proc_heights.begin() + start, 0);
const int scroll_pos = clamp((int)round((height - 5) * (double)up_to_start / (all_proc_height - rendered_proc_height)), 0, height - 5);
const int scroll_pos = clamp((int)round((height - 5) * (double)up_to_start / all_proc_height), 0, height - 5);
out += Mv::to(y + 1, x + width - 2) + Fx::b + Theme::c("main_fg") + Symbols::up
+ Mv::to(y + height - 2, x + width - 2) + Symbols::down;

Expand Down

0 comments on commit a18960c

Please sign in to comment.