mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-08 19:43:11 +00:00
Remove memmove to improve terminal performance
Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
parent
79679cb616
commit
51127460b2
1 changed files with 57 additions and 60 deletions
|
@ -250,8 +250,8 @@ impl TerminalElement {
|
||||||
|
|
||||||
//Layout current cell text
|
//Layout current cell text
|
||||||
{
|
{
|
||||||
let cell_text = cell.c.to_string();
|
|
||||||
if !is_blank(&cell) {
|
if !is_blank(&cell) {
|
||||||
|
let cell_text = cell.c.to_string();
|
||||||
let cell_style =
|
let cell_style =
|
||||||
TerminalElement::cell_style(&cell, fg, theme, text_style, hyperlink);
|
TerminalElement::cell_style(&cell, fg, theme, text_style, hyperlink);
|
||||||
|
|
||||||
|
@ -586,24 +586,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(
|
fn register_mouse_listeners(
|
||||||
&mut self,
|
&mut self,
|
||||||
origin: Point<Pixels>,
|
origin: Point<Pixels>,
|
||||||
|
@ -771,53 +753,68 @@ impl Element for TerminalElement {
|
||||||
|
|
||||||
self.register_mouse_listeners(origin, layout.mode, bounds, cx);
|
self.register_mouse_listeners(origin, layout.mode, bounds, cx);
|
||||||
|
|
||||||
let mut interactivity = mem::take(&mut self.interactivity);
|
self.interactivity
|
||||||
interactivity.paint(bounds, bounds.size, state, cx, |_, _, cx| {
|
.paint(bounds, bounds.size, state, cx, |_, _, cx| {
|
||||||
cx.handle_input(&self.focus, terminal_input_handler);
|
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 {
|
let handled =
|
||||||
rect.paint(origin, &layout, cx);
|
this.update(cx, |term, _| term.try_modifiers_change(&event.modifiers));
|
||||||
}
|
|
||||||
|
|
||||||
cx.with_z_index(1, |cx| {
|
if handled {
|
||||||
for (relative_highlighted_range, color) in layout.relative_highlighted_ranges.iter()
|
cx.refresh();
|
||||||
{
|
}
|
||||||
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() {
|
for rect in &layout.rects {
|
||||||
element.draw(origin, bounds.size.map(AvailableSpace::Definite), cx)
|
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)
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue