diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8546968..f047ea4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,8 @@
+
+### v0.8.4 - 2019-12-16
+- fix a compilation problem on windows (see https://github.com/Canop/termimad/issues/13#issuecomment-565848039)
+
### v0.8.3 - 2019-12-15
- port to crossterm 0.14
diff --git a/Cargo.toml b/Cargo.toml
index 87bd8d2..c911295 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "termimad"
-version = "0.8.3"
+version = "0.8.4"
authors = ["dystroy "]
repository = "https://github.com/Canop/termimad"
description = "Markdown Renderer for the Terminal"
diff --git a/src/compound_style.rs b/src/compound_style.rs
index 2bf1824..8f3998f 100644
--- a/src/compound_style.rs
+++ b/src/compound_style.rs
@@ -1,14 +1,16 @@
-use std::fmt::{self, Display};
-use crossterm::{
- queue,
- style::{
- Attribute, Color, ContentStyle, PrintStyledContent, SetBackgroundColor, SetForegroundColor,
- StyledContent,
+use {
+ crate::{errors::Result, styled_char::StyledChar},
+ crossterm::{
+ QueueableCommand,
+ style::{
+ Attribute, Color, ContentStyle, PrintStyledContent, SetBackgroundColor, SetForegroundColor,
+ StyledContent,
+ },
},
+ std::fmt::{self, Display},
};
-use crate::{errors::Result, styled_char::StyledChar};
/// A style which may be applied to a compound
#[derive(Default, Clone)]
@@ -24,9 +26,9 @@ impl From for CompoundStyle {
impl CompoundStyle {
/// Apply an `StyledContent` to the passed displayable object.
- pub fn apply_to(&self, val: D) -> StyledContent
+ pub fn apply_to(&self, val: D) -> StyledContent
where
- D: Clone,
+ D: Clone + Display,
{
self.object_style.apply(val)
}
@@ -146,7 +148,8 @@ impl CompoundStyle {
D: Clone + Display,
W: std::io::Write,
{
- Ok(queue!(w, PrintStyledContent(self.apply_to(val)))?)
+ w.queue(PrintStyledContent(self.apply_to(val)))?;
+ Ok(())
}
/// write the string with this style on the given
@@ -163,7 +166,7 @@ impl CompoundStyle {
W: std::io::Write,
{
if let Some(fg) = self.object_style.foreground_color {
- queue!(w, SetForegroundColor(fg))?;
+ w.queue(SetForegroundColor(fg))?;
}
Ok(())
}
@@ -173,7 +176,7 @@ impl CompoundStyle {
W: std::io::Write,
{
if let Some(bg) = self.object_style.background_color {
- queue!(w, SetBackgroundColor(bg))?;
+ w.queue(SetBackgroundColor(bg))?;
}
Ok(())
}
diff --git a/src/events/event.rs b/src/events/event.rs
index 3838ec6..86dce05 100644
--- a/src/events/event.rs
+++ b/src/events/event.rs
@@ -1,7 +1,12 @@
-use crossterm;
+use crossterm::{
+ self,
+ event::{
+ KeyCode, KeyModifiers,
+ },
+};
/// a valid user event
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Event {
Key(crossterm::event::KeyEvent),
@@ -50,5 +55,22 @@ impl Event {
_ => None,
}
}
+ pub const fn crtl_key(code: KeyCode) -> Self {
+ Event::Key(
+ crossterm::event::KeyEvent {
+ code,
+ modifiers: KeyModifiers::CONTROL,
+ }
+ )
+ }
+ pub const fn simple_key(code: KeyCode) -> Self {
+ Event::Key(
+ crossterm::event::KeyEvent {
+ code,
+ modifiers: KeyModifiers::empty(),
+ }
+ )
+ }
}
+
diff --git a/src/styled_char.rs b/src/styled_char.rs
index 5d65b86..b8a70d8 100644
--- a/src/styled_char.rs
+++ b/src/styled_char.rs
@@ -1,13 +1,15 @@
-use std::fmt::{self, Display};
-
-use crossterm::{
- queue,
- style::{Color, PrintStyledContent, StyledContent},
+use {
+ crate::{
+ compound_style::CompoundStyle,
+ errors::Result,
+ },
+ crossterm::{
+ QueueableCommand,
+ style::{Color, PrintStyledContent, StyledContent},
+ },
+ std::fmt::{self, Display},
};
-use crate::compound_style::CompoundStyle;
-use crate::errors::Result;
-
/// A modifiable character which can be easily written or repeated. Can
/// be used for bullets, horizontal rules or quote marks.
#[derive(Clone)]
@@ -66,7 +68,8 @@ impl StyledChar {
where
W: std::io::Write,
{
- Ok(queue!(w, PrintStyledContent(self.styled_char.clone()))?)
+ w.queue(PrintStyledContent(self.styled_char.clone()))?;
+ Ok(())
}
}