Fix show_scrollbars

This commit is contained in:
Alexandre Bury 2019-09-19 22:45:54 -07:00
parent 86c800554b
commit cfcdfa7e9e

View File

@ -101,56 +101,60 @@ impl Core {
printer: &Printer<'a, 'b>, printer: &Printer<'a, 'b>,
) -> Printer<'a, 'b> { ) -> Printer<'a, 'b> {
// Draw scrollbar? // Draw scrollbar?
let scrolling = self.is_scrolling();
let lengths = self.scrollbar_thumb_lengths();
let offsets = self.scrollbar_thumb_offsets(lengths);
let line_c = XY::new("-", "|");
let color = if printer.focused {
ColorStyle::highlight()
} else {
ColorStyle::highlight_inactive()
};
let size = self.available_size(); let size = self.available_size();
// Draw the scrollbars // Draw the scrollbars
XY::zip5(lengths, offsets, size, line_c, Orientation::pair()).run_if( if self.get_show_scrollbars() {
scrolling, let scrolling = self.is_scrolling();
|(length, offset, size, c, orientation)| {
let start = printer
.size
.saturating_sub((1, 1))
.with_axis(orientation, 0);
let offset = orientation.make_vec(offset, 0);
printer.print_line(orientation, start, size, c); let lengths = self.scrollbar_thumb_lengths();
let offsets = self.scrollbar_thumb_offsets(lengths);
let thumb_c = if self let line_c = XY::new("-", "|");
.thumb_grab
.map(|(o, _)| o == orientation)
.unwrap_or(false)
{
" "
} else {
""
};
printer.with_color(color, |printer| {
printer.print_line(
orientation,
start + offset,
length,
thumb_c,
);
});
},
);
// Draw the X between the two scrollbars. let color = if printer.focused {
if scrolling.both() { ColorStyle::highlight()
printer.print(printer.size.saturating_sub((1, 1)), ""); } else {
ColorStyle::highlight_inactive()
};
XY::zip5(lengths, offsets, size, line_c, Orientation::pair())
.run_if(
scrolling,
|(length, offset, size, c, orientation)| {
let start = printer
.size
.saturating_sub((1, 1))
.with_axis(orientation, 0);
let offset = orientation.make_vec(offset, 0);
printer.print_line(orientation, start, size, c);
let thumb_c = if self
.thumb_grab
.map(|(o, _)| o == orientation)
.unwrap_or(false)
{
" "
} else {
""
};
printer.with_color(color, |printer| {
printer.print_line(
orientation,
start + offset,
length,
thumb_c,
);
});
},
);
// Draw the X between the two scrollbars.
if scrolling.both() {
printer.print(printer.size.saturating_sub((1, 1)), "");
}
} }
// Draw content // Draw content