Update dependencies

This commit is contained in:
Alexandre Bury 2021-01-08 11:56:22 -08:00
parent c352e4c54a
commit 71a600cb9b
17 changed files with 67 additions and 78 deletions

View File

@ -25,14 +25,15 @@ enum-map = "0.6"
enumset = "1" enumset = "1"
log = "0.4" log = "0.4"
owning_ref = "0.4" owning_ref = "0.4"
syn = "=1.0.57" # Pin syn to 1.0.57 since enumset currently incompatible with 1.0.58
unicode-segmentation = "1" unicode-segmentation = "1"
unicode-width = "0.1" unicode-width = "0.1"
xi-unicode = "0.2" xi-unicode = "0.3"
libc = "0.2" libc = "0.2"
crossbeam-channel = "0.4" crossbeam-channel = "0.5"
lazy_static = "1" lazy_static = "1"
chrono = "0.4" chrono = "0.4"
ahash = "0.4" ahash = "0.6"
[dependencies.toml] [dependencies.toml]
optional = true optional = true
@ -45,15 +46,7 @@ version = "0.3"
[dependencies.pulldown-cmark] [dependencies.pulldown-cmark]
default-features = false default-features = false
optional = true optional = true
version = "0.7" version = "0.8"
[target.'cfg(unix)'.dependencies]
signal-hook = "0.1"
[dev-dependencies]
rand = "0.7"
pretty-bytes = "0.2"
atty = "0.2"
[features] [features]
markdown = ["pulldown-cmark"] markdown = ["pulldown-cmark"]

View File

