mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-09 19:00:46 +00:00
Use cfg-if for to define Cursive::default()
And update other dependencies
This commit is contained in:
parent
51c6450688
commit
ac28309b3b
19
Cargo.toml
19
Cargo.toml
@ -20,19 +20,20 @@ repository = "gyscos/Cursive"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
enum-map = "0.5.0"
|
enum-map = "0.5.0"
|
||||||
enumset = "0.3.15"
|
enumset = "0.3.17"
|
||||||
log = "0.4.6"
|
log = "0.4.6"
|
||||||
owning_ref = "0.4.0"
|
owning_ref = "0.4.0"
|
||||||
toml = "0.4.10"
|
toml = "0.5.0"
|
||||||
unicode-segmentation = "1.2.1"
|
unicode-segmentation = "1.2.1"
|
||||||
unicode-width = "0.1.5"
|
unicode-width = "0.1.5"
|
||||||
xi-unicode = "0.1.0"
|
xi-unicode = "0.1.0"
|
||||||
libc = "0.2.47"
|
libc = "0.2.51"
|
||||||
term_size = { version = "0.3.1", optional = true }
|
term_size = { version = "0.3.1", optional = true }
|
||||||
crossbeam-channel = "0.3.6"
|
crossbeam-channel = "0.3.8"
|
||||||
lazy_static = "1.2.0"
|
lazy_static = "1.3.0"
|
||||||
chrono = "0.4.6"
|
chrono = "0.4.6"
|
||||||
hashbrown = "0.1.8"
|
hashbrown = "0.2.1"
|
||||||
|
cfg-if = "0.1.7"
|
||||||
|
|
||||||
[dependencies.num]
|
[dependencies.num]
|
||||||
default-features = false
|
default-features = false
|
||||||
@ -59,17 +60,17 @@ version = "0.16.1"
|
|||||||
[dependencies.pulldown-cmark]
|
[dependencies.pulldown-cmark]
|
||||||
default-features = false
|
default-features = false
|
||||||
optional = true
|
optional = true
|
||||||
version = "0.2.0"
|
version = "0.4.1"
|
||||||
|
|
||||||
[dependencies.termion]
|
[dependencies.termion]
|
||||||
optional = true
|
optional = true
|
||||||
version = "1.5.1"
|
version = "1.5.1"
|
||||||
|
|
||||||
[target.'cfg(unix)'.dependencies]
|
[target.'cfg(unix)'.dependencies]
|
||||||
signal-hook = "0.1.7"
|
signal-hook = "0.1.8"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.6.4"
|
rand = "0.6.5"
|
||||||
pretty-bytes = "0.2.2"
|
pretty-bytes = "0.2.2"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
@ -77,41 +77,33 @@ impl<F: FnOnce(&mut Cursive) -> () + Send> CbFunc for F {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "termion-backend")]
|
cfg_if::cfg_if! {
|
||||||
impl Default for Cursive {
|
if #[cfg(feature = "blt-backend")] {
|
||||||
fn default() -> Self {
|
impl Default for Cursive {
|
||||||
Self::termion().unwrap()
|
fn default() -> Self {
|
||||||
}
|
Self::blt()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#[cfg(all(not(feature = "termion-backend"), feature = "pancurses-backend"))]
|
} else if #[cfg(feature = "termion-backend")] {
|
||||||
impl Default for Cursive {
|
impl Default for Cursive {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::pancurses().unwrap()
|
Self::termion().unwrap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if #[cfg(feature = "pancurses-backend")] {
|
||||||
#[cfg(all(
|
impl Default for Cursive {
|
||||||
not(feature = "termion-backend"),
|
fn default() -> Self {
|
||||||
not(feature = "pancurses-backend"),
|
Self::pancurses().unwrap()
|
||||||
feature = "blt-backend"
|
}
|
||||||
))]
|
}
|
||||||
impl Default for Cursive {
|
} else if #[cfg(feature = "ncurses-backend")] {
|
||||||
fn default() -> Self {
|
impl Default for Cursive {
|
||||||
Self::blt()
|
fn default() -> Self {
|
||||||
}
|
Self::ncurses().unwrap()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#[cfg(all(
|
|
||||||
not(feature = "termion-backend"),
|
|
||||||
not(feature = "pancurses-backend"),
|
|
||||||
not(feature = "blt-backend"),
|
|
||||||
feature = "ncurses-backend"
|
|
||||||
))]
|
|
||||||
impl Default for Cursive {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self::ncurses().unwrap()
|
|
||||||
}
|
}
|
||||||
|
// No Default implementation otherwise.
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cursive {
|
impl Cursive {
|
||||||
|
@ -2,11 +2,13 @@
|
|||||||
//!
|
//!
|
||||||
//! Needs the `markdown` feature to be enabled.
|
//! Needs the `markdown` feature to be enabled.
|
||||||
|
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::theme::{Effect, Style};
|
use crate::theme::{Effect, Style};
|
||||||
use crate::utils::markup::{StyledIndexedSpan, StyledString};
|
use crate::utils::markup::{StyledIndexedSpan, StyledString};
|
||||||
use crate::utils::span::IndexedCow;
|
use crate::utils::span::IndexedCow;
|
||||||
|
|
||||||
use pulldown_cmark::{self, Event, Tag};
|
use pulldown_cmark::{self, CowStr, Event, Tag};
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
/// Parses the given string as markdown text.
|
/// Parses the given string as markdown text.
|
||||||
@ -79,7 +81,7 @@ impl<'a> Iterator for Parser<'a> {
|
|||||||
}
|
}
|
||||||
Tag::Rule => return Some(self.literal("---")),
|
Tag::Rule => return Some(self.literal("---")),
|
||||||
Tag::BlockQuote => return Some(self.literal("> ")),
|
Tag::BlockQuote => return Some(self.literal("> ")),
|
||||||
Tag::Link(_, _) => return Some(self.literal("[")),
|
Tag::Link(_, _, _) => return Some(self.literal("[")),
|
||||||
Tag::Code => return Some(self.literal("```")),
|
Tag::Code => return Some(self.literal("```")),
|
||||||
Tag::Strong => self.stack.push(Style::from(Effect::Bold)),
|
Tag::Strong => self.stack.push(Style::from(Effect::Bold)),
|
||||||
Tag::Paragraph if !self.first => {
|
Tag::Paragraph if !self.first => {
|
||||||
@ -91,7 +93,7 @@ impl<'a> Iterator for Parser<'a> {
|
|||||||
// Remove from stack!
|
// Remove from stack!
|
||||||
Tag::Paragraph if self.first => self.first = false,
|
Tag::Paragraph if self.first => self.first = false,
|
||||||
Tag::Header(_) => return Some(self.literal("\n\n")),
|
Tag::Header(_) => return Some(self.literal("\n\n")),
|
||||||
Tag::Link(link, _) => {
|
Tag::Link(_, link, _) => {
|
||||||
return Some(self.literal(format!("]({})", link)))
|
return Some(self.literal(format!("]({})", link)))
|
||||||
}
|
}
|
||||||
Tag::Code => return Some(self.literal("```")),
|
Tag::Code => return Some(self.literal("```")),
|
||||||
@ -107,6 +109,11 @@ impl<'a> Iterator for Parser<'a> {
|
|||||||
| Event::InlineHtml(text)
|
| Event::InlineHtml(text)
|
||||||
| Event::Html(text)
|
| Event::Html(text)
|
||||||
| Event::Text(text) => {
|
| Event::Text(text) => {
|
||||||
|
let text = match text {
|
||||||
|
CowStr::Boxed(text) => Cow::Owned(text.into()),
|
||||||
|
CowStr::Borrowed(text) => Cow::Borrowed(text),
|
||||||
|
CowStr::Inlined(text) => Cow::Owned(text.to_string()),
|
||||||
|
};
|
||||||
let width = text.width();
|
let width = text.width();
|
||||||
// Return something!
|
// Return something!
|
||||||
return Some(StyledIndexedSpan {
|
return Some(StyledIndexedSpan {
|
||||||
@ -115,6 +122,10 @@ impl<'a> Iterator for Parser<'a> {
|
|||||||
width,
|
width,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Event::TaskListMarker(checked) => {
|
||||||
|
let mark = if checked { "[x]" } else { "[ ]" };
|
||||||
|
return Some(self.literal(mark));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user