added cursor text back

This commit is contained in:
Mikayla Maki 2022-07-21 10:04:12 -07:00
parent ee87c8ebde
commit 7c0a031506
3 changed files with 11 additions and 10 deletions

View File

@ -366,7 +366,7 @@ impl Terminal {
pub fn render_lock<F, T>(&self, new_size: Option<TerminalDimensions>, f: F) -> T
where
F: FnOnce(RenderableContent) -> T,
F: FnOnce(RenderableContent, char) -> T,
{
if let Some(new_size) = new_size {
self.pty_tx.0.send(Msg::Resize(new_size.into())).ok(); //Give the PTY a chance to react to the new size
@ -380,7 +380,9 @@ impl Terminal {
}
let content = term.renderable_content();
f(content)
let cursor_text = term.grid()[content.cursor.point].c;
f(content, cursor_text)
}
pub fn get_display_offset(&self) -> usize {

View File

@ -333,7 +333,7 @@ impl Element for TerminalEl {
let terminal = self.connection.upgrade(cx).unwrap().read(cx);
let (cursor, cells, rects, highlights) =
terminal.render_lock(Some(layout.size.clone()), |content| {
terminal.render_lock(Some(layout.size.clone()), |content, cursor_text| {
let (cells, rects, highlights) = layout_grid(
content.display_iter,
&layout.text_style,
@ -345,7 +345,7 @@ impl Element for TerminalEl {
//Layout cursor
let cursor = layout_cursor(
// grid,
cursor_text,
cx.text_layout_cache,
&layout,
content.cursor.point,
@ -522,14 +522,14 @@ impl Element for TerminalEl {
///TODO: Fix cursor rendering with alacritty fork
fn layout_cursor(
// grid: &Grid<Cell>,
cursor_text: char,
text_layout_cache: &TextLayoutCache,
tcx: &TerminalLayoutData,
cursor_point: Point,
display_offset: usize,
constraint: SizeConstraint,
) -> Option<Cursor> {
let cursor_text = layout_cursor_text(/*grid,*/ cursor_point, text_layout_cache, tcx);
let cursor_text = layout_cursor_text(cursor_text, cursor_point, text_layout_cache, tcx);
get_cursor_shape(
cursor_point.line.0 as usize,
cursor_point.column.0 as usize,
@ -558,13 +558,12 @@ fn layout_cursor(
}
fn layout_cursor_text(
// grid: &Grid<Cell>,
cursor_text: char,
_cursor_point: Point,
text_layout_cache: &TextLayoutCache,
tcx: &TerminalLayoutData,
) -> Line {
let cursor_text = " "; //grid[cursor_point.line][cursor_point.column].c.to_string();
let cursor_text = cursor_text.to_string();
text_layout_cache.layout_str(
&cursor_text,
tcx.text_style.font_size,

View File

@ -57,7 +57,7 @@ impl<'a> TerminalTestContext<'a> {
}
fn grid_as_str(connection: &Terminal) -> String {
connection.render_lock(None, |content| {
connection.render_lock(None, |content, _| {
let lines = content.display_iter.group_by(|i| i.point.line.0);
lines
.into_iter()