|
|
@ -294,16 +294,27 @@ impl EditorView {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
let selection_style = theme.get("ui.selection");
|
|
|
|
let selection_style = theme.get("ui.selection");
|
|
|
|
|
|
|
|
let primary_style = theme
|
|
|
|
|
|
|
|
.try_get("ui.selection.primary")
|
|
|
|
|
|
|
|
.unwrap_or(selection_style);
|
|
|
|
|
|
|
|
let selection = doc.selection(view.id);
|
|
|
|
|
|
|
|
let primary_idx = selection.primary_index();
|
|
|
|
|
|
|
|
|
|
|
|
for selection in doc
|
|
|
|
for (i, selection) in selection
|
|
|
|
.selection(view.id)
|
|
|
|
|
|
|
|
.iter()
|
|
|
|
.iter()
|
|
|
|
.filter(|range| range.overlaps(&screen))
|
|
|
|
.enumerate()
|
|
|
|
|
|
|
|
.filter(|(_, range)| range.overlaps(&screen))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO: render also if only one of the ranges is in viewport
|
|
|
|
// TODO: render also if only one of the ranges is in viewport
|
|
|
|
let mut start = view.screen_coords_at_pos(doc, text, selection.anchor);
|
|
|
|
let mut start = view.screen_coords_at_pos(doc, text, selection.anchor);
|
|
|
|
let mut end = view.screen_coords_at_pos(doc, text, selection.head);
|
|
|
|
let mut end = view.screen_coords_at_pos(doc, text, selection.head);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let style = if i != primary_idx {
|
|
|
|
|
|
|
|
selection_style
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
primary_style
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let head = end;
|
|
|
|
let head = end;
|
|
|
|
|
|
|
|
|
|
|
|
if selection.head < selection.anchor {
|
|
|
|
if selection.head < selection.anchor {
|
|
|
@ -331,7 +342,7 @@ impl EditorView {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
selection_style,
|
|
|
|
style,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
surface.set_style(
|
|
|
|
surface.set_style(
|
|
|
@ -342,7 +353,7 @@ impl EditorView {
|
|
|
|
viewport.width.saturating_sub(start.col as u16),
|
|
|
|
viewport.width.saturating_sub(start.col as u16),
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
selection_style,
|
|
|
|
style,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
for i in start.row + 1..end.row {
|
|
|
|
for i in start.row + 1..end.row {
|
|
|
|
surface.set_style(
|
|
|
|
surface.set_style(
|
|
|
@ -353,7 +364,7 @@ impl EditorView {
|
|
|
|
viewport.width,
|
|
|
|
viewport.width,
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
selection_style,
|
|
|
|
style,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
surface.set_style(
|
|
|
|
surface.set_style(
|
|
|
@ -363,7 +374,7 @@ impl EditorView {
|
|
|
|
(end.col as u16).min(viewport.width),
|
|
|
|
(end.col as u16).min(viewport.width),
|
|
|
|
1,
|
|
|
|
1,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
selection_style,
|
|
|
|
style,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|