| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().; |
| 2 | |
| 3 | use itertoolsrust-analyzer cargo itertools 0.15.0 crate/::Itertoolsrust-analyzer cargo itertools 0.15.0 Itertools#; |
| 4 | use ratatuirust-analyzer cargo ratatui 0.30.2 crate/::{ |
| 5 | Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#, |
| 6 | layoutrust-analyzer cargo ratatui-core 0.1.2 layout/::{Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#, Directionrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#, Layoutrust-analyzer cargo ratatui-core 0.1.2 layout/layout/Layout#, Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#}, |
| 7 | stylerust-analyzer cargo ratatui-core 0.1.2 style/::Stylerust-analyzer cargo ratatui-core 0.1.2 style/Style#, |
| 8 | }; |
| 9 | |
| 10 | use craterust-analyzer cargo bottom 0.14.9 crate/::{ |
| 11 | apprust-analyzer cargo bottom 0.14.9 app/::Apprust-analyzer cargo bottom 0.14.9 app/App#, |
| 12 | canvasrust-analyzer cargo bottom 0.14.9 canvas/::{ |
| 13 | Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter#, |
| 14 | componentsrust-analyzer cargo bottom 0.14.9 canvas/components/::pipe_gaugerust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/::{LabelLimitrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/LabelLimit#, PipeGaugerust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/PipeGauge#}, |
| 15 | drawing_utilsrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/::widget_blockrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/widget_block()., |
| 16 | }, |
| 17 | collectionrust-analyzer cargo bottom 0.14.9 collection/::cpurust-analyzer cargo bottom 0.14.9 collection/cpu/::{CpuDatarust-analyzer cargo bottom 0.14.9 collection/cpu/CpuData#, CpuDataTyperust-analyzer cargo bottom 0.14.9 collection/cpu/CpuDataType#}, |
| 18 | }; |
| 19 | |
| 20 | impl Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter# { |
| 21 | /// Inspired by htop. |
| 22 | pub fn draw_basic_cpurust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/impl#[Painter]draw_basic_cpu().( |
| 23 | &self, f: &mut Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#<'_>, app_state: &mut Apprust-analyzer cargo bottom 0.14.9 app/App#, mut draw_loc: Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#, widget_id: u64, |
| 24 | ) { |
| 25 | let cpu_data = &app_state.data_storerust-analyzer cargo bottom 0.14.9 app/App#data_store..get_datarust-analyzer cargo bottom 0.14.9 app/data/store/impl#[DataStore]get_data().().cpu_harvestrust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#cpu_harvest.; |
| 26 | |
| 27 | // This is a bit complicated, but basically, we want to draw SOME number |
| 28 | // of columns to draw all CPUs. Ideally, as well, we want to not have |
| 29 | // to ever scroll. |
| 30 | // |
| 31 | // **General logic** - count number of elements in cpu_data. Then see how |
| 32 | // many rows and columns we have in draw_loc (-2 on both sides for border?). |
| 33 | // I think what we can do is try to fit in as many in one column as possible. |
| 34 | // If not, then add a new column. Then, from this, split the row space across |
| 35 | // ALL columns. From there, generate the desired lengths. |
| 36 | |
| 37 | f.render_widgetrust-analyzer cargo ratatui-core 0.1.2 terminal/frame/impl#[`Frame<'_>`]render_widget().( |
| 38 | widget_blockrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/widget_block().( |
| 39 | true, |
| 40 | app_state.current_widgetrust-analyzer cargo bottom 0.14.9 app/App#current_widget..widget_idrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#widget_id. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().widget_id, |
| 41 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..border_typerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#border_type., |
| 42 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..general_widget_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#general_widget_style., |
| 43 | ) |
| 44 | .border_stylerust-analyzer cargo ratatui-widgets 0.3.2 block/impl#[`Block<'a>`]border_style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..highlighted_border_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#highlighted_border_style.), |
| 45 | draw_loc, |
| 46 | ); |
| 47 | |
| 48 | // TODO: This is pretty ugly. Is there a better way of doing it? |
| 49 | let mut avg_index = cpu_data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1; |
| 50 | let mut avg_row_count = 0; |
| 51 | let show_decimal = app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..show_cpu_decimalrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#show_cpu_decimal.; |
| 52 | if app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..dedicated_average_rowrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#dedicated_average_row. |
| 53 | && app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..show_average_cpurust-analyzer cargo bottom 0.14.9 app/AppConfigFields#show_average_cpu. |
| 54 | && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((index, avg)) = cpu_data |
| 55 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 56 | .find_positionrust-analyzer cargo itertools 0.15.0 Itertools#find_position().(|&datum| matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(datum.data_typerust-analyzer cargo bottom 0.14.9 collection/cpu/CpuData#data_type., CpuDataTyperust-analyzer cargo bottom 0.14.9 collection/cpu/CpuDataType#::Avgrust-analyzer cargo bottom 0.14.9 collection/cpu/CpuDataType#Avg#)) |
| 57 | { |
| 58 | let (outer, inner, ratio, style) = self.cpu_inforust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/impl#[Painter]cpu_info().(avg, show_decimal); |
| 59 | let [cores_loc, mut avg_loc] = |
| 60 | Layoutrust-analyzer cargo ratatui-core 0.1.2 layout/layout/Layout#::verticalrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]vertical().([Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Minrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Min#(0), Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(1)]).areasrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]areas().(draw_loc); |
| 61 | |
| 62 | // The cores section all have horizontal margin, so to line up with the cores we |
| 63 | // need to add some margin ourselves. |
| 64 | avg_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`AddAssign<Self>`]add_assign().1; |
| 65 | avg_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`SubAssign<Self>`]sub_assign().2; |
| 66 | |
| 67 | f.render_widgetrust-analyzer cargo ratatui-core 0.1.2 terminal/frame/impl#[`Frame<'_>`]render_widget().( |
| 68 | PipeGaugerust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/PipeGauge#::defaultrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'_>`][Default]default().() |
| 69 | .gauge_stylerust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]gauge_style().(style) |
| 70 | .label_stylerust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]label_style().(style) |
| 71 | .inner_labelrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]inner_label().(inner) |
| 72 | .start_labelrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]start_label().(outer) |
| 73 | .ratiorust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]ratio().(ratio.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 74 | avg_loc, |
| 75 | ); |
| 76 | avg_row_count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1; |
| 77 | avg_index = index; |
| 78 | draw_loc = cores_loc; |
| 79 | } |
| 80 | |
| 81 | if draw_loc.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]gt().0 { |
| 82 | let remaining_height = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(draw_loc.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height.); |
| 83 | const REQUIRED_COLUMNSrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/REQUIRED_COLUMNS.: usize = 4; |
| 84 | |
| 85 | let col_constraints = |
| 86 | vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Percentagerust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Percentage#((100 /rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). REQUIRED_COLUMNSrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/REQUIRED_COLUMNS.) as u16); REQUIRED_COLUMNSrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/REQUIRED_COLUMNS.]; |
| 87 | let columns = Layoutrust-analyzer cargo ratatui-core 0.1.2 layout/layout/Layout#::defaultrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout][Default]default().() |
| 88 | .constraintsrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]constraints().(col_constraints) |
| 89 | .directionrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]direction().(Directionrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#::Horizontalrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#Horizontal#) |
| 90 | .splitrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]split().(draw_loc); |
| 91 | |
| 92 | let mut gauge_info = cpu_data.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().().filter_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter_map().(|(index, cpu)| { |
| 93 | if index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().avg_index { |
| 94 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 95 | } else { |
| 96 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(self.cpu_inforust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/impl#[Painter]cpu_info().(cpu, show_decimal)) |
| 97 | } |
| 98 | }); |
| 99 | |
| 100 | // Very ugly way to sync the gauge limit across all gauges. |
| 101 | let hide_parts = columns |
| 102 | .firstrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]first().() |
| 103 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|col| { |
| 104 | if col.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().12 { |
| 105 | LabelLimitrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/LabelLimit#::Nonerust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/LabelLimit#None# |
| 106 | } else if col.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]ge().10 { |
| 107 | LabelLimitrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/LabelLimit#::Barsrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/LabelLimit#Bars# |
| 108 | } else { |
| 109 | LabelLimitrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/LabelLimit#::StartLabelrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/LabelLimit#StartLabel# |
| 110 | } |
| 111 | }) |
| 112 | .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().(); |
| 113 | |
| 114 | let num_entries = cpu_data.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().avg_row_count; |
| 115 | let mut row_counter = num_entries; |
| 116 | for (itx, column) in columns.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() { |
| 117 | if REQUIRED_COLUMNSrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/REQUIRED_COLUMNS. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().itx { |
| 118 | let to_divide = REQUIRED_COLUMNSrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/REQUIRED_COLUMNS. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().itx; |
| 119 | let num_taken = minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().( |
| 120 | remaining_height, |
| 121 | (row_counter rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Div<Self>`]div().to_divide) |
| 122 | +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<bool>`]from().(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().row_counter.is_multiple_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]is_multiple_of().(to_divide)), |
| 123 | ); |
| 124 | row_counter rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().-=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`SubAssign<Self>`]sub_assign().num_taken; |
| 125 | let chunk = (&mut gauge_info).takerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take().(num_taken); |
| 126 | |
| 127 | let rows = Layoutrust-analyzer cargo ratatui-core 0.1.2 layout/layout/Layout#::defaultrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout][Default]default().() |
| 128 | .directionrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]direction().(Directionrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#::Verticalrust-analyzer cargo ratatui-core 0.1.2 layout/direction/Direction#Vertical#) |
| 129 | .constraintsrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]constraints().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(1); remaining_height]) |
| 130 | .horizontal_marginrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]horizontal_margin().(1) |
| 131 | .splitrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]split().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().column); |
| 132 | |
| 133 | for ((start_label, inner_label, ratio, style), row) in chunk.ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(rows.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) { |
| 134 | f.render_widgetrust-analyzer cargo ratatui-core 0.1.2 terminal/frame/impl#[`Frame<'_>`]render_widget().( |
| 135 | PipeGaugerust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/PipeGauge#::defaultrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'_>`][Default]default().() |
| 136 | .gauge_stylerust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]gauge_style().(style) |
| 137 | .label_stylerust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]label_style().(style) |
| 138 | .inner_labelrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]inner_label().(inner_label) |
| 139 | .start_labelrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]start_label().(start_label) |
| 140 | .ratiorust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]ratio().(ratio.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 141 | .hide_partsrust-analyzer cargo bottom 0.14.9 canvas/components/pipe_gauge/impl#[`PipeGauge<'a>`]hide_parts().(hide_parts), |
| 142 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().row, |
| 143 | ); |
| 144 | } |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | if app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().() { |
| 150 | // Update draw loc in widget map |
| 151 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(widget) = app_state.widget_maprust-analyzer cargo bottom 0.14.9 app/App#widget_map..get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&widget_id) { |
| 152 | widget.top_left_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#top_left_corner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x., draw_loc.yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.)); |
| 153 | widget.bottom_right_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#bottom_right_corner. = |
| 154 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width., draw_loc.yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Add<Self>`]add().draw_loc.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height.)); |
| 155 | } |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | #[inline] |
| 160 | fn cpu_inforust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_basic/impl#[Painter]cpu_info().(&self, data: &CpuDatarust-analyzer cargo bottom 0.14.9 collection/cpu/CpuData#, show_decimal: bool) -> (Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, f32, Stylerust-analyzer cargo ratatui-core 0.1.2 style/Style#) { |
| 161 | let (outer, style) = match data.data_typerust-analyzer cargo bottom 0.14.9 collection/cpu/CpuData#data_type. { |
| 162 | CpuDataTyperust-analyzer cargo bottom 0.14.9 collection/cpu/CpuDataType#::Avgrust-analyzer cargo bottom 0.14.9 collection/cpu/CpuDataType#Avg# => ("AVG".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..avg_cpu_colourrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#avg_cpu_colour.), |
| 163 | CpuDataTyperust-analyzer cargo bottom 0.14.9 collection/cpu/CpuDataType#::Cpurust-analyzer cargo bottom 0.14.9 collection/cpu/CpuDataType#Cpu#(index) => ( |
| 164 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{index:<3}",), |
| 165 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..cpu_colour_stylesrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#cpu_colour_styles.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().index rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().%rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Rem<Self>`]rem().self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..cpu_colour_stylesrust-analyzer cargo bottom 0.14.9 options/config/style/Styles#cpu_colour_styles..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()., |
| 166 | ), |
| 167 | }; |
| 168 | |
| 169 | let inner = if show_decimal { |
| 170 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:>5.1}%", data.usagerust-analyzer cargo bottom 0.14.9 collection/cpu/CpuData#usage.) |
| 171 | } else { |
| 172 | formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{:>3.0}%", data.usagerust-analyzer cargo bottom 0.14.9 collection/cpu/CpuData#usage..roundrust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/impl#[f32]round().()) |
| 173 | }; |
| 174 | let ratio = data.usagerust-analyzer cargo bottom 0.14.9 collection/cpu/CpuData#usage. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div()./rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f32][`Div<Self>`]div().100.0; |
| 175 | |
| 176 | (outer, inner, ratio, style) |
| 177 | } |
| 178 | } |