| 1 | mod code_action_menu; |
| 2 | mod completion_menu; |
| 3 | mod diagnostic_popover; |
| 4 | mod hover_popover; |
| 5 | |
| 6 | pub(crate) use code_action_menu::*; |
| 7 | pub(crate) use completion_menu::*; |
| 8 | pub(crate) use diagnostic_popover::*; |
| 9 | pub(crate) use hover_popover::*; |
| 10 | |
| 11 | use gpui::{ |
| 12 | App, Div, ElementId, InteractiveElement as _, SharedString, Stateful, StyleRefinement, |
| 13 | Styled as _, Window, div, px, rems, |
| 14 | }; |
| 15 | |
| 16 | use crate::{ |
| 17 | ActiveTheme, ThemeStyled as _, |
| 18 | text::{TextView, TextViewStyle}, |
| 19 | }; |
| 20 | |
| 21 | pub(super) fn render_markdown( |
| 22 | id: impl Into<ElementId>, |
| 23 | markdown: impl Into<SharedString>, |
| 24 | _: &mut Window, |
| 25 | cx: &mut App, |
| 26 | ) -> TextView { |
| 27 | TextView::markdown(id, markdown) |
| 28 | .style( |
| 29 | TextViewStyle::default() |
| 30 | .paragraph_gap(rems(0.5)) |
| 31 | .heading_font_size(|level, rem_size| match level { |
| 32 | 1..=3 => rem_size * 1, |
| 33 | 4 => rem_size * 0.9, |
| 34 | _ => rem_size * 0.8, |
| 35 | }) |
| 36 | .code_block( |
| 37 | StyleRefinement::default() |
| 38 | .bg(cx.theme().transparent) |
| 39 | .p_0() |
| 40 | .text_size(px(11.)), |
| 41 | ), |
| 42 | ) |
| 43 | .selectable(true) |
| 44 | } |
| 45 | |
| 46 | pub(super) fn editor_popover(id: impl Into<ElementId>, window: &Window, cx: &App) -> Stateful<Div> { |
| 47 | div() |
| 48 | .id(id) |
| 49 | .flex_none() |
| 50 | .occlude() |
| 51 | .popover_style(window, cx) |
| 52 | .text_xs() |
| 53 | .p_1() |
| 54 | } |