@ -196,7 +196,7 @@ fn parse_special(value: &str) -> Option<Color> {
value.chars().map(|c| c as i16 - '0' as i16).collect(); value.chars().map(|c| c as i16 - '0' as i16).collect();
assert_eq!(rgb.len(), 3); assert_eq!(rgb.len(), 3);
if rgb.iter().all(|&i| i >= 0 && i < 6) { if rgb.iter().all(|i| (0..6).contains(i)) {
Some(Color::RgbLowRes(rgb[0] as u8, rgb[1] as u8, rgb[2] as u8)) Some(Color::RgbLowRes(rgb[0] as u8, rgb[1] as u8, rgb[2] as u8))
} else { } else {
None None

View File

@ -9,6 +9,18 @@ use std::str::FromStr;
// Use AHash instead of the slower SipHash // Use AHash instead of the slower SipHash
type HashMap<K, V> = std::collections::HashMap<K, V, ahash::RandomState>; type HashMap<K, V> = std::collections::HashMap<K, V, ahash::RandomState>;
/// Error
#[derive(Debug)]
pub struct NoSuchColor;
impl std::fmt::Display for NoSuchColor {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Could not parse the given color")
}
}
impl std::error::Error for NoSuchColor {}
/// Color configuration for the application. /// Color configuration for the application.
/// ///
/// Assign each color role an actual color. /// Assign each color role an actual color.
@ -126,7 +138,7 @@ impl Palette {
&mut self, &mut self,
key: &str, key: &str,
color: Color, color: Color,
) -> Result<(), ()> { ) -> Result<(), NoSuchColor> {
PaletteColor::from_str(key).map(|c| self.basic[c] = color) PaletteColor::from_str(key).map(|c| self.basic[c] = color)
} }
@ -192,9 +204,9 @@ impl Default for Palette {
// Iterate over a toml // Iterate over a toml
#[cfg(feature = "toml")] #[cfg(feature = "toml")]
fn iterate_toml<'a>( fn iterate_toml(
table: &'a toml::value::Table, table: &toml::value::Table,
) -> impl Iterator<Item = (&'a str, PaletteNode)> + 'a { ) -> impl Iterator<Item = (&str, PaletteNode)> {
table.iter().flat_map(|(key, value)| { table.iter().flat_map(|(key, value)| {
let node = match value { let node = match value {
toml::Value::Table(table) => { toml::Value::Table(table) => {
@ -285,9 +297,9 @@ impl PaletteColor {
} }
impl FromStr for PaletteColor { impl FromStr for PaletteColor {
type Err = (); type Err = NoSuchColor;
fn from_str(s: &str) -> Result<Self, ()> { fn from_str(s: &str) -> Result<Self, NoSuchColor> {
use PaletteColor::*; use PaletteColor::*;
Ok(match s { Ok(match s {
@ -302,7 +314,7 @@ impl FromStr for PaletteColor {
"Highlight" | "highlight" => Highlight, "Highlight" | "highlight" => Highlight,
"HighlightInactive" | "highlight_inactive" => HighlightInactive, "HighlightInactive" | "highlight_inactive" => HighlightInactive,
"HighlightText" | "highlight_text" => HighlightText, "HighlightText" | "highlight_text" => HighlightText,
_ => return Err(()), _ => return Err(NoSuchColor),
}) })
} }
} }

View File

@ -1,4 +1,4 @@
use crate::view::{View, ViewPath, ViewWrapper}; use crate::view::{View, ViewWrapper};
use crate::views::{NamedView, ViewRef}; use crate::views::{NamedView, ViewRef};
/// Provides `call_on<V: View>` to views. /// Provides `call_on<V: View>` to views.
@ -94,6 +94,7 @@ impl<T: View> Finder for T {
} }
/// Selects a single view (if any) in the tree. /// Selects a single view (if any) in the tree.
#[non_exhaustive]
pub enum Selector<'a> { pub enum Selector<'a> {
/// Same as [`Selector::Name`]. /// Same as [`Selector::Name`].
#[deprecated( #[deprecated(
@ -103,7 +104,4 @@ pub enum Selector<'a> {
/// Selects a view from its name. /// Selects a view from its name.
Name(&'a str), Name(&'a str),
/// Selects a view from its path.
Path(&'a ViewPath),
} }

View File

@ -3,20 +3,20 @@ use crate::view::View;
/// Represents a type that can be made into a `Box<View>`. /// Represents a type that can be made into a `Box<View>`.
pub trait IntoBoxedView { pub trait IntoBoxedView {
/// Returns a `Box<View>`. /// Returns a `Box<View>`.
fn as_boxed_view(self) -> Box<dyn View>; fn into_boxed_view(self) -> Box<dyn View>;
} }
impl<T> IntoBoxedView for T impl<T> IntoBoxedView for T
where where
T: View, T: View,
{ {
fn as_boxed_view(self) -> Box<dyn View> { fn into_boxed_view(self) -> Box<dyn View> {
Box::new(self) Box::new(self)
} }
} }
impl IntoBoxedView for Box<dyn View> { impl IntoBoxedView for Box<dyn View> {
fn as_boxed_view(self) -> Box<dyn View> { fn into_boxed_view(self) -> Box<dyn View> {
self self
} }
} }

View File

@ -89,7 +89,6 @@ mod margins;
mod position; mod position;
mod size_cache; mod size_cache;
mod size_constraint; mod size_constraint;
mod view_path;
mod view_trait; mod view_trait;
// Helper bases // Helper bases
@ -116,7 +115,6 @@ pub use self::scroll_base::ScrollBase;
pub use self::scrollable::Scrollable; pub use self::scrollable::Scrollable;
pub use self::size_cache::SizeCache; pub use self::size_cache::SizeCache;
pub use self::size_constraint::SizeConstraint; pub use self::size_constraint::SizeConstraint;
pub use self::view_path::ViewPath;
pub use self::view_trait::{View, ViewNotFound}; pub use self::view_trait::{View, ViewNotFound};
pub use self::view_wrapper::ViewWrapper; pub use self::view_wrapper::ViewWrapper;

View File

@ -19,7 +19,7 @@ impl BoxedView {
where where
T: IntoBoxedView, T: IntoBoxedView,
{ {
BoxedView::new(view.as_boxed_view()) BoxedView::new(view.into_boxed_view())
} }
/// Returns the inner boxed view. /// Returns the inner boxed view.

View File

@ -58,7 +58,7 @@ impl FixedLayout {
/// Adds a child. /// Adds a child.
pub fn add_child<V: IntoBoxedView>(&mut self, position: Rect, view: V) { pub fn add_child<V: IntoBoxedView>(&mut self, position: Rect, view: V) {
self.children.push(Child { self.children.push(Child {
view: view.as_boxed_view(), view: view.into_boxed_view(),
position, position,
}); });
} }

View File

@ -172,7 +172,7 @@ impl LinearLayout {
/// Adds a child to the layout. /// Adds a child to the layout.
pub fn add_child<V: IntoBoxedView + 'static>(&mut self, view: V) { pub fn add_child<V: IntoBoxedView + 'static>(&mut self, view: V) {
self.children.push(Child { self.children.push(Child {
view: view.as_boxed_view(), view: view.into_boxed_view(),
required_size: Vec2::zero(), required_size: Vec2::zero(),
last_size: Vec2::zero(), last_size: Vec2::zero(),
weight: 0, weight: 0,
@ -193,7 +193,7 @@ impl LinearLayout {
self.children.insert( self.children.insert(
i, i,
Child { Child {
view: view.as_boxed_view(), view: view.into_boxed_view(),
required_size: Vec2::zero(), required_size: Vec2::zero(),
last_size: Vec2::zero(), last_size: Vec2::zero(),
weight: 0, weight: 0,

View File

@ -94,7 +94,7 @@ impl ListView {
label: &str, label: &str,
view: V, view: V,
) { ) {
let mut view = view.as_boxed_view(); let mut view = view.into_boxed_view();
view.take_focus(direction::Direction::none()); view.take_focus(direction::Direction::none());
self.children.push(ListChild::Row(label.to_string(), view)); self.children.push(ListChild::Row(label.to_string(), view));
self.children_heights.push(0); self.children_heights.push(0);

View File

@ -16,8 +16,8 @@ features = ["unstable_scroll", "markdown", "toml"]
[dependencies] [dependencies]
cursive_core = { path = "../cursive-core", version="0.1.1-alpha.0" } cursive_core = { path = "../cursive-core", version="0.1.1-alpha.0" }
crossbeam-channel = "0.4" crossbeam-channel = "0.5"
cfg-if = "0.1" cfg-if = "1"
enumset = "1" enumset = "1"
unicode-segmentation = "1" unicode-segmentation = "1"
unicode-width = "0.1" unicode-width = "0.1"
@ -26,7 +26,7 @@ libc = "0.2"
term_size = { version = "0.3", optional = true } term_size = { version = "0.3", optional = true }
maplit = { version = "1.0", optional = true } maplit = { version = "1.0", optional = true }
log = "0.4" log = "0.4"
ahash = "0.4" ahash = "0.6"
[dependencies.bear-lib-terminal] [dependencies.bear-lib-terminal]
optional = true optional = true
@ -48,12 +48,7 @@ version = "1"
[dependencies.crossterm] [dependencies.crossterm]
optional = true optional = true
version = "0.17" version = "0.19"
[dev-dependencies]
rand = "0.7"
pretty-bytes = "0.2"
atty = "0.2"
[features] [features]
blt-backend = ["bear-lib-terminal"] blt-backend = ["bear-lib-terminal"]
@ -70,4 +65,4 @@ toml = ["cursive_core/toml"]
name = "cursive" name = "cursive"
[target.'cfg(unix)'.dependencies] [target.'cfg(unix)'.dependencies]
signal-hook = "0.1" signal-hook = "0.3"

View File

@ -372,11 +372,9 @@ fn colour_to_blt_colour(clr: Color, role: ColorRole) -> BltColor {
} }
fn blt_keycode_to_char(kc: KeyCode, shift: bool) -> char { fn blt_keycode_to_char(kc: KeyCode, shift: bool) -> char {
let bltchar = bear_lib_terminal::terminal::state::char(); match bear_lib_terminal::terminal::state::char() {
if bltchar == '\u{0}' { '\u{0}' => blt_keycode_to_char_impl(kc, shift),
return blt_keycode_to_char_impl(kc, shift); c => c,
} else {
return bltchar;
} }
} }

View File

@ -17,6 +17,7 @@ use crossterm::{
poll, read, DisableMouseCapture, EnableMouseCapture, Event as CEvent, poll, read, DisableMouseCapture, EnableMouseCapture, Event as CEvent,
KeyCode, KeyEvent as CKeyEvent, KeyModifiers, KeyCode, KeyEvent as CKeyEvent, KeyModifiers,
MouseButton as CMouseButton, MouseEvent as CMouseEvent, MouseButton as CMouseButton, MouseEvent as CMouseEvent,
MouseEventKind,
}, },
execute, queue, execute, queue,
style::{ style::{
@ -232,34 +233,28 @@ impl Backend {
fn map_key(&mut self, event: CEvent) -> Event { fn map_key(&mut self, event: CEvent) -> Event {
match event { match event {
CEvent::Key(key_event) => translate_event(key_event), CEvent::Key(key_event) => translate_event(key_event),
CEvent::Mouse(mouse_event) => { CEvent::Mouse(CMouseEvent {
let position; kind,
let event; column,
row,
match mouse_event { modifiers: _,
CMouseEvent::Down(button, x, y, _) => { }) => {
let button = translate_button(button); let position = (column, row).into();
event = MouseEvent::Press(button); let event = match kind {
position = (x, y).into(); MouseEventKind::Down(button) => {
MouseEvent::Press(translate_button(button))
} }
CMouseEvent::Up(button, x, y, _) => { MouseEventKind::Up(button) => {
let button = translate_button(button); MouseEvent::Release(translate_button(button))
event = MouseEvent::Release(button);
position = (x, y).into();
} }
CMouseEvent::Drag(button, x, y, _) => { MouseEventKind::Drag(button) => {
let button = translate_button(button); MouseEvent::Hold(translate_button(button))
event = MouseEvent::Hold(button);
position = (x, y).into();
} }
CMouseEvent::ScrollDown(x, y, _) => { MouseEventKind::Moved => {
event = MouseEvent::WheelDown; unreachable!("Not tracking mouse move.");
position = (x, y).into();
}
CMouseEvent::ScrollUp(x, y, _) => {
event = MouseEvent::WheelUp;
position = (x, y).into();
} }
MouseEventKind::ScrollDown => MouseEvent::WheelDown,
MouseEventKind::ScrollUp => MouseEvent::WheelUp,
}; };
Event::Mouse { Event::Mouse {

View File

@ -11,7 +11,7 @@ pub fn start_resize_thread(
resize_sender: Sender<()>, resize_sender: Sender<()>,
resize_running: Arc<AtomicBool>, resize_running: Arc<AtomicBool>,
) { ) {
let signals = Signals::new(&[libc::SIGWINCH]).unwrap(); let mut signals = Signals::new(&[libc::SIGWINCH]).unwrap();
thread::spawn(move || { thread::spawn(move || {
// This thread will listen to SIGWINCH events and report them. // This thread will listen to SIGWINCH events and report them.
while resize_running.load(Ordering::Relaxed) { while resize_running.load(Ordering::Relaxed) {

View File

@ -14,9 +14,9 @@ version = "0.1.1-alpha.0"
atty = "0.2.14" atty = "0.2.14"
log = "0.4.8" log = "0.4.8"
pretty-bytes = "0.2.2" pretty-bytes = "0.2.2"
rand = "0.7.3" rand = "0.8"
cursive = { path = "../cursive", default-features=false } cursive = { path = "../cursive", default-features=false }
crossbeam-channel = "0.4.2" crossbeam-channel = "0.5"
lazy_static = "1.4" lazy_static = "1.4"
[features] [features]

View File

@ -39,7 +39,7 @@ impl Board {
for _ in 0..options.mines { for _ in 0..options.mines {
// Find a free cell to put a bomb // Find a free cell to put a bomb
let i = loop { let i = loop {
let i = thread_rng().gen_range(0, n_cells); let i = thread_rng().gen_range(0..n_cells);
if let Cell::Bomb = board.cells[i] { if let Cell::Bomb = board.cells[i] {
continue; continue;

View File

@ -74,7 +74,7 @@ fn phase_2(s: &mut Cursive) {
let counters: Vec<_> = (0..n_bars).map(|_| Counter::new(0)).collect(); let counters: Vec<_> = (0..n_bars).map(|_| Counter::new(0)).collect();
// To make things more interesting, we'll give a random speed to each bar // To make things more interesting, we'll give a random speed to each bar
let speeds: Vec<_> = (0..n_bars) let speeds: Vec<_> = (0..n_bars)
.map(|_| rand::thread_rng().gen_range(50, 150)) .map(|_| rand::thread_rng().gen_range(50..150))
.collect(); .collect();
let n_max = 100_000; let n_max = 100_000;