mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-09 10:50:40 +00:00
Update dependencies
This commit is contained in:
parent
c352e4c54a
commit
71a600cb9b
@ -25,14 +25,15 @@ enum-map = "0.6"
|
||||
enumset = "1"
|
||||
log = "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-width = "0.1"
|
||||
xi-unicode = "0.2"
|
||||
xi-unicode = "0.3"
|
||||
libc = "0.2"
|
||||
crossbeam-channel = "0.4"
|
||||
crossbeam-channel = "0.5"
|
||||
lazy_static = "1"
|
||||
chrono = "0.4"
|
||||
ahash = "0.4"
|
||||
ahash = "0.6"
|
||||
|
||||
[dependencies.toml]
|
||||
optional = true
|
||||
@ -45,15 +46,7 @@ version = "0.3"
|
||||
[dependencies.pulldown-cmark]
|
||||
default-features = false
|
||||
optional = true
|
||||
version = "0.7"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
signal-hook = "0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.7"
|
||||
pretty-bytes = "0.2"
|
||||
atty = "0.2"
|
||||
version = "0.8"
|
||||
|
||||
[features]
|
||||
markdown = ["pulldown-cmark"]
|
||||
|
@ -196,7 +196,7 @@ fn parse_special(value: &str) -> Option<Color> {
|
||||
value.chars().map(|c| c as i16 - '0' as i16).collect();
|
||||
|
||||
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))
|
||||
} else {
|
||||
None
|
||||
|
@ -9,6 +9,18 @@ use std::str::FromStr;
|
||||
// Use AHash instead of the slower SipHash
|
||||
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.
|
||||
///
|
||||
/// Assign each color role an actual color.
|
||||
@ -126,7 +138,7 @@ impl Palette {
|
||||
&mut self,
|
||||
key: &str,
|
||||
color: Color,
|
||||
) -> Result<(), ()> {
|
||||
) -> Result<(), NoSuchColor> {
|
||||
PaletteColor::from_str(key).map(|c| self.basic[c] = color)
|
||||
}
|
||||
|
||||
@ -192,9 +204,9 @@ impl Default for Palette {
|
||||
|
||||
// Iterate over a toml
|
||||
#[cfg(feature = "toml")]
|
||||
fn iterate_toml<'a>(
|
||||
table: &'a toml::value::Table,
|
||||
) -> impl Iterator<Item = (&'a str, PaletteNode)> + 'a {
|
||||
fn iterate_toml(
|
||||
table: &toml::value::Table,
|
||||
) -> impl Iterator<Item = (&str, PaletteNode)> {
|
||||
table.iter().flat_map(|(key, value)| {
|
||||
let node = match value {
|
||||
toml::Value::Table(table) => {
|
||||
@ -285,9 +297,9 @@ impl 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::*;
|
||||
|
||||
Ok(match s {
|
||||
@ -302,7 +314,7 @@ impl FromStr for PaletteColor {
|
||||
"Highlight" | "highlight" => Highlight,
|
||||
"HighlightInactive" | "highlight_inactive" => HighlightInactive,
|
||||
"HighlightText" | "highlight_text" => HighlightText,
|
||||
_ => return Err(()),
|
||||
_ => return Err(NoSuchColor),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::view::{View, ViewPath, ViewWrapper};
|
||||
use crate::view::{View, ViewWrapper};
|
||||
use crate::views::{NamedView, ViewRef};
|
||||
|
||||
/// 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.
|
||||
#[non_exhaustive]
|
||||
pub enum Selector<'a> {
|
||||
/// Same as [`Selector::Name`].
|
||||
#[deprecated(
|
||||
@ -103,7 +104,4 @@ pub enum Selector<'a> {
|
||||
|
||||
/// Selects a view from its name.
|
||||
Name(&'a str),
|
||||
|
||||
/// Selects a view from its path.
|
||||
Path(&'a ViewPath),
|
||||
}
|
||||
|
@ -3,20 +3,20 @@ use crate::view::View;
|
||||
/// Represents a type that can be made into a `Box<View>`.
|
||||
pub trait IntoBoxedView {
|
||||
/// 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
|
||||
where
|
||||
T: View,
|
||||
{
|
||||
fn as_boxed_view(self) -> Box<dyn View> {
|
||||
fn into_boxed_view(self) -> Box<dyn View> {
|
||||
Box::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoBoxedView for Box<dyn View> {
|
||||
fn as_boxed_view(self) -> Box<dyn View> {
|
||||
fn into_boxed_view(self) -> Box<dyn View> {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,6 @@ mod margins;
|
||||
mod position;
|
||||
mod size_cache;
|
||||
mod size_constraint;
|
||||
mod view_path;
|
||||
mod view_trait;
|
||||
|
||||
// Helper bases
|
||||
@ -116,7 +115,6 @@ pub use self::scroll_base::ScrollBase;
|
||||
pub use self::scrollable::Scrollable;
|
||||
pub use self::size_cache::SizeCache;
|
||||
pub use self::size_constraint::SizeConstraint;
|
||||
pub use self::view_path::ViewPath;
|
||||
pub use self::view_trait::{View, ViewNotFound};
|
||||
pub use self::view_wrapper::ViewWrapper;
|
||||
|
||||
|
@ -19,7 +19,7 @@ impl BoxedView {
|
||||
where
|
||||
T: IntoBoxedView,
|
||||
{
|
||||
BoxedView::new(view.as_boxed_view())
|
||||
BoxedView::new(view.into_boxed_view())
|
||||
}
|
||||
|
||||
/// Returns the inner boxed view.
|
||||
|
@ -58,7 +58,7 @@ impl FixedLayout {
|
||||
/// Adds a child.
|
||||
pub fn add_child<V: IntoBoxedView>(&mut self, position: Rect, view: V) {
|
||||
self.children.push(Child {
|
||||
view: view.as_boxed_view(),
|
||||
view: view.into_boxed_view(),
|
||||
position,
|
||||
});
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ impl LinearLayout {
|
||||
/// Adds a child to the layout.
|
||||
pub fn add_child<V: IntoBoxedView + 'static>(&mut self, view: V) {
|
||||
self.children.push(Child {
|
||||
view: view.as_boxed_view(),
|
||||
view: view.into_boxed_view(),
|
||||
required_size: Vec2::zero(),
|
||||
last_size: Vec2::zero(),
|
||||
weight: 0,
|
||||
@ -193,7 +193,7 @@ impl LinearLayout {
|
||||
self.children.insert(
|
||||
i,
|
||||
Child {
|
||||
view: view.as_boxed_view(),
|
||||
view: view.into_boxed_view(),
|
||||
required_size: Vec2::zero(),
|
||||
last_size: Vec2::zero(),
|
||||
weight: 0,
|
||||
|
@ -94,7 +94,7 @@ impl ListView {
|
||||
label: &str,
|
||||
view: V,
|
||||
) {
|
||||
let mut view = view.as_boxed_view();
|
||||
let mut view = view.into_boxed_view();
|
||||
view.take_focus(direction::Direction::none());
|
||||
self.children.push(ListChild::Row(label.to_string(), view));
|
||||
self.children_heights.push(0);
|
||||
|
@ -16,8 +16,8 @@ features = ["unstable_scroll", "markdown", "toml"]
|
||||
|
||||
[dependencies]
|
||||
cursive_core = { path = "../cursive-core", version="0.1.1-alpha.0" }
|
||||
crossbeam-channel = "0.4"
|
||||
cfg-if = "0.1"
|
||||
crossbeam-channel = "0.5"
|
||||
cfg-if = "1"
|
||||
enumset = "1"
|
||||
unicode-segmentation = "1"
|
||||
unicode-width = "0.1"
|
||||
@ -26,7 +26,7 @@ libc = "0.2"
|
||||
term_size = { version = "0.3", optional = true }
|
||||
maplit = { version = "1.0", optional = true }
|
||||
log = "0.4"
|
||||
ahash = "0.4"
|
||||
ahash = "0.6"
|
||||
|
||||
[dependencies.bear-lib-terminal]
|
||||
optional = true
|
||||
@ -48,12 +48,7 @@ version = "1"
|
||||
|
||||
[dependencies.crossterm]
|
||||
optional = true
|
||||
version = "0.17"
|
||||
|
||||
[dev-dependencies]
|
||||
rand = "0.7"
|
||||
pretty-bytes = "0.2"
|
||||
atty = "0.2"
|
||||
version = "0.19"
|
||||
|
||||
[features]
|
||||
blt-backend = ["bear-lib-terminal"]
|
||||
@ -70,4 +65,4 @@ toml = ["cursive_core/toml"]
|
||||
name = "cursive"
|
||||
|
||||
[target.'cfg(unix)'.dependencies]
|
||||
signal-hook = "0.1"
|
||||
signal-hook = "0.3"
|
||||
|
@ -372,11 +372,9 @@ fn colour_to_blt_colour(clr: Color, role: ColorRole) -> BltColor {
|
||||
}
|
||||
|
||||
fn blt_keycode_to_char(kc: KeyCode, shift: bool) -> char {
|
||||
let bltchar = bear_lib_terminal::terminal::state::char();
|
||||
if bltchar == '\u{0}' {
|
||||
return blt_keycode_to_char_impl(kc, shift);
|
||||
} else {
|
||||
return bltchar;
|
||||
match bear_lib_terminal::terminal::state::char() {
|
||||
'\u{0}' => blt_keycode_to_char_impl(kc, shift),
|
||||
c => c,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ use crossterm::{
|
||||
poll, read, DisableMouseCapture, EnableMouseCapture, Event as CEvent,
|
||||
KeyCode, KeyEvent as CKeyEvent, KeyModifiers,
|
||||
MouseButton as CMouseButton, MouseEvent as CMouseEvent,
|
||||
MouseEventKind,
|
||||
},
|
||||
execute, queue,
|
||||
style::{
|
||||
@ -232,34 +233,28 @@ impl Backend {
|
||||
fn map_key(&mut self, event: CEvent) -> Event {
|
||||
match event {
|
||||
CEvent::Key(key_event) => translate_event(key_event),
|
||||
CEvent::Mouse(mouse_event) => {
|
||||
let position;
|
||||
let event;
|
||||
|
||||
match mouse_event {
|
||||
CMouseEvent::Down(button, x, y, _) => {
|
||||
let button = translate_button(button);
|
||||
event = MouseEvent::Press(button);
|
||||
position = (x, y).into();
|
||||
CEvent::Mouse(CMouseEvent {
|
||||
kind,
|
||||
column,
|
||||
row,
|
||||
modifiers: _,
|
||||
}) => {
|
||||
let position = (column, row).into();
|
||||
let event = match kind {
|
||||
MouseEventKind::Down(button) => {
|
||||
MouseEvent::Press(translate_button(button))
|
||||
}
|
||||
CMouseEvent::Up(button, x, y, _) => {
|
||||
let button = translate_button(button);
|
||||
event = MouseEvent::Release(button);
|
||||
position = (x, y).into();
|
||||
MouseEventKind::Up(button) => {
|
||||
MouseEvent::Release(translate_button(button))
|
||||
}
|
||||
CMouseEvent::Drag(button, x, y, _) => {
|
||||
let button = translate_button(button);
|
||||
event = MouseEvent::Hold(button);
|
||||
position = (x, y).into();
|
||||
MouseEventKind::Drag(button) => {
|
||||
MouseEvent::Hold(translate_button(button))
|
||||
}
|
||||
CMouseEvent::ScrollDown(x, y, _) => {
|
||||
event = MouseEvent::WheelDown;
|
||||
position = (x, y).into();
|
||||
}
|
||||
CMouseEvent::ScrollUp(x, y, _) => {
|
||||
event = MouseEvent::WheelUp;
|
||||
position = (x, y).into();
|
||||
MouseEventKind::Moved => {
|
||||
unreachable!("Not tracking mouse move.");
|
||||
}
|
||||
MouseEventKind::ScrollDown => MouseEvent::WheelDown,
|
||||
MouseEventKind::ScrollUp => MouseEvent::WheelUp,
|
||||
};
|
||||
|
||||
Event::Mouse {
|
||||
|
@ -11,7 +11,7 @@ pub fn start_resize_thread(
|
||||
resize_sender: Sender<()>,
|
||||
resize_running: Arc<AtomicBool>,
|
||||
) {
|
||||
let signals = Signals::new(&[libc::SIGWINCH]).unwrap();
|
||||
let mut signals = Signals::new(&[libc::SIGWINCH]).unwrap();
|
||||
thread::spawn(move || {
|
||||
// This thread will listen to SIGWINCH events and report them.
|
||||
while resize_running.load(Ordering::Relaxed) {
|
||||
|
@ -14,9 +14,9 @@ version = "0.1.1-alpha.0"
|
||||
atty = "0.2.14"
|
||||
log = "0.4.8"
|
||||
pretty-bytes = "0.2.2"
|
||||
rand = "0.7.3"
|
||||
rand = "0.8"
|
||||
cursive = { path = "../cursive", default-features=false }
|
||||
crossbeam-channel = "0.4.2"
|
||||
crossbeam-channel = "0.5"
|
||||
lazy_static = "1.4"
|
||||
|
||||
[features]
|
||||
|
@ -39,7 +39,7 @@ impl Board {
|
||||
for _ in 0..options.mines {
|
||||
// Find a free cell to put a bomb
|
||||
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] {
|
||||
continue;
|
||||
|
@ -74,7 +74,7 @@ fn phase_2(s: &mut Cursive) {
|
||||
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
|
||||
let speeds: Vec<_> = (0..n_bars)
|
||||
.map(|_| rand::thread_rng().gen_range(50, 150))
|
||||
.map(|_| rand::thread_rng().gen_range(50..150))
|
||||
.collect();
|
||||
|
||||
let n_max = 100_000;
|
||||
|
Loading…
Reference in New Issue
Block a user