(
ui: &mut Ui,
items: Vec<ContextItem>,
column: usize,
appearance: &Appearance,
)
| 952 | } |
| 953 | |
| 954 | pub fn context_menu_items_ui( |
| 955 | ui: &mut Ui, |
| 956 | items: Vec<ContextItem>, |
| 957 | column: usize, |
| 958 | appearance: &Appearance, |
| 959 | ) -> Option<DiffViewAction> { |
| 960 | let mut ret = None; |
| 961 | for item in items { |
| 962 | match item { |
| 963 | ContextItem::Copy { value, label, copy_string } => { |
| 964 | let mut job = LayoutJob::default(); |
| 965 | write_text("Copy ", appearance.text_color, &mut job, appearance.code_font.clone()); |
| 966 | write_text( |
| 967 | &format!("{value:?}"), |
| 968 | appearance.highlight_color, |
| 969 | &mut job, |
| 970 | appearance.code_font.clone(), |
| 971 | ); |
| 972 | if let Some(label) = label { |
| 973 | write_text(" (", appearance.text_color, &mut job, appearance.code_font.clone()); |
| 974 | write_text( |
| 975 | &label, |
| 976 | appearance.text_color, |
| 977 | &mut job, |
| 978 | appearance.code_font.clone(), |
| 979 | ); |
| 980 | write_text(")", appearance.text_color, &mut job, appearance.code_font.clone()); |
| 981 | } |
| 982 | if ui.button(job).clicked() { |
| 983 | ui.ctx().copy_text(copy_string.unwrap_or(value)); |
| 984 | ui.close(); |
| 985 | } |
| 986 | } |
| 987 | ContextItem::Navigate { label, symbol_index, kind } => { |
| 988 | if ui.button(label).clicked() { |
| 989 | ret = Some(DiffViewAction::Navigate(DiffViewNavigation::new( |
| 990 | kind, |
| 991 | symbol_index, |
| 992 | column, |
| 993 | ))); |
| 994 | ui.close(); |
| 995 | } |
| 996 | } |
| 997 | ContextItem::Separator => { |
| 998 | ui.separator(); |
| 999 | } |
| 1000 | } |
| 1001 | } |
| 1002 | ret |
| 1003 | } |
no test coverage detected