From 0dc079233abf01a8d44c78ecc2dec6f9498a8719 Mon Sep 17 00:00:00 2001 From: Alexandre Bury Date: Mon, 25 May 2015 22:38:11 -0700 Subject: [PATCH] Unfocused view draw an inactive scrollbar --- src/view/text_view.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/view/text_view.rs b/src/view/text_view.rs index 67b6c02..efb8d8b 100644 --- a/src/view/text_view.rs +++ b/src/view/text_view.rs @@ -175,7 +175,7 @@ impl <'a> Iterator for LinesIterator<'a> { } impl View for TextView { - fn draw(&mut self, printer: &Printer, _: bool) { + fn draw(&mut self, printer: &Printer, focused: bool) { // We don't have a focused view for (i,line) in self.rows.iter().skip(self.start_line).map(|row| &self.content[row.start..row.end]).enumerate() { printer.print((0,i), line); @@ -186,9 +186,11 @@ impl View for TextView { // Where ratio is ({start or end} / content.height) let start = self.view_height * self.start_line / self.rows.len(); let end = self.view_height * (self.start_line + self.view_height) / self.rows.len(); - printer.with_style(color::HIGHLIGHT, |printer| { - printer.print_vline((printer.size.x-1, start), end-start, ' ' as u64); - }); + printer.with_style( + if focused { color::HIGHLIGHT } else { color::HIGHLIGHT_INACTIVE }, + |printer| { + printer.print_vline((printer.size.x-1, start), end-start, ' ' as u64); + }); } }