Skip to content

Commit 42a31ae

Browse files
committed
version 0.29.3
1 parent c7e1e81 commit 42a31ae

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
*If you're reading this because you try make sense of some new API or a breaking change, you might also be interested in coming to the chat for explanations or guidance.*
22

3+
<a name="v0.29.3"></a>
4+
### v0.29.3 - 2024-06-13
5+
- `ask!` macro doesn't need separate imports anymore
6+
37
<a name="v0.29.2"></a>
48
### v0.29.2 - 2024-04-24
59
- update Crokey to 1.0.0

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "termimad"
3-
version = "0.29.2"
3+
version = "0.29.3"
44
authors = ["dystroy <denys.seguret@gmail.com>"]
55
repository = "https://github.com/Canop/termimad"
66
description = "Markdown Renderer for the Terminal"

src/area.rs

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ const DEFAULT_TERMINAL_WIDTH: u16 = 50;
99
/// A default height which is used when we failed measuring the real terminal width
1010
const DEFAULT_TERMINAL_HEIGHT: u16 = 20;
1111

12-
pub trait AreaContent {
13-
fn height() -> u16;
14-
}
15-
1612
/// A rectangular part of the screen
1713
#[derive(Debug, PartialEq, Eq, Clone)]
1814
pub struct Area {

src/ask.rs

+18-7
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,27 @@ impl Question {
102102
/// ask the user to choose among proposed answers.
103103
///
104104
/// This macro makes it possible to propose several choices, with
105-
/// an optional default ones, to execute blocks, to optionaly return
105+
/// an optional default one, to execute blocks, to optionaly return
106106
/// a value.
107107
///
108-
/// Example:
108+
/// Example of a simple confirmation::
109+
///
110+
/// ```no_run
111+
/// let confirmed = termimad::ask!(
112+
/// termimad::get_default_skin(),
113+
/// "Do you want to erase the disk ?", ('n') {
114+
/// ('y', "**Y**es") => { true }
115+
/// ('n', "**N**o") => { false }
116+
/// }
117+
/// );
118+
/// ```
119+
///
120+
/// Example of chained questions:
109121
///
110122
/// ```no_run
111123
/// use termimad::*;
112124
///
113125
/// let skin = get_default_skin();
114-
///
115126
/// let beverage = ask!(skin, "What do I serve you ?", {
116127
/// ('b', "**B**eer") => {
117128
/// ask!(skin, "Really ? We have wine and orange juice too", (2) {
@@ -139,9 +150,9 @@ macro_rules! ask {
139150
$question: expr,
140151
{ $(($key: expr, $answer: expr) => $r: block)+ }
141152
) => {{
142-
let mut question = Question {
153+
let mut question = $crate::Question {
143154
md: Some($question.to_string()),
144-
answers: vec![$(Answer { key: $key.to_string(), md: $answer.to_string() }),*],
155+
answers: vec![$($crate::Answer { key: $key.to_string(), md: $answer.to_string() }),*],
145156
default_answer: None,
146157
};
147158
let key = question.ask($skin).unwrap();
@@ -159,9 +170,9 @@ macro_rules! ask {
159170
($default_answer: expr)
160171
{ $(($key: expr, $answer: expr) => $r: block)+ }
161172
) => {{
162-
let mut question = Question {
173+
let mut question = $crate::Question {
163174
md: Some($question.to_string()),
164-
answers: vec![$(Answer { key: $key.to_string(), md: $answer.to_string() }),*],
175+
answers: vec![$($crate::Answer { key: $key.to_string(), md: $answer.to_string() }),*],
165176
default_answer: Some($default_answer.to_string()),
166177
};
167178
if question.has_exotic_default() {

0 commit comments

Comments
 (0)