| 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/::{Alignmentrust-analyzer cargo ratatui-core 0.1.2 layout/alignment/Alignment#, 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 | textrust-analyzer cargo ratatui-core 0.1.2 text/::{Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#, Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#}, |
| 5 | widgetsrust-analyzer cargo ratatui 0.30.2 widgets/::Paragraphrust-analyzer cargo ratatui-widgets 0.3.2 paragraph/Paragraph#, |
| 6 | }; |
| 7 | |
| 8 | use craterust-analyzer cargo bottom 0.14.9 crate/::{ |
| 9 | apprust-analyzer cargo bottom 0.14.9 app/::Apprust-analyzer cargo bottom 0.14.9 app/App#, |
| 10 | canvasrust-analyzer cargo bottom 0.14.9 canvas/::{ |
| 11 | Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter#, |
| 12 | componentsrust-analyzer cargo bottom 0.14.9 canvas/components/::{ |
| 13 | 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#}, |
| 14 | search_inputrust-analyzer cargo bottom 0.14.9 canvas/components/search_input/::build_query_spansrust-analyzer cargo bottom 0.14.9 canvas/components/search_input/build_query_spans()., |
| 15 | }, |
| 16 | drawing_utilsrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/::widget_blockrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/widget_block()., |
| 17 | }, |
| 18 | }; |
| 19 | |
| 20 | const SORT_MENU_WIDTHrust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/SORT_MENU_WIDTH.: u16 = 7; |
| 21 | |
| 22 | impl Painterrust-analyzer cargo bottom 0.14.9 canvas/Painter# { |
| 23 | /// Draws and handles all process-related drawing. Use this. |
| 24 | /// - `widget_id` here represents the widget ID of the process widget |
| 25 | /// itself! |
| 26 | pub fn draw_processrust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/impl#[Painter]draw_process().( |
| 27 | &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, |
| 28 | ) { |
| 29 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(proc_widget_state) = app_state.statesrust-analyzer cargo bottom 0.14.9 app/App#states..proc_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#proc_state..widget_statesrust-analyzer cargo bottom 0.14.9 app/states/ProcState#widget_states..getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&widget_id) { |
| 30 | let is_basic = app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..use_basic_moderust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_basic_mode.; |
| 31 | let search_height = if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_basic { 5 } else { 3 }; |
| 32 | let is_sort_open = proc_widget_state.is_sort_openrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#is_sort_open.; |
| 33 | |
| 34 | let mut proc_draw_loc = draw_loc; |
| 35 | if proc_widget_state.is_search_enabledrust-analyzer cargo bottom 0.14.9 widgets/process_table/impl#[ProcWidgetState]is_search_enabled().() { |
| 36 | let processes_chunk = 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().() |
| 37 | .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#) |
| 38 | .constraintsrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]constraints().([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#(search_height)]) |
| 39 | .splitrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]split().(draw_loc); |
| 40 | proc_draw_loc = processes_chunk[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().; |
| 41 | |
| 42 | self.draw_search_fieldrust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/impl#[Painter]draw_search_field().(f, app_state, processes_chunk[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()., 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); |
| 43 | } |
| 44 | |
| 45 | if is_sort_open { |
| 46 | let processes_chunk = 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().() |
| 47 | .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#) |
| 48 | .constraintsrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]constraints().([Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Lengthrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Length#(SORT_MENU_WIDTHrust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/SORT_MENU_WIDTH. 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().4), Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Minrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Min#(0)]) |
| 49 | .splitrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]split().(proc_draw_loc); |
| 50 | proc_draw_loc = processes_chunk[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().; |
| 51 | |
| 52 | self.draw_sort_tablerust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/impl#[Painter]draw_sort_table().(f, app_state, processes_chunk[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()., 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().2); |
| 53 | } |
| 54 | |
| 55 | self.draw_processes_tablerust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/impl#[Painter]draw_processes_table().(f, app_state, proc_draw_loc, widget_id); |
| 56 | } |
| 57 | |
| 58 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(proc_widget_state) = app_state |
| 59 | .statesrust-analyzer cargo bottom 0.14.9 app/App#states. |
| 60 | .proc_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#proc_state. |
| 61 | .widget_statesrust-analyzer cargo bottom 0.14.9 app/states/ProcState#widget_states. |
| 62 | .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) |
| 63 | { |
| 64 | // Reset redraw marker. |
| 65 | if proc_widget_state.force_rerenderrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#force_rerender. { |
| 66 | proc_widget_state.force_rerenderrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#force_rerender. = false; |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /// Draws the process sort box. |
| 72 | /// - `widget_id` represents the widget ID of the process widget itself. |
| 73 | fn draw_processes_tablerust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/impl#[Painter]draw_processes_table().( |
| 74 | &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, |
| 75 | ) { |
| 76 | let should_get_widget_bounds = app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().(); |
| 77 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(proc_widget_state) = app_state |
| 78 | .statesrust-analyzer cargo bottom 0.14.9 app/App#states. |
| 79 | .proc_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#proc_state. |
| 80 | .widget_statesrust-analyzer cargo bottom 0.14.9 app/states/ProcState#widget_states. |
| 81 | .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) |
| 82 | { |
| 83 | let recalculate_column_widths = |
| 84 | should_get_widget_bounds || proc_widget_state.force_rerenderrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#force_rerender.; |
| 85 | |
| 86 | 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.; |
| 87 | |
| 88 | let draw_info = DrawInforust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo# { |
| 89 | locrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#loc.: draw_loc, |
| 90 | 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., |
| 91 | recalculate_column_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#recalculate_column_widths., |
| 92 | 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), |
| 93 | }; |
| 94 | |
| 95 | proc_widget_state.tablerust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#table..drawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[`DataTable<DataType, H, S, C>`]draw().( |
| 96 | f, |
| 97 | &draw_info, |
| 98 | 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), |
| 99 | self, |
| 100 | ); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | /// Draws the process search field. |
| 105 | /// - `widget_id` represents the widget ID of the search box itself --- NOT |
| 106 | /// the process widget state that is stored. |
| 107 | fn draw_search_fieldrust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/impl#[Painter]draw_search_field().( |
| 108 | &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, |
| 109 | ) { |
| 110 | let is_basic = app_state.app_config_fieldsrust-analyzer cargo bottom 0.14.9 app/App#app_config_fields..use_basic_moderust-analyzer cargo bottom 0.14.9 app/AppConfigFields#use_basic_mode.; |
| 111 | |
| 112 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(proc_widget_state) = app_state |
| 113 | .statesrust-analyzer cargo bottom 0.14.9 app/App#states. |
| 114 | .proc_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#proc_state. |
| 115 | .widget_statesrust-analyzer cargo bottom 0.14.9 app/states/ProcState#widget_states. |
| 116 | .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)) |
| 117 | { |
| 118 | let is_selected = 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.; |
| 119 | let num_columns = usize::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[usize][`From<u16>`]from().(draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width.); |
| 120 | const SEARCH_TITLErust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/SEARCH_TITLE.: &str = "> "; |
| 121 | let offset = 4; |
| 122 | let available_width = if num_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().(offset 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().3) { |
| 123 | num_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().offset |
| 124 | } else { |
| 125 | num_columns |
| 126 | }; |
| 127 | |
| 128 | proc_widget_state |
| 129 | .proc_searchrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#proc_search. |
| 130 | .search_staterust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcessSearchState#search_state. |
| 131 | .input_field_staterust-analyzer cargo bottom 0.14.9 app/states/AppSearchState#input_field_state. |
| 132 | .get_start_positionrust-analyzer cargo bottom 0.14.9 utils/input/impl#[InputFieldState]get_start_position().(available_width, app_state.is_force_redrawrust-analyzer cargo bottom 0.14.9 app/App#is_force_redraw.); |
| 133 | |
| 134 | // TODO: [CURSOR] blinking cursor? |
| 135 | let query_with_cursor = build_query_spansrust-analyzer cargo bottom 0.14.9 canvas/components/search_input/build_query_spans().( |
| 136 | &proc_widget_state.proc_searchrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#proc_search..search_staterust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcessSearchState#search_state..input_field_staterust-analyzer cargo bottom 0.14.9 app/states/AppSearchState#input_field_state., |
| 137 | available_width, |
| 138 | is_selected, |
| 139 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..selected_text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#selected_text_style., |
| 140 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#text_style., |
| 141 | ); |
| 142 | |
| 143 | let mut search_text = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#::fromrust-analyzer cargo ratatui-core 0.1.2 text/line/impl#[`Line<'a>`][`From<Vec<Span<'a>>>`]from().({ |
| 144 | let mut search_vec = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#::styledrust-analyzer cargo ratatui-core 0.1.2 text/span/impl#[`Span<'a>`]styled().( |
| 145 | SEARCH_TITLErust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/SEARCH_TITLE., |
| 146 | if is_selected { |
| 147 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..table_header_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#table_header_style. |
| 148 | } else { |
| 149 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#text_style. |
| 150 | }, |
| 151 | )]; |
| 152 | search_vec.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(query_with_cursor); |
| 153 | |
| 154 | search_vec |
| 155 | })]; |
| 156 | |
| 157 | // Text options shamelessly stolen from VS Code. |
| 158 | let case_style = if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().proc_widget_state.proc_searchrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#proc_search..query_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcessSearchState#query_options..ignore_caserust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#ignore_case. { |
| 159 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..selected_text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#selected_text_style. |
| 160 | } else { |
| 161 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#text_style. |
| 162 | }; |
| 163 | |
| 164 | let whole_word_style = if proc_widget_state.proc_searchrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#proc_search..query_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcessSearchState#query_options..whole_wordrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#whole_word. { |
| 165 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..selected_text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#selected_text_style. |
| 166 | } else { |
| 167 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#text_style. |
| 168 | }; |
| 169 | |
| 170 | let regex_style = if proc_widget_state.proc_searchrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#proc_search..query_optionsrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcessSearchState#query_options..use_regexrust-analyzer cargo bottom 0.14.9 widgets/process_table/query/QueryOptions#use_regex. { |
| 171 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..selected_text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#selected_text_style. |
| 172 | } else { |
| 173 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#text_style. |
| 174 | }; |
| 175 | |
| 176 | // TODO: [MOUSE] Mouse support for these in search |
| 177 | // TODO: [MOVEMENT] Movement support for these in search |
| 178 | let (case, whole, regex) = { |
| 179 | cfg_selectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/cfg_select!! { |
| 180 | target_os = "macos" => { |
| 181 | ("Case(F1)", "Whole(F2)", "Regex(F3)") |
| 182 | } |
| 183 | _ => { |
| 184 | ("Case(Alt+C)", "Whole(Alt+W)", "Regex(Alt+R)") |
| 185 | } |
| 186 | } |
| 187 | }; |
| 188 | let option_text = Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#::fromrust-analyzer cargo ratatui-core 0.1.2 text/line/impl#[`Line<'a>`][`From<Vec<Span<'a>>>`]from().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![ |
| 189 | Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#::styledrust-analyzer cargo ratatui-core 0.1.2 text/span/impl#[`Span<'a>`]styled().(case, case_style), |
| 190 | Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#::rawrust-analyzer cargo ratatui-core 0.1.2 text/span/impl#[`Span<'a>`]raw().(" "), |
| 191 | Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#::styledrust-analyzer cargo ratatui-core 0.1.2 text/span/impl#[`Span<'a>`]styled().(whole, whole_word_style), |
| 192 | Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#::rawrust-analyzer cargo ratatui-core 0.1.2 text/span/impl#[`Span<'a>`]raw().(" "), |
| 193 | Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#::styledrust-analyzer cargo ratatui-core 0.1.2 text/span/impl#[`Span<'a>`]styled().(regex, regex_style), |
| 194 | ]); |
| 195 | |
| 196 | search_text.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#::fromrust-analyzer cargo ratatui-core 0.1.2 text/line/impl#[`Line<'a>`][`From<Span<'a>>`]from().(Spanrust-analyzer cargo ratatui-core 0.1.2 text/span/Span#::styledrust-analyzer cargo ratatui-core 0.1.2 text/span/impl#[`Span<'a>`]styled().( |
| 197 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(err) = &proc_widget_state.proc_searchrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#proc_search..search_staterust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcessSearchState#search_state..error_messagerust-analyzer cargo bottom 0.14.9 app/states/AppSearchState#error_message. { |
| 198 | err.as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() |
| 199 | } else { |
| 200 | "" |
| 201 | }, |
| 202 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..invalid_query_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#invalid_query_style., |
| 203 | ))); |
| 204 | search_text.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(option_text); |
| 205 | |
| 206 | let current_border_style = |
| 207 | if proc_widget_state.proc_searchrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#proc_search..search_staterust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcessSearchState#search_state..is_invalid_searchrust-analyzer cargo bottom 0.14.9 app/states/AppSearchState#is_invalid_search. { |
| 208 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..invalid_query_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#invalid_query_style. |
| 209 | } else if is_selected { |
| 210 | 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. |
| 211 | } else { |
| 212 | self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..border_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#border_style. |
| 213 | }; |
| 214 | |
| 215 | let process_search_block = { |
| 216 | let mut block = widget_blockrust-analyzer cargo bottom 0.14.9 canvas/drawing_utils/widget_block().( |
| 217 | is_basic, |
| 218 | is_selected, |
| 219 | 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., |
| 220 | 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 | ) |
| 222 | .border_stylerust-analyzer cargo ratatui-widgets 0.3.2 block/impl#[`Block<'a>`]border_style().(current_border_style); |
| 223 | |
| 224 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_basic { |
| 225 | block = block.title_toprust-analyzer cargo ratatui-widgets 0.3.2 block/impl#[`Block<'a>`]title_top().( |
| 226 | Linerust-analyzer cargo ratatui-core 0.1.2 text/line/Line#::styledrust-analyzer cargo ratatui-core 0.1.2 text/line/impl#[`Line<'a>`]styled().(" Esc to close ", current_border_style).right_alignedrust-analyzer cargo ratatui-core 0.1.2 text/line/impl#[`Line<'a>`]right_aligned().(), |
| 227 | ) |
| 228 | } |
| 229 | |
| 230 | block |
| 231 | }; |
| 232 | |
| 233 | let margined_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().() |
| 234 | .constraintsrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]constraints().([Constraintrust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#::Percentagerust-analyzer cargo ratatui-core 0.1.2 layout/constraint/Constraint#Percentage#(100)]) |
| 235 | .horizontal_marginrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]horizontal_margin().(u16::fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/num/impl#[u16][`From<bool>`]from().(is_basic && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_selected)) |
| 236 | .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#) |
| 237 | .splitrust-analyzer cargo ratatui-core 0.1.2 layout/layout/impl#[Layout]split().(draw_loc)[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().; |
| 238 | |
| 239 | f.render_widgetrust-analyzer cargo ratatui-core 0.1.2 terminal/frame/impl#[`Frame<'_>`]render_widget().( |
| 240 | Paragraphrust-analyzer cargo ratatui-widgets 0.3.2 paragraph/Paragraph#::newrust-analyzer cargo ratatui-widgets 0.3.2 paragraph/impl#[`Paragraph<'a>`]new().(search_text) |
| 241 | .blockrust-analyzer cargo ratatui-widgets 0.3.2 paragraph/impl#[`Paragraph<'a>`]block().(process_search_block) |
| 242 | .stylerust-analyzer cargo ratatui-widgets 0.3.2 paragraph/impl#[`Paragraph<'a>`]style().(self.stylesrust-analyzer cargo bottom 0.14.9 canvas/Painter#styles..text_stylerust-analyzer cargo bottom 0.14.9 options/config/style/Styles#text_style.) |
| 243 | .alignmentrust-analyzer cargo ratatui-widgets 0.3.2 paragraph/impl#[`Paragraph<'a>`]alignment().(Alignmentrust-analyzer cargo ratatui-core 0.1.2 layout/alignment/Alignment#::Leftrust-analyzer cargo ratatui-core 0.1.2 layout/alignment/HorizontalAlignment#Left#), |
| 244 | margined_draw_loc, |
| 245 | ); |
| 246 | |
| 247 | if app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().() { |
| 248 | // Update draw loc in widget map |
| 249 | 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) { |
| 250 | 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#((margined_draw_loc.xrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#x., margined_draw_loc.yrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#y.)); |
| 251 | 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#(( |
| 252 | margined_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().margined_draw_loc.widthrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#width., |
| 253 | margined_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().margined_draw_loc.heightrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#height., |
| 254 | )); |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | /// Draws the process sort box. |
| 261 | /// - `widget_id` represents the widget ID of the sort box itself --- NOT |
| 262 | /// the process widget state that is stored. |
| 263 | fn draw_sort_tablerust-analyzer cargo bottom 0.14.9 canvas/widgets/process_table/impl#[Painter]draw_sort_table().( |
| 264 | &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, |
| 265 | ) { |
| 266 | let should_get_widget_bounds = app_state.should_get_widget_boundsrust-analyzer cargo bottom 0.14.9 app/impl#[App]should_get_widget_bounds().(); |
| 267 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pws) = app_state |
| 268 | .statesrust-analyzer cargo bottom 0.14.9 app/App#states. |
| 269 | .proc_staterust-analyzer cargo bottom 0.14.9 app/states/AppWidgetStates#proc_state. |
| 270 | .widget_statesrust-analyzer cargo bottom 0.14.9 app/states/ProcState#widget_states. |
| 271 | .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().2)) |
| 272 | { |
| 273 | let recalculate_column_widths = should_get_widget_bounds || pws.force_rerenderrust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#force_rerender.; |
| 274 | |
| 275 | 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.; |
| 276 | |
| 277 | let draw_info = DrawInforust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo# { |
| 278 | locrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#loc.: draw_loc, |
| 279 | 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., |
| 280 | recalculate_column_widthsrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/DrawInfo#recalculate_column_widths., |
| 281 | 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), |
| 282 | }; |
| 283 | |
| 284 | pws.sort_tablerust-analyzer cargo bottom 0.14.9 widgets/process_table/ProcWidgetState#sort_table..drawrust-analyzer cargo bottom 0.14.9 canvas/components/data_table/draw/impl#[`DataTable<DataType, H, S, C>`]draw().( |
| 285 | f, |
| 286 | &draw_info, |
| 287 | 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), |
| 288 | self, |
| 289 | ); |
| 290 | } |
| 291 | } |
| 292 | } |