BlueGit

ict rusty-teams

Files

rusty-teams / crates / app-ui-kit / src / render / hooks.rs

hooks.rs

f9ed0525 History
hooks.rs 872 B Download Raw
1use gpui_kit::*;
2
3#[derive(Clone, Copy)]
4pub struct RenderHooks {
5 pub open_profile_link: fn(&str, Point<Pixels>, &mut App) -> bool,
6 pub jump_to_quoted: fn(String, &mut App),
7 pub inline_image: fn(&str, &App) -> Option<std::path::PathBuf>,
8}
9
10impl Global for RenderHooks {}
11
12pub fn open_profile_link(url: &str, position: Point<Pixels>, cx: &mut App) -> bool {
13 match cx.try_global::<RenderHooks>().copied() {
14 Some(hooks) => (hooks.open_profile_link)(url, position, cx),
15 None => false,
16 }
17}
18
19pub fn jump_to_quoted(message_id: String, cx: &mut App) {
20 if let Some(hooks) = cx.try_global::<RenderHooks>().copied() {
21 (hooks.jump_to_quoted)(message_id, cx);
22 }
23}
24
25pub fn inline_image(url: &str, cx: &App) -> Option<std::path::PathBuf> {
26 let hooks = cx.try_global::<RenderHooks>().copied()?;
27 (hooks.inline_image)(url, cx)
28}