1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
//! A text selection API built around `iced`'s [`Paragraph`].
//!
//! [`Paragraph`]: https://docs.iced.rs/iced_graphics/text/paragraph/struct.Paragraph.html
pub mod markdown;
pub mod selection;
pub mod text;
use iced_widget::core;
use iced_widget::graphics::text::Paragraph;
pub use markdown::view as markdown;
#[doc(no_inline)]
pub use text::Text;
/// Creates a new [`Text`] widget with the provided content.
#[macro_export]
macro_rules! text {
($($arg:tt)*) => {
$crate::Text::new(format!($($arg)*))
};
}
/// Creates some [`Rich`] text with the given spans.
///
/// [`Rich`]: crate::text::Rich
#[macro_export]
macro_rules! rich_text {
() => (
$crate::text::Rich::new()
);
($($x:expr),+ $(,)?) => (
$crate::text::Rich::from_iter([$($crate::text::Span::from($x)),+])
);
}
/// Creates a new [`Text`] widget with the provided content.
pub fn text<'a, Theme, Renderer>(
text: impl text::IntoFragment<'a>,
) -> Text<'a, Theme, Renderer>
where
Theme: text::Catalog + 'a,
Renderer: core::text::Renderer,
{
Text::new(text)
}
/// Creates some [`Rich`] text with the given spans.
///
/// [`Rich`]: crate::text::Rich
pub fn rich_text<'a, Link, Message, Theme, Renderer>(
spans: impl AsRef<[text::Span<'a, Link, core::Font>]> + 'a,
) -> text::Rich<'a, Link, Message, Theme, Renderer>
where
Link: Clone + 'static,
Theme: text::Catalog + 'a,
Renderer: core::text::Renderer<Paragraph = Paragraph, Font = core::Font>,
{
text::Rich::with_spans(spans)
}
/// Creates a new [`Span`] of text with the provided content.
///
/// A [`Span`] is a fragment of some [`Rich`] text.
///
/// [`Rich`]: crate::text::Rich
/// [`Span`]: crate::text::Span
pub fn span<'a, Link>(
text: impl text::IntoFragment<'a>,
) -> text::Span<'a, Link, core::Font> {
text::Span::new(text)
}
|