Show selection
This commit is contained in:
parent
6cad69b414
commit
c2fb3573d5
2 changed files with 19 additions and 4 deletions
|
|
@ -271,8 +271,8 @@ impl Terminal {
|
|||
let mut text = String::new();
|
||||
let mut attrs_list = AttrsList::new(self.default_attrs);
|
||||
{
|
||||
let term_guard = self.term.lock();
|
||||
let grid = term_guard.grid();
|
||||
let term = self.term.lock();
|
||||
let grid = term.grid();
|
||||
for indexed in grid.display_iter() {
|
||||
if indexed.point.line != last_point.unwrap_or(indexed.point).line {
|
||||
while line_i >= buffer.lines.len() {
|
||||
|
|
@ -312,10 +312,23 @@ impl Terminal {
|
|||
let mut attrs = self.default_attrs;
|
||||
let mut fg = convert_color(&self.colors, indexed.cell.fg);
|
||||
let mut bg = convert_color(&self.colors, indexed.cell.bg);
|
||||
//TODO: better handling of cursor
|
||||
|
||||
// Change color if cursor
|
||||
if indexed.point == grid.cursor.point {
|
||||
//TODO: better handling of cursor
|
||||
mem::swap(&mut fg, &mut bg);
|
||||
}
|
||||
|
||||
// Change color if selected
|
||||
if let Some(selection) = &term.selection {
|
||||
if let Some(range) = selection.to_range(&term) {
|
||||
if range.contains(indexed.point) {
|
||||
//TODO: better handling of selection
|
||||
mem::swap(&mut fg, &mut bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
attrs = attrs.color(fg);
|
||||
// Use metadata as background color
|
||||
attrs = attrs.metadata(bg.0 as usize);
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ where
|
|||
) -> Status {
|
||||
let state = tree.state.downcast_mut::<State>();
|
||||
let scrollbar_rect = state.scrollbar_rect.get();
|
||||
let terminal = self.terminal.lock().unwrap();
|
||||
let mut terminal = self.terminal.lock().unwrap();
|
||||
let buffer_size = terminal.with_buffer(|buffer| buffer.size());
|
||||
|
||||
let mut status = Status::Ignored;
|
||||
|
|
@ -483,6 +483,7 @@ where
|
|||
let mut term = terminal.term.lock();
|
||||
term.selection = Some(selection);
|
||||
}
|
||||
terminal.update();
|
||||
state.click = Some((click_kind, Instant::now()));
|
||||
state.dragging = Some(Dragging::Buffer);
|
||||
} else if scrollbar_rect.contains(Point::new(x, y)) {
|
||||
|
|
@ -549,6 +550,7 @@ where
|
|||
selection.update(location, side);
|
||||
}
|
||||
}
|
||||
terminal.update();
|
||||
}
|
||||
Dragging::Scrollbar {
|
||||
start_y,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue