Skip to content

Commit

Permalink
fix fat cursor on commas
Browse files Browse the repository at this point in the history
  • Loading branch information
misson20000 committed Sep 25, 2024
1 parent 998e4b8 commit c899bd2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/view/gsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub struct Cache {
font: pango::Font,

gs_space: pango::GlyphString, // " "
gs_comma: pango::GlyphString, // ", "
gs_comma: pango::GlyphString, // ","
gs_open: pango::GlyphString, // "{"
gs_close: pango::GlyphString, // "}"
gs_digit: [pango::GlyphString; 16], // "0", "1", ..., "f"
Expand Down Expand Up @@ -70,7 +70,7 @@ impl Cache {
font: font.clone(),

gs_space,
gs_comma: Self::shape(pg, token::PunctuationKind::Comma.as_str()),
gs_comma: Self::shape(pg, ","),
gs_open: Self::shape(pg, token::PunctuationKind::OpenBracket.as_str()),
gs_close: Self::shape(pg, token::PunctuationKind::CloseBracket.as_str()),
gs_digit: DIGIT_STRINGS.map(|d| Self::shape(pg, d)),
Expand Down Expand Up @@ -192,6 +192,7 @@ impl<'a, I: Iterator<Item = pango::GlyphString>> TextBuilder<'a, I> {
if enable {
self.config.placeholder = Some(placeholder_color);
}

self
}

Expand Down
9 changes: 9 additions & 0 deletions src/view/listing/token_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ impl TokenView {
.cursor(has_cursor, cursor, render.config.cursor_fg_color.rgba(), render.config.cursor_bg_color.rgba())
.selected(selected, render.config.selection_color.rgba())
.render(snapshot);

/* need to render space separately so it doesn't draw cursor because that looks bad */
match token.kind {
token::PunctuationKind::Comma => render.gsc_mono.begin(gsc::Entry::Space, render.config.text_color.rgba(), &mut pos)
.selected(selected, render.config.selection_color.rgba())
.render(snapshot),

_ => {}
}
},
token::Token::Title(token) => {
gsc::begin_text(
Expand Down

0 comments on commit c899bd2

Please sign in to comment.