Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions cursive-core/src/view/scroll/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::direction::Orientation;
use crate::event::{AnyCb, Event, EventResult, Key, MouseButton, MouseEvent};
use crate::printer::Printer;
use crate::rect::Rect;
use crate::theme::ColorStyle;
use crate::theme::{ColorStyle, PaletteColor};
use crate::view::{ScrollStrategy, Selector, SizeCache};
use crate::with::With;
use crate::Vec2;
Expand Down Expand Up @@ -141,35 +141,25 @@ impl Core {
let lengths = self.scrollbar_thumb_lengths();
let offsets = self.scrollbar_thumb_offsets(lengths);

let line_c = XY::new("-", "|");
let line_c = XY::new(("_", "▄"), ("|", "█"));

let color = if printer.focused {
ColorStyle::highlight()
ColorStyle::new(PaletteColor::Highlight, PaletteColor::View)
} else {
ColorStyle::highlight_inactive()
ColorStyle::new(PaletteColor::HighlightInactive, PaletteColor::View)
};

XY::zip5(lengths, offsets, size, line_c, Orientation::pair())
.run_if(
scrolling,
|(length, offset, size, c, orientation)| {
|(length, offset, size, (c, thumb_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,
Expand All @@ -183,7 +173,9 @@ impl Core {

// Draw the X between the two scrollbars.
if scrolling.both() {
printer.print(printer.size.saturating_sub((1, 1)), "╳");
printer.with_color(color, |printer| {
printer.print(printer.size.saturating_sub((2, 1)), "▄█");
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion cursive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ atty = "0.2"

[features]
blt-backend = ["bear-lib-terminal"]
default = ["ncurses-backend"]
default = ["pancurses-backend"]
ncurses-backend = ["ncurses", "maplit", "term_size"]
pancurses-backend = ["pancurses", "maplit", "term_size"]
termion-backend = ["termion"]
Expand Down
2 changes: 1 addition & 1 deletion cursive/src/backends/curses/pan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl Backend {

let make_event = |event| Event::Mouse {
offset: Vec2::zero(),
position: Vec2::new(mevent.x as usize, mevent.y as usize),
position: Vec2::new(mevent.x.max(0) as usize, mevent.y.max(0) as usize),
event,
};

Expand Down