Added background colors and matched the cursor color
This commit is contained in:
parent
5bc0acd88c
commit
06107afdd4
1 changed files with 19 additions and 6 deletions
|
@ -42,8 +42,9 @@ pub struct LayoutState {
|
||||||
lines: Vec<Line>,
|
lines: Vec<Line>,
|
||||||
line_height: f32,
|
line_height: f32,
|
||||||
em_width: f32,
|
em_width: f32,
|
||||||
cursor: Option<RectF>,
|
cursor: Option<(RectF, Color)>,
|
||||||
cur_size: SizeInfo,
|
cur_size: SizeInfo,
|
||||||
|
background_color: Color,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Element for TerminalEl {
|
impl Element for TerminalEl {
|
||||||
|
@ -114,9 +115,12 @@ impl Element for TerminalEl {
|
||||||
.and_then(|cursor_line: usize| shaped_lines.get(cursor_line))
|
.and_then(|cursor_line: usize| shaped_lines.get(cursor_line))
|
||||||
{
|
{
|
||||||
let cursor_x = layout_line.x_for_index(content.cursor.point.column.0);
|
let cursor_x = layout_line.x_for_index(content.cursor.point.column.0);
|
||||||
cursor = Some(RectF::new(
|
cursor = Some((
|
||||||
vec2f(cursor_x, cursor_line as f32 * line_height),
|
RectF::new(
|
||||||
vec2f(cell_width, line_height),
|
vec2f(cursor_x, cursor_line as f32 * line_height),
|
||||||
|
vec2f(cell_width, line_height),
|
||||||
|
),
|
||||||
|
terminal_theme.cursor,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +132,7 @@ impl Element for TerminalEl {
|
||||||
em_width: cell_width,
|
em_width: cell_width,
|
||||||
cursor,
|
cursor,
|
||||||
cur_size: new_size,
|
cur_size: new_size,
|
||||||
|
background_color: terminal_theme.background,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -155,6 +160,14 @@ impl Element for TerminalEl {
|
||||||
right_mouse_down_out: None,
|
right_mouse_down_out: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//Background
|
||||||
|
cx.scene.push_quad(Quad {
|
||||||
|
bounds: visible_bounds,
|
||||||
|
background: Some(layout.background_color),
|
||||||
|
border: Default::default(),
|
||||||
|
corner_radius: 0.,
|
||||||
|
});
|
||||||
|
|
||||||
let origin = bounds.origin() + vec2f(layout.em_width, 0.); //Padding
|
let origin = bounds.origin() + vec2f(layout.em_width, 0.); //Padding
|
||||||
|
|
||||||
let mut line_origin = origin;
|
let mut line_origin = origin;
|
||||||
|
@ -168,12 +181,12 @@ impl Element for TerminalEl {
|
||||||
line_origin.set_y(boundaries.max_y());
|
line_origin.set_y(boundaries.max_y());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(c) = layout.cursor {
|
if let Some((c, color)) = layout.cursor {
|
||||||
let new_origin = origin + c.origin();
|
let new_origin = origin + c.origin();
|
||||||
let new_cursor = RectF::new(new_origin, c.size());
|
let new_cursor = RectF::new(new_origin, c.size());
|
||||||
cx.scene.push_quad(Quad {
|
cx.scene.push_quad(Quad {
|
||||||
bounds: new_cursor,
|
bounds: new_cursor,
|
||||||
background: Some(Color::white()),
|
background: Some(color),
|
||||||
border: Default::default(),
|
border: Default::default(),
|
||||||
corner_radius: 0.,
|
corner_radius: 0.,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue