Skip to content

Commit 01747d9

Browse files
committed
fix truncated cpu usage in detailed view if more than 3 digits
1 parent 8fee965 commit 01747d9

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

src/btop_draw.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1969,11 +1969,7 @@ namespace Proc {
19691969
const int item_width = floor((double)(d_width - 2) / min(item_fit, 8));
19701970

19711971
//? Graph part of box
1972-
string cpu_str = (alive or pause_proc_list ? fmt::format("{:.2f}", detailed.entry.cpu_p) : "");
1973-
if (alive or pause_proc_list) {
1974-
cpu_str.resize(4);
1975-
if (cpu_str.ends_with('.')) { cpu_str.pop_back(); cpu_str.pop_back(); }
1976-
}
1972+
string cpu_str = (alive or pause_proc_list ? fmt::format("{:>4.{}f}", detailed.entry.cpu_p, detailed.entry.cpu_p < 9.995f ? 2 : detailed.entry.cpu_p < 99.95f ? 1 : 0) : "");
19771973
out += Mv::to(d_y + 1, dgraph_x + 1) + Fx::ub + detailed_cpu_graph(detailed.cpu_percent, (redraw or data_same or not alive))
19781974
+ Mv::to(d_y + 1, dgraph_x + 1) + Theme::c("title") + Fx::b + rjust(cpu_str, 4) + "%";
19791975
for (int i = 0; const auto& l : {'C', 'P', 'U'})

0 commit comments

Comments
 (0)