pub struct Decoration {
pub version: u32,
pub kind: DecorationKind,
pub severity: Option<Severity>,
pub color: Option<ColorRole>,
pub range: CodeRange,
pub id: u64,
pub text: String,
}Expand description
One thing drawn over the document, said as a range and never as a picture.
The colour of an underline is a role, never a literal, and is left to the design system where it is not given; the shape of the mark, a squiggle or a line, and its weight are always the design system’s.
Fields§
§version: u32The document version the range was written against.
kind: DecorationKind§severity: Option<Severity>Only an underline has one.
color: Option<ColorRole>The role an underline is drawn in. None leaves it to the design system, which picks one that suits the severity.
range: CodeRange§id: u64The application’s own name for this decoration, reported when it is pressed, accepted or hovered. Zero means it cannot be pressed and is never reported.
text: StringWhat a lens or a suggestion shows. Empty for the other two kinds.
Implementations§
Source§impl Decoration
impl Decoration
Sourcepub fn underline(version: u32, range: CodeRange, severity: Severity) -> Self
pub fn underline(version: u32, range: CodeRange, severity: Severity) -> Self
A diagnostic mark under a range.
Sourcepub fn code_lens(
version: u32,
line: u32,
text: impl Into<String>,
id: u64,
) -> Self
pub fn code_lens( version: u32, line: u32, text: impl Into<String>, id: u64, ) -> Self
A short line of text shown above line, which reports id when pressed.
Sourcepub fn hover_anchor(version: u32, range: CodeRange, id: u64) -> Self
pub fn hover_anchor(version: u32, range: CodeRange, id: u64) -> Self
A range that reports id when a pointer comes to rest over it.
Sourcepub fn ghost_text(
version: u32,
at: Position,
text: impl Into<String>,
id: u64,
) -> Self
pub fn ghost_text( version: u32, at: Position, text: impl Into<String>, id: u64, ) -> Self
A suggestion shown faintly at at. Accepting it inserts text there as an
ordinary edit and then reports id.
Sourcepub fn line_background(
version: u32,
line_start: u32,
line_end: u32,
color: ColorRole,
) -> Self
pub fn line_background( version: u32, line_start: u32, line_end: u32, color: ColorRole, ) -> Self
A tint across lines line_start to line_end, both included, the whole width of the
editor and past the end of each line. color is a role such as DiffAdded,
DiffRemoved or DiffModified, and the design system decides how strong the tint
of each is. The lines follow the reader’s edits like every other decoration.
Sourcepub fn range_background(
version: u32,
range: CodeRange,
color: ColorRole,
) -> Self
pub fn range_background( version: u32, range: CodeRange, color: ColorRole, ) -> Self
A tint over the characters of range, stronger than a line background in the same
role, for the part of a changed line that changed.
Sourcepub fn with_color(self, role: ColorRole) -> Self
pub fn with_color(self, role: ColorRole) -> Self
Draws an underline in this role rather than the one the design system would pick.