mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 10:40:54 +00:00
Convert rich_text2
This commit is contained in:
parent
6ecb4805f7
commit
0b3932f38c
4 changed files with 59 additions and 18 deletions
22
Cargo.lock
generated
22
Cargo.lock
generated
|
@ -5115,7 +5115,7 @@ dependencies = [
|
|||
"project2",
|
||||
"pulldown-cmark",
|
||||
"rand 0.8.5",
|
||||
"rich_text",
|
||||
"rich_text2",
|
||||
"schemars",
|
||||
"serde",
|
||||
"serde_derive",
|
||||
|
@ -6947,6 +6947,24 @@ dependencies = [
|
|||
"util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rich_text2"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"collections",
|
||||
"futures 0.3.28",
|
||||
"gpui2",
|
||||
"language2",
|
||||
"lazy_static",
|
||||
"pulldown-cmark",
|
||||
"smallvec",
|
||||
"smol",
|
||||
"sum_tree",
|
||||
"theme2",
|
||||
"util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.16.20"
|
||||
|
@ -8876,7 +8894,7 @@ name = "theme2"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"fs",
|
||||
"fs2",
|
||||
"gpui2",
|
||||
"indexmap 1.9.3",
|
||||
"parking_lot 0.11.2",
|
||||
|
|
29
crates/rich_text2/Cargo.toml
Normal file
29
crates/rich_text2/Cargo.toml
Normal file
|
@ -0,0 +1,29 @@
|
|||
[package]
|
||||
name = "rich_text2"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
[lib]
|
||||
path = "src/rich_text.rs"
|
||||
doctest = false
|
||||
|
||||
[features]
|
||||
test-support = [
|
||||
"gpui/test-support",
|
||||
"util/test-support",
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
collections = { path = "../collections" }
|
||||
gpui = { package = "gpui2", path = "../gpui2" }
|
||||
sum_tree = { path = "../sum_tree" }
|
||||
theme = { package = "theme2", path = "../theme2" }
|
||||
language = { package = "language2", path = "../language2" }
|
||||
util = { path = "../util" }
|
||||
anyhow.workspace = true
|
||||
futures.workspace = true
|
||||
lazy_static.workspace = true
|
||||
pulldown-cmark = { version = "0.9.2", default-features = false }
|
||||
smallvec.workspace = true
|
||||
smol.workspace = true
|
|
@ -2,14 +2,8 @@ use std::{ops::Range, sync::Arc};
|
|||
|
||||
use anyhow::bail;
|
||||
use futures::FutureExt;
|
||||
use gpui::{
|
||||
elements::Text,
|
||||
fonts::{HighlightStyle, Underline, Weight},
|
||||
platform::{CursorStyle, MouseButton},
|
||||
AnyElement, CursorRegion, Element, MouseRegion, ViewContext,
|
||||
};
|
||||
use gpui::{AnyElement, FontStyle, FontWeight, HighlightStyle, UnderlineStyle};
|
||||
use language::{HighlightId, Language, LanguageRegistry};
|
||||
use theme::{RichTextStyle, SyntaxTheme};
|
||||
use util::RangeExt;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -64,9 +58,9 @@ pub struct Mention {
|
|||
impl RichText {
|
||||
pub fn element<V: 'static>(
|
||||
&self,
|
||||
syntax: Arc<SyntaxTheme>,
|
||||
style: RichTextStyle,
|
||||
cx: &mut ViewContext<V>,
|
||||
// syntax: Arc<SyntaxTheme>,
|
||||
// style: RichTextStyle,
|
||||
// cx: &mut ViewContext<V>,
|
||||
) -> AnyElement<V> {
|
||||
todo!();
|
||||
|
||||
|
@ -203,10 +197,10 @@ pub fn render_markdown_mut(
|
|||
data.text.push_str(t.as_ref());
|
||||
let mut style = HighlightStyle::default();
|
||||
if bold_depth > 0 {
|
||||
style.weight = Some(Weight::BOLD);
|
||||
style.font_weight = Some(FontWeight::BOLD);
|
||||
}
|
||||
if italic_depth > 0 {
|
||||
style.italic = Some(true);
|
||||
style.font_style = Some(FontStyle::Italic);
|
||||
}
|
||||
if let Some(link_url) = link_url.clone() {
|
||||
data.region_ranges.push(prev_len..data.text.len());
|
||||
|
@ -214,7 +208,7 @@ pub fn render_markdown_mut(
|
|||
link_url: Some(link_url),
|
||||
background_kind: None,
|
||||
});
|
||||
style.underline = Some(Underline {
|
||||
style.underline = Some(UnderlineStyle {
|
||||
thickness: 1.0.into(),
|
||||
..Default::default()
|
||||
});
|
||||
|
@ -244,7 +238,7 @@ pub fn render_markdown_mut(
|
|||
data.highlights.push((
|
||||
prev_len..data.text.len(),
|
||||
Highlight::Highlight(HighlightStyle {
|
||||
underline: Some(Underline {
|
||||
underline: Some(UnderlineStyle {
|
||||
thickness: 1.0.into(),
|
||||
..Default::default()
|
||||
}),
|
||||
|
|
|
@ -17,7 +17,7 @@ doctest = false
|
|||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
fs = { path = "../fs" }
|
||||
fs = { package = "fs2", path = "../fs2" }
|
||||
gpui = { package = "gpui2", path = "../gpui2" }
|
||||
indexmap = "1.6.2"
|
||||
parking_lot.workspace = true
|
||||
|
@ -32,5 +32,5 @@ util = { path = "../util" }
|
|||
|
||||
[dev-dependencies]
|
||||
gpui = { package = "gpui2", path = "../gpui2", features = ["test-support"] }
|
||||
fs = { path = "../fs", features = ["test-support"] }
|
||||
fs = { package = "fs2", path = "../fs2", features = ["test-support"] }
|
||||
settings = { package = "settings2", path = "../settings2", features = ["test-support"] }
|
||||
|
|
Loading…
Reference in a new issue