aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--src/ansi.rs2
-rw-r--r--src/renderer/mod.rs13
-rw-r--r--src/term/mod.rs5
4 files changed, 16 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 345f8a8c..a6febd06 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- PTY size not getting updated when message bar is shown
+- Text Cursor disappearing
## Version 0.3.2
diff --git a/src/ansi.rs b/src/ansi.rs
index 4e76c05b..c0ebb79c 100644
--- a/src/ansi.rs
+++ b/src/ansi.rs
@@ -343,7 +343,7 @@ pub trait Handler {
}
/// Describes shape of cursor
-#[derive(Debug, Eq, PartialEq, Copy, Clone, Deserialize)]
+#[derive(Debug, Eq, PartialEq, Copy, Clone, Hash, Deserialize)]
pub enum CursorStyle {
/// Cursor is a block like `▒`
Block,
diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs
index fd10c861..c0e3081d 100644
--- a/src/renderer/mod.rs
+++ b/src/renderer/mod.rs
@@ -26,6 +26,7 @@ use font::{self, FontDesc, FontKey, GlyphKey, Rasterize, RasterizedGlyph, Raster
use glutin::dpi::PhysicalSize;
use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher};
+use crate::ansi::CursorStyle;
use crate::config::{self, Config, Delta};
use crate::gl;
use crate::gl::types::*;
@@ -154,6 +155,9 @@ pub struct GlyphCache {
/// Cache of buffered glyphs
cache: HashMap<GlyphKey, Glyph, BuildHasherDefault<FnvHasher>>,
+ /// Cache of buffered cursor glyphs
+ cursor_cache: HashMap<CursorStyle, Glyph, BuildHasherDefault<FnvHasher>>,
+
/// Rasterizer for loading new glyphs
rasterizer: Rasterizer,
@@ -195,6 +199,7 @@ impl GlyphCache {
let mut cache = GlyphCache {
cache: HashMap::default(),
+ cursor_cache: HashMap::default(),
rasterizer,
font_size: font.size(),
font_key: regular,
@@ -302,6 +307,7 @@ impl GlyphCache {
// Clear currently cached data in both GL and the registry
loader.clear();
self.cache = HashMap::default();
+ self.cursor_cache = HashMap::default();
// Update dpi scaling
self.rasterizer.update_dpr(dpr as f32);
@@ -984,9 +990,12 @@ impl<'a> RenderApi<'a> {
pub fn render_cell(&mut self, cell: RenderableCell, glyph_cache: &mut GlyphCache) {
let chars = match cell.inner {
- RenderableCellContent::Raw(ref raw) => {
+ RenderableCellContent::Cursor((cursor_style, ref raw)) => {
// Raw cell pixel buffers like cursors don't need to go through font lookup
- let glyph = self.load_glyph(raw);
+ let glyph = glyph_cache
+ .cursor_cache
+ .entry(cursor_style)
+ .or_insert_with(|| self.load_glyph(raw));
self.add_render_item(&cell, &glyph);
return;
},
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 2096e7a1..a9a3841f 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -259,7 +259,7 @@ impl<'a> RenderableCellsIter<'a> {
#[derive(Clone, Debug)]
pub enum RenderableCellContent {
Chars([char; cell::MAX_ZEROWIDTH_CHARS + 1]),
- Raw(RasterizedGlyph),
+ Cursor((CursorStyle, RasterizedGlyph)),
}
#[derive(Clone, Debug)]
@@ -388,7 +388,8 @@ impl<'a> Iterator for RenderableCellsIter<'a> {
let mut renderable_cell =
RenderableCell::new(self.config, self.colors, cell, false);
- renderable_cell.inner = RenderableCellContent::Raw(cursor_cell);
+ renderable_cell.inner =
+ RenderableCellContent::Cursor((self.cursor_style, cursor_cell));
if let Some(color) = self.config.cursor_cursor_color() {
renderable_cell.fg = color;