Merge branch 'main' into cursors

This commit is contained in:
Conrad Irwin 2024-01-18 14:03:27 -07:00
commit bfee008bb2
199 changed files with 3365 additions and 1735 deletions

View file

@ -250,8 +250,8 @@ impl TerminalElement {
//Layout current cell text
{
let cell_text = cell.c.to_string();
if !is_blank(&cell) {
let cell_text = cell.c.to_string();
let cell_style =
TerminalElement::cell_style(&cell, fg, theme, text_style, hyperlink);
@ -446,7 +446,7 @@ impl TerminalElement {
let last_hovered_word = self.terminal.update(cx, |terminal, cx| {
terminal.set_size(dimensions);
terminal.try_sync(cx);
terminal.sync(cx);
if self.can_navigate_to_selected_word && terminal.can_navigate_to_selected_word() {
terminal.last_content.last_hovered_word.clone()
} else {
@ -587,24 +587,6 @@ impl TerminalElement {
}
}
fn register_key_listeners(&self, cx: &mut WindowContext) {
cx.on_key_event({
let this = self.terminal.clone();
move |event: &ModifiersChangedEvent, phase, cx| {
if phase != DispatchPhase::Bubble {
return;
}
let handled =
this.update(cx, |term, _| term.try_modifiers_change(&event.modifiers));
if handled {
cx.refresh();
}
}
});
}
fn register_mouse_listeners(
&mut self,
origin: Point<Pixels>,
@ -772,53 +754,68 @@ impl Element for TerminalElement {
self.register_mouse_listeners(origin, layout.mode, bounds, cx);
let mut interactivity = mem::take(&mut self.interactivity);
interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {
cx.handle_input(&self.focus, terminal_input_handler);
self.interactivity
.paint(bounds, bounds.size, state, cx, |_, _, cx| {
cx.handle_input(&self.focus, terminal_input_handler);
self.register_key_listeners(cx);
cx.on_key_event({
let this = self.terminal.clone();
move |event: &ModifiersChangedEvent, phase, cx| {
if phase != DispatchPhase::Bubble {
return;
}
for rect in &layout.rects {
rect.paint(origin, &layout, cx);
}
let handled =
this.update(cx, |term, _| term.try_modifiers_change(&event.modifiers));
cx.with_z_index(1, |cx| {
for (relative_highlighted_range, color) in layout.relative_highlighted_ranges.iter()
{
if let Some((start_y, highlighted_range_lines)) =
to_highlighted_range_lines(relative_highlighted_range, &layout, origin)
{
let hr = HighlightedRange {
start_y, //Need to change this
line_height: layout.dimensions.line_height,
lines: highlighted_range_lines,
color: color.clone(),
//Copied from editor. TODO: move to theme or something
corner_radius: 0.15 * layout.dimensions.line_height,
};
hr.paint(bounds, cx);
}
}
});
cx.with_z_index(2, |cx| {
for cell in &layout.cells {
cell.paint(origin, &layout, bounds, cx);
}
});
if self.cursor_visible {
cx.with_z_index(3, |cx| {
if let Some(cursor) = &layout.cursor {
cursor.paint(origin, cx);
if handled {
cx.refresh();
}
}
});
}
if let Some(mut element) = layout.hyperlink_tooltip.take() {
element.draw(origin, bounds.size.map(AvailableSpace::Definite), cx)
}
});
for rect in &layout.rects {
rect.paint(origin, &layout, cx);
}
cx.with_z_index(1, |cx| {
for (relative_highlighted_range, color) in
layout.relative_highlighted_ranges.iter()
{
if let Some((start_y, highlighted_range_lines)) =
to_highlighted_range_lines(relative_highlighted_range, &layout, origin)
{
let hr = HighlightedRange {
start_y, //Need to change this
line_height: layout.dimensions.line_height,
lines: highlighted_range_lines,
color: color.clone(),
//Copied from editor. TODO: move to theme or something
corner_radius: 0.15 * layout.dimensions.line_height,
};
hr.paint(bounds, cx);
}
}
});
cx.with_z_index(2, |cx| {
for cell in &layout.cells {
cell.paint(origin, &layout, bounds, cx);
}
});
if self.cursor_visible {
cx.with_z_index(3, |cx| {
if let Some(cursor) = &layout.cursor {
cursor.paint(origin, cx);
}
});
}
if let Some(mut element) = layout.hyperlink_tooltip.take() {
element.draw(origin, bounds.size.map(AvailableSpace::Definite), cx)
}
});
}
}