mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
Add support for rendering cursors to rusttype
This commit is contained in:
parent
a7e59d393d
commit
34ada9295d
3 changed files with 33 additions and 1 deletions
|
@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Fixed
|
||||
|
||||
- Fixed erroneous results when using the `indexed_colors` config option
|
||||
- Fixed rendering cursors other than rectangular with the RustType backend
|
||||
|
||||
## Version 0.2.1
|
||||
|
||||
|
|
|
@ -240,7 +240,12 @@ selection:
|
|||
|
||||
hide_cursor_when_typing: false
|
||||
|
||||
# - Beam
|
||||
# Cursor style
|
||||
#
|
||||
# Values for 'cursor_style':
|
||||
# - Block
|
||||
# - Underline
|
||||
# - Beam
|
||||
cursor_style: Block
|
||||
|
||||
# Whether the cursor should be a hollow block on window focus loss
|
||||
|
|
|
@ -72,6 +72,32 @@ impl ::Rasterize for RustTypeRasterizer {
|
|||
}
|
||||
|
||||
fn get_glyph(&mut self, glyph_key: GlyphKey) -> Result<RasterizedGlyph, Error> {
|
||||
match glyph_key.c {
|
||||
super::UNDERLINE_CURSOR_CHAR => {
|
||||
let metrics = self.metrics(glyph_key.font_key, glyph_key.size)?;
|
||||
return super::get_underline_cursor_glyph(metrics.descent as i32, metrics.average_advance as i32);
|
||||
}
|
||||
super::BEAM_CURSOR_CHAR => {
|
||||
let metrics = self.metrics(glyph_key.font_key, glyph_key.size)?;
|
||||
|
||||
return super::get_beam_cursor_glyph(
|
||||
(metrics.line_height + f64::from(metrics.descent)).round() as i32,
|
||||
metrics.line_height.round() as i32,
|
||||
metrics.average_advance.round() as i32
|
||||
);
|
||||
}
|
||||
super::BOX_CURSOR_CHAR => {
|
||||
let metrics = self.metrics(glyph_key.font_key, glyph_key.size)?;
|
||||
|
||||
return super::get_box_cursor_glyph(
|
||||
(metrics.line_height + f64::from(metrics.descent)).round() as i32,
|
||||
metrics.line_height.round() as i32,
|
||||
metrics.average_advance.round() as i32
|
||||
);
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
|
||||
let scaled_glyph = self.fonts[glyph_key.font_key.token as usize]
|
||||
.glyph(glyph_key.c)
|
||||
.ok_or(Error::MissingGlyph)?
|
||||
|
|
Loading…
Reference in a new issue