mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-10 03:10:41 +00:00
Select views now highlight the entire line
And scrollviews have an extra padding column between the content and the scrollbar.
This commit is contained in:
parent
405cd1e961
commit
2a423b8408
@ -95,10 +95,11 @@ impl ScrollBase {
|
||||
{
|
||||
// Print the content in a sub_printer
|
||||
let max_y = min(self.view_height, self.content_height - self.start_line);
|
||||
let w = if self.scrollable() { printer.size.x - 2 } else { printer.size.x };
|
||||
for y in 0..max_y {
|
||||
// Y is the actual coordinate of the line.
|
||||
// The item ID is then Y + self.start_line
|
||||
line_drawer(&printer.sub_printer(Vec2::new(0,y),printer.size,true), y+self.start_line);
|
||||
line_drawer(&printer.sub_printer(Vec2::new(0,y),Vec2::new(w,1),true), y+self.start_line);
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,7 +99,11 @@ impl <T: 'static> View for SelectView<T> {
|
||||
} else {
|
||||
color::PRIMARY
|
||||
};
|
||||
printer.with_color(style, |printer| printer.print((0,0), &self.items[i].label));
|
||||
printer.with_color(style, |printer| {
|
||||
printer.print((0,0), &self.items[i].label);
|
||||
let x:usize = self.items[i].label.chars().count();
|
||||
printer.print_hline((x,0), printer.size.x-x, ' ' as u64);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@ -115,7 +119,8 @@ impl <T: 'static> View for SelectView<T> {
|
||||
false
|
||||
};
|
||||
|
||||
let w = if scrolling { w + 1 } else { w };
|
||||
// Add 2 spaces for the scrollbar if we need
|
||||
let w = if scrolling { w + 2 } else { w };
|
||||
|
||||
Vec2::new(w,h)
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ impl View for TextView {
|
||||
// Compute the text rows.
|
||||
self.rows = LinesIterator::new(&self.content, size.x).collect();
|
||||
if self.rows.len() > size.y {
|
||||
self.rows = LinesIterator::new(&self.content, size.x - 1).collect();
|
||||
self.rows = LinesIterator::new(&self.content, size.x - 2).collect();
|
||||
}
|
||||
self.scrollbase.set_heights(size.y, self.rows.len());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user