Terminal implements important half of search protocol
This commit is contained in:
parent
63d9d29762
commit
3f11fd3b8b
8 changed files with 249 additions and 119 deletions
|
@ -570,19 +570,25 @@ impl Element for TerminalElement {
|
|||
TerminalSize::new(line_height, cell_width, constraint.max)
|
||||
};
|
||||
|
||||
let search_matches = if let Some(terminal_model) = self.terminal.upgrade(cx) {
|
||||
terminal_model.read(cx).matches.clone()
|
||||
} else {
|
||||
Default::default()
|
||||
};
|
||||
|
||||
let background_color = if self.modal {
|
||||
terminal_theme.colors.modal_background
|
||||
} else {
|
||||
terminal_theme.colors.background
|
||||
};
|
||||
|
||||
let (cells, selection, cursor, display_offset, cursor_text, search_matches, mode) = self
|
||||
let (cells, selection, cursor, display_offset, cursor_text, mode) = self
|
||||
.terminal
|
||||
.upgrade(cx)
|
||||
.unwrap()
|
||||
.update(cx.app, |terminal, cx| {
|
||||
terminal.set_size(dimensions);
|
||||
terminal.render_lock(cx, |content, cursor_text, search_matches| {
|
||||
terminal.render_lock(cx, |content, cursor_text| {
|
||||
let mut cells = vec![];
|
||||
cells.extend(
|
||||
content
|
||||
|
@ -605,7 +611,6 @@ impl Element for TerminalElement {
|
|||
content.cursor,
|
||||
content.display_offset,
|
||||
cursor_text,
|
||||
search_matches.clone(),
|
||||
content.mode,
|
||||
)
|
||||
})
|
||||
|
@ -613,12 +618,12 @@ impl Element for TerminalElement {
|
|||
|
||||
// searches, highlights to a single range representations
|
||||
let mut relative_highlighted_ranges = Vec::new();
|
||||
if let Some(selection) = selection {
|
||||
relative_highlighted_ranges.push((selection.start..=selection.end, selection_color));
|
||||
}
|
||||
for search_match in search_matches {
|
||||
relative_highlighted_ranges.push((search_match, match_color))
|
||||
}
|
||||
if let Some(selection) = selection {
|
||||
relative_highlighted_ranges.push((selection.start..=selection.end, selection_color));
|
||||
}
|
||||
|
||||
// then have that representation be converted to the appropriate highlight data structure
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue