pub struct SignDefinition {
pub name: String,
pub text: String,
pub fallback: String,
pub theme_element: String,
pub priority: i32,
pub column: String,
}Expand description
A sign definition: what it looks like, how it is styled, how it competes for its cell (SG.1).
vim’s :sign define / :sign place split, and the split is load-bearing
rather than historical. A definition is registered once and carries the
expensive, reusable parts — the glyph and its theme element. A placement
is (line, name) and happens per keystroke, per visible line, on every
refresh. Folding the two together would re-carry a glyph and a theme key
across the boundary for every marked line of every refresh, to say something
that was already true at load.
The host knows what a sign IS and nothing about what any particular sign MEANS — which is what makes this a mechanism rather than a feature. A provider’s marks, a plugin’s breakpoints and a future built-in all place signs through the same registry and are styled through the same theme.
Fields§
§name: StringThe name placements refer to. A provider’s own namespace by convention
(org-agenda-mark), unenforced — last definition wins, as with every
other registry here.
text: StringThe glyph when ui.nerd_fonts is on. One cell — SG.2b put signs
in the gutter’s single shared mark cell, so anything wider would push
every line of content right. Self::glyph_char is what the
renderers paint and it takes the first character.
fallback: StringThe BMP fallback, used when it is off — the same cell width, per the icon-degradation rule, so toggling the option cannot shift the gutter’s geometry.
theme_element: StringThe theme element the glyph is painted in (gutter.sign.* by
convention). Resolved by the renderer through the ordinary theme
registry, so a user or a theme retunes a plugin’s signs without either
knowing about the other.
priority: i32Which sign wins when two land on one line of the same column. Higher wins; ties break on name so the answer is stable rather than incidental to hash order.
One cell, one sign: a cell that stacked them would either grow unpredictably or silently drop one, and vim’s answer — priority — is the one users already know.
column: StringWhich gutter column this sign paints in (SG.4a).
Columns exist because contention is only meaningful between marks that
mean comparable things. A diagnostic and a git-diff mark are both
“something is true of this line”, but they answer different questions,
and a single contended cell would drop the git gutter on exactly the
lines a diagnostic touches — the lines a user is most likely to be
looking at. Vim’s single signcolumn accepts that trade; Helix and Zed
do not, and neither does this.
A name the host does not paint falls back to the FIRST column rather
than vanishing, on the same principle as the gutter.sign theme
fallback: a sign was placed to say something, and the failure mode that
loses the information entirely is the worst one available.
Use SIGN_COLUMN_MARK / SIGN_COLUMN_DIFF for the built-ins.
Implementations§
Source§impl SignDefinition
impl SignDefinition
Sourcepub fn glyph(&self, nerd_fonts: bool) -> &str
pub fn glyph(&self, nerd_fonts: bool) -> &str
The glyph for the current palette. Not a theme question — the theme decides the COLOUR, the font capability decides the GLYPH, and conflating them is how a themed editor renders tofu.
Sourcepub fn glyph_char(&self, nerd_fonts: bool) -> char
pub fn glyph_char(&self, nerd_fonts: bool) -> char
The single character the renderers paint into the gutter’s mark cell (SG.2b).
The cell is one column, so this TRUNCATES rather than trusting a producer to have obeyed the one-cell rule. A definition that ignores it loses its tail; the alternative is a gutter that silently widens and pushes every line of content sideways, which is a pixel change to content the user did not edit and costs far more than the glyph. An empty definition paints a blank, so a producer can place a sign that reserves the cell without drawing in it.
Trait Implementations§
Source§impl Clone for SignDefinition
impl Clone for SignDefinition
Source§fn clone(&self) -> SignDefinition
fn clone(&self) -> SignDefinition
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SignDefinition
impl Debug for SignDefinition
impl Eq for SignDefinition
Source§impl PartialEq for SignDefinition
impl PartialEq for SignDefinition
impl StructuralPartialEq for SignDefinition
Auto Trait Implementations§
impl Freeze for SignDefinition
impl RefUnwindSafe for SignDefinition
impl Send for SignDefinition
impl Sync for SignDefinition
impl Unpin for SignDefinition
impl UnsafeUnpin for SignDefinition
impl UnwindSafe for SignDefinition
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.