Debian Codegraph @

src/canvas/widgets/cpu_graph.rs

raw symbols SCIP
1 use ratatuirust-analyzer cargo ratatui 0.30.2 crate/::{
2 Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#,
3 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#},
4 };
5
6 use craterust-analyzer cargo bottom 0.14.9 crate/::{
7 apprust-analyzer cargo bottom 0.14.9 app/::{Apprust-analyzer cargo bottom 0.14.9 app/App#, datarust-analyzer cargo bottom 0.14.9 app/data/::InnerDatarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#, layout_managerrust-analyzer cargo bottom 0.14.9 app/layout_manager/::WidgetDirectionrust-analyzer cargo bottom 0.14.9 app/layout_manager/WidgetDirection#},
8 canvasrust-analyzer cargo bottom 0.14.9 canvas/::{
9 Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter#,
10 componentsrust-analyzer cargo bottom 0.14.9 canvas/components/::{
11 data_tablerust-analyzer cargo bottom 0.14.9 canvas/components/data_table/::{DrawInforust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#, SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#},
12 time_seriesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/::GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#,
13 },
14 drawing_utilsrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/::should_hide_x_labelrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/should_hide_x_label().,
15 },
16 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#,
17 componentsrust-analyzer cargo bottom 0.14.9 components/::time_seriesrust-analyzer cargo bottom 0.14.9 components/time_series/::GraphDrawCtxrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#,
18 widgetsrust-analyzer cargo bottom 0.14.9 widgets/::CpuWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#,
19 };
20
21 const AVG_POSITIONrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/AVG_POSITION.: usize = 1;
22 const ALL_POSITIONrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/ALL_POSITION.: usize = 0;
23
24 impl Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter# {
25 pub fn draw_cpurust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/impl#[Painter]draw_cpu().(&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#, draw_loc: Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#, widget_id: u64) {
26 let legend_width = (draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width. as f64 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][`Mul<Self>`]mul().0.15) as u16;
27
28 if legend_width rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialOrd<Self>`]lt().6 {
29 // Skip drawing legend
30 if 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 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().1) {
31 if app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..cpu_left_legendrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#cpu_left_legend. {
32 app_state.move_widget_selectionrust-analyzer cargo bottom 0.14.9 app/impl#[App]move_widget_selection().(&WidgetDirectionrust-analyzer cargo bottom 0.14.9 app/layout_manager/WidgetDirection#::Rightrust-analyzer cargo bottom 0.14.9 app/layout_manager/WidgetDirection#Right#);
33 } else {
34 app_state.move_widget_selectionrust-analyzer cargo bottom 0.14.9 app/impl#[App]move_widget_selection().(&WidgetDirectionrust-analyzer cargo bottom 0.14.9 app/layout_manager/WidgetDirection#::Leftrust-analyzer cargo bottom 0.14.9 app/layout_manager/WidgetDirection#Left#);
35 }
36 }
37 self.draw_cpu_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/impl#[Painter]draw_cpu_graph().(f, app_state, draw_loc, widget_id);
38 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cpu_widget_state) =
39 app_state.statesrust-analyzer cargo bottom 0.14.9 app/App#states..cpu_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#cpu_state..widget_statesrust-analyzer cargo bottom 0.14.9 app/states/CpuState#widget_states..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)
40 {
41 cpu_widget_state.is_legend_hiddenrust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#is_legend_hidden. = true;
42 }
43
44 // Update draw loc in widget map
45 if app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().()
46 && let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(bottom_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)
47 {
48 bottom_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.));
49 bottom_widget.bottom_right_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#bottom_right_corner. =
50 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.));
51 }
52 } else {
53 let graph_width = draw_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][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u16][`Sub<Self>`]sub().legend_width;
54 let (graph_index, legend_index, constraints) =
55 if app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..cpu_left_legendrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#cpu_left_legend. {
56 (
57 1,
58 0,
59 [
60 Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(legend_width),
61 Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(graph_width),
62 ],
63 )
64 } else {
65 (
66 0,
67 1,
68 [
69 Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(graph_width),
70 Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(legend_width),
71 ],
72 )
73 };
74
75 let partitioned_draw_loc = 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().()
76 .marginrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]margin().(0)
77 .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#)
78 .constraintsrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]constraints().(constraints)
79 .splitrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]split().(draw_loc);
80
81 self.draw_cpu_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/impl#[Painter]draw_cpu_graph().(f, app_state, partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().graph_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., widget_id);
82 self.draw_cpu_legendrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/impl#[Painter]draw_cpu_legend().(
83 f,
84 app_state,
85 partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().legend_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().,
86 widget_id rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().1,
87 );
88
89 if app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().() {
90 // Update draw loc in widget map
91 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cpu_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) {
92 cpu_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#((
93 partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().graph_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x.,
94 partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().graph_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.,
95 ));
96 cpu_widget.bottom_right_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#bottom_right_corner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
97 partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().graph_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x.
98 +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().partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().graph_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width.,
99 partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().graph_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.
100 +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().partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().graph_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height.,
101 ));
102 }
103
104 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(legend_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 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Add<Self>`]add().1)) {
105 legend_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#((
106 partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().legend_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x.,
107 partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().legend_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.,
108 ));
109 legend_widget.bottom_right_cornerrust-analyzer cargo bottom 0.14.9 app/layout_manager/BottomWidget#bottom_right_corner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((
110 partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().legend_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x.
111 +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().partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().legend_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width.,
112 partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().legend_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.
113 +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().partitioned_draw_loc[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().legend_index]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height.,
114 ));
115 }
116 }
117 }
118 }
119
120 fn generate_pointsrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/impl#[Painter]generate_points().<'a>(
121 &self, cpu_widget_state: &'a CpuWidgetStaterust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#, data: &'a InnerDatarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#, show_avg_cpu: bool,
122 ) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#<'a>> {
123 let show_avg_offset = if show_avg_cpu { AVG_POSITIONrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/AVG_POSITION. } else { 0 };
124 let current_scroll_position = cpu_widget_state.tablerust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#table..staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/DataTable#state..current_indexrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/state/DataTableState#current_index.;
125 let cpu_entries = &data.cpu_harvestrust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#cpu_harvest.;
126 let cpu_points = &data.time_series_datarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#time_series_data..cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu.;
127 let time = &data.time_series_datarust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#time_series_data..timerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#time.;
128
129 if current_scroll_position 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().ALL_POSITIONrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/ALL_POSITION. {
130 // This case ensures the other cases cannot have the position be equal to 0.
131
132 cpu_points
133 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
134 .enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().()
135 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(itx, values)| {
136 let style = if show_avg_cpu && itx 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().0 {
137 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.
138 } else {
139 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.
140 [rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().(itx 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().show_avg_offset) 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().
141 };
142
143 GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#::defaultrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`][Default]default().().stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(style).timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(time).valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(values)
144 })
145 .revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().()
146 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
147 } else if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(CpuDatarust-analyzer cargo bottom 0.14.9 collection/cpu/CpuData# { .. }) = cpu_entries.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]get().(current_scroll_position 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().1) {
148 // We generally subtract one from current scroll position because of the all
149 // entry. TODO: Do this a bit better (e.g. we can just do if let
150 // Some(_) = cpu_points.get())
151
152 let style = if show_avg_cpu && current_scroll_position 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_POSITIONrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/AVG_POSITION. {
153 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.
154 } else {
155 let offset_position = current_scroll_position 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().1;
156 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.
157 [rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().(offset_position 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().show_avg_offset) 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().
158 };
159
160 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
161 GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#::defaultrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`][Default]default().()
162 .stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]style().(style)
163 .timerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]time().(time)
164 .valuesrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`GraphData<'a, F>`]values().(&cpu_points[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().current_scroll_position -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). 1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().),
165 ]
166 } else {
167 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]
168 }
169 }
170
171 fn draw_cpu_graphrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/impl#[Painter]draw_cpu_graph().(
172 &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#, draw_loc: Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#, widget_id: u64,
173 ) {
174 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cpu_widget_state) = app_state.statesrust-analyzer cargo bottom 0.14.9 app/App#states..cpu_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#cpu_state..widget_statesrust-analyzer cargo bottom 0.14.9 app/states/CpuState#widget_states..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)
175 {
176 let 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().();
177
178 let hide_x_labels = should_hide_x_labelrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/should_hide_x_label().(
179 app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..hide_timerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#hide_time.,
180 app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..autohide_timerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#autohide_time.,
181 cpu_widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#graph..state_mutrust-analyzer cargo bottom 0.14.9 components/time_series/percent/impl#[PercentTimeGraph]state_mut().().autohide_timer_mutrust-analyzer cargo bottom 0.14.9 components/time_series/impl#[TimeseriesState]autohide_timer_mut().(),
182 draw_loc,
183 );
184
185 let graph_data = self.generate_pointsrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/impl#[Painter]generate_points().(
186 cpu_widget_state,
187 data,
188 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.,
189 );
190
191 // TODO: Maybe hide load avg if too long? Or maybe the CPU part.
192 let title = {
193 #[cfg(unix)]
194 {
195 let load_avg = &data.load_avg_harvestrust-analyzer cargo bottom 0.14.9 app/data/store/InnerData#load_avg_harvest.;
196 let load_avg_str = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
197 "─ {:.2} {:.2} {:.2} ",
198 load_avg[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., load_avg[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., load_avg[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
199 );
200
201 concat_stringrust-analyzer cargo concat-string 1.0.1 crate/::concat_stringrust-analyzer cargo concat-string 1.0.1 concat_string!!(" CPU ", load_avg_str).intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
202 }
203 #[cfg(not(target_family = "unix"))]
204 {
205 " CPU ".into()
206 }
207 };
208
209 let border_style = self.get_border_stylerust-analyzer cargo bottom 0.14.9 canvas/impl#[Painter]get_border_style().(widget_id, 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.);
210 let marker = self.get_markerrust-analyzer cargo bottom 0.14.9 canvas/impl#[Painter]get_marker().(app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..use_dotrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_dot.);
211
212 cpu_widget_state.graphrust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#graph..drawrust-analyzer cargo bottom 0.14.9 components/time_series/percent/impl#[PercentTimeGraph]draw().(
213 f,
214 draw_loc,
215 GraphDrawCtxrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx# {
216 titlerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#title.,
217 border_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#border_style.,
218 title_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#title_style.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..widget_title_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#widget_title_style.,
219 graph_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#graph_style.: self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..graph_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#graph_style.,
220 general_widget_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#general_widget_style.: 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.,
221 border_typerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#border_type.: 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.,
222 markerrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#marker.,
223 hide_x_labelsrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#hide_x_labels.,
224 is_selectedrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#is_selected.: 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,
225 is_expandedrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#is_expanded.: app_state.is_expandedrust-analyzer cargo bottom 0.14.9 app/App#is_expanded.,
226 legend_positionrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#legend_position.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
227 legend_constraintsrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#legend_constraints.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
228 },
229 graph_data,
230 );
231 }
232 }
233
234 fn draw_cpu_legendrust-analyzer cargo bottom 0.14.9 canvas/widgets/cpu_graph/impl#[Painter]draw_cpu_legend().(
235 &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#, draw_loc: Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#, widget_id: u64,
236 ) {
237 let recalculate_column_widths = app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().();
238 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cpu_widget_state) = app_state
239 .statesrust-analyzer cargo bottom 0.14.9 app/App#states.
240 .cpu_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#cpu_state.
241 .widget_statesrust-analyzer cargo bottom 0.14.9 app/states/CpuState#widget_states.
242 .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 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u64][`Sub<Self>`]sub().1))
243 {
244 // TODO: This line (and the one above, see caller) is pretty dumb but I guess
245 // needed for now. Refactor if possible!
246 cpu_widget_state.is_legend_hiddenrust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#is_legend_hidden. = false;
247
248 let is_on_widget = 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().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.;
249
250 let draw_info = DrawInforust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo# {
251 locrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#loc.: draw_loc,
252 force_redrawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#force_redraw.: app_state.is_force_redrawrust-analyzer cargo bottom 0.14.9 app/App#is_force_redraw.,
253 recalculate_column_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#recalculate_column_widths.,
254 // TODO: Bug with this, shouldn't be selected on expand!
255 selection_staterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#selection_state.: SelectionStaterust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/SelectionState#::newrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[SelectionState]new().(app_state.is_expandedrust-analyzer cargo bottom 0.14.9 app/App#is_expanded., is_on_widget),
256 };
257
258 cpu_widget_state.tablerust-analyzer cargo bottom 0.14.9 widgets/cpu_graph/CpuWidgetState#table..drawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[`DataTable<DataType, H, S, C>`]draw().(
259 f,
260 &draw_info,
261 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),
262 self,
263 );
264 }
265 }
266 }