mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-27 19:26:09 +00:00
Add Plain markup implementation
This commit is contained in:
parent
59d67e891c
commit
6f468658e1
@ -5,7 +5,7 @@
|
|||||||
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
|
[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
|
||||||
[![Gitter chat](https://badges.gitter.im/gyscos/cursive.png)](https://gitter.im/cursive-rs/cursive)
|
[![Gitter chat](https://badges.gitter.im/gyscos/cursive.png)](https://gitter.im/cursive-rs/cursive)
|
||||||
|
|
||||||
Cursive is a TUI (Text User Interface) library for rust. It is currently based on jeaye's [ncurses-rs](https://github.com/jeaye/ncurses-rs), but [other backends are available](https://github.com/gyscos/Cursive/wiki/Backends).
|
Cursive is a TUI (Text User Interface) library for rust. It uses ncurses by default, but [other backends are available](https://github.com/gyscos/Cursive/wiki/Backends).
|
||||||
|
|
||||||
It allows you to build rich user interfaces for terminal applications.
|
It allows you to build rich user interfaces for terminal applications.
|
||||||
|
|
||||||
|
@ -9,8 +9,9 @@ pub mod markdown;
|
|||||||
pub use self::markdown::Markdown;
|
pub use self::markdown::Markdown;
|
||||||
use owning_ref::OwningHandle;
|
use owning_ref::OwningHandle;
|
||||||
use owning_ref::StringRef;
|
use owning_ref::StringRef;
|
||||||
use std::marker::PhantomData;
|
|
||||||
use utils::lines::spans::Span;
|
use utils::lines::spans::Span;
|
||||||
|
use theme::Style;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
/// Trait for parsing text into styled spans.
|
/// Trait for parsing text into styled spans.
|
||||||
pub trait Markup {
|
pub trait Markup {
|
||||||
@ -35,6 +36,20 @@ pub trait Markup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Dummy `Markup` implementation that returns the text as-is.
|
||||||
|
pub struct Plain;
|
||||||
|
|
||||||
|
impl Markup for Plain {
|
||||||
|
type Error = ();
|
||||||
|
|
||||||
|
fn parse<'a>(input: &'a str) -> Result<Vec<Span<'a>>, Self::Error> {
|
||||||
|
Ok(vec![Span {
|
||||||
|
text: Cow::Borrowed(input),
|
||||||
|
style: Style::none(),
|
||||||
|
}])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Holds both parsed spans, and the input string they borrow.
|
/// Holds both parsed spans, and the input string they borrow.
|
||||||
///
|
///
|
||||||
/// This is used to pass around a parsed string.
|
/// This is used to pass around a parsed string.
|
||||||
|
Loading…
Reference in New Issue
Block a user