Skip to content

Commit d74bd86

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 6c86ca3 + 203ab68 commit d74bd86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1680
-655
lines changed

.github/workflows/deny.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on: [push, pull_request]
2+
3+
name: cargo-deny
4+
5+
jobs:
6+
deny:
7+
name: deny
8+
runs-on: ubuntu-latest
9+
10+
strategy:
11+
matrix:
12+
checks:
13+
- advisories
14+
- bans licenses sources
15+
16+
# Prevent sudden announcement of a new advisory from failing ci:
17+
continue-on-error: ${{ matrix.checks == 'advisories' }}
18+
19+
steps:
20+
- name: Checkout sources
21+
uses: actions/[email protected]
22+
23+
- name: Install toolchain
24+
uses: dtolnay/rust-toolchain@master
25+
with:
26+
toolchain: 1.73.0
27+
28+
- name: Cache
29+
uses: Swatinem/rust-cache@v2
30+
31+
- name: cargo-deny
32+
uses: EmbarkStudios/cargo-deny-action@v1
33+
with:
34+
command: check ${{ matrix.checks }}
35+

CHANGELOG.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,57 @@
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.4"></a>
4+
### v0.29.4 - 2024-06-17
5+
- fix compilation with `default-features = false` - Fix #62
6+
7+
<a name="v0.29.3"></a>
8+
### v0.29.3 - 2024-06-13
9+
- `ask!` macro doesn't need separate imports anymore
10+
11+
<a name="v0.29.2"></a>
12+
### v0.29.2 - 2024-04-24
13+
- update Crokey to 1.0.0
14+
15+
<a name="v0.29.1"></a>
16+
### v0.29.1 - 2024-02-10
17+
- event source's `combining` now `false` by default
18+
19+
<a name="v0.29.0"></a>
20+
### v0.29.0 - 2024-01-29
21+
- list items are now by default indented as blocks. It's possible to revert to the old rendering (only the first line indented) with the list_items_identation_mod field of the skin - Fix #21
22+
23+
<a name="v0.28.2"></a>
24+
### v0.28.2 - 2024-01-26
25+
- Better support of repeated keys in EventSource
26+
27+
<a name="v0.28.1"></a>
28+
### v0.28.1 - 2024-01-20
29+
- EventSource by default mandates modifier (or space) for combinations with multiple simple keys. This can be changed with an option
30+
31+
<a name="v0.28.0"></a>
32+
### v0.28.0 - 2024-01-18
33+
- Major change: termimad and its coolor and crokey dependencies now use the version 0.27 of Crossterm, which brings many breaking changes but allows new capabilities in key events handling. Termimad's EventSource now outputs key combinations along crossterm events.
34+
35+
<a name="v0.27.0"></a>
36+
### v0.27.0 - 2024-01-08
37+
- paragraphs, code blocks, headers, and tables can be given a left_margin and a right_margin - Fix #11
38+
39+
<a name="v0.26.1"></a>
40+
### v0.26.1 - 2023-11-05
41+
- can_move_left and can_move_right functions on InputField
42+
43+
<a name="v0.26.0"></a>
44+
### v0.26.0 - 2023-11-03
45+
- MadSkin and other structs now implement serde::Serialize - Fix #19
46+
47+
<a name="v0.25.7"></a>
48+
### v0.25.7 - 2023-10-31
49+
- upgrade coolor, removing the ansi_colours dependency, fixing a license incompatibility - Fix #51
50+
51+
<a name="v0.25.6"></a>
52+
### v0.25.6 - 2023-10-31
53+
- upgrade terminal-clipboard due to RUSTSEC-2021-0019 in its X11 dependency
54+
355
<a name="v0.25.5"></a>
456
### v0.25.5 - 2023-10-16
557
- dependency version updated

Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "termimad"
3-
version = "0.25.5"
3+
version = "0.29.4"
44
authors = ["dystroy <[email protected]>"]
55
repository = "https://github.com/Canop/termimad"
66
description = "Markdown Renderer for the Terminal"
@@ -17,25 +17,27 @@ special-renders = []
1717
default = ["special-renders"]
1818

1919
[dependencies]
20-
minimad = "0.13.0"
21-
coolor = { version="0.7.0", features=["crossterm"] }
22-
crossterm = "=0.23.2"
20+
coolor = { version="0.9.0", features=["crossterm"] }
21+
crokey = "1.0.0"
2322
crossbeam = "0.8"
2423
lazy-regex = "3.2"
24+
minimad = "0.13.0"
2525
serde = { version = "1.0", features = ["derive"] }
2626
thiserror = "1.0"
27-
unicode-width = "0.1.10"
27+
unicode-width = "0.1.11"
2828
# cli-log = "2.0"
2929

3030
[dev-dependencies]
3131
anyhow = "1.0"
3232
cli-log = "2"
33-
crokey = "0.4"
3433
deser-hjson = "2"
35-
terminal-clipboard = ">=0.3.1"
34+
pretty_assertions = "1.4"
35+
serde_json = "1"
36+
terminal-clipboard = "0.4.1"
3637

3738
[patch.crates-io]
3839
# coolor = { path = "../coolor" }
40+
# crokey = { path = "../crokey" }
3941
# crossterm = { path = "../crossterm" }
4042
# minimad = { path = "../minimad" }
4143
# terminal-clipboard = { path = "../terminal-clipboard" }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,4 +320,4 @@ If you're the author of another application using Termimad, please tell me.
320320

321321
[Crossterm](https://github.com/crossterm-rs/crossterm) is a 0.x library which means its API isn't frozen. And it does change sometimes so libraries based on Crossterm can't always use its last version.
322322

323-
Crossterm 0.23.x is reexported by Termimad so you don't have to declare the import yourself. You may use crossterm as `termimad::crossterm`.
323+
Crossterm 0.27.x is reexported by Termimad so you don't have to declare the import yourself. You may use crossterm as `termimad::crossterm`.

bacon.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ default_job = "check-all"
99
command = ["cargo", "check", "--color", "always"]
1010
need_stdout = false
1111

12+
[jobs.check-no-features]
13+
command = ["cargo", "check", "--no-default-features", "--color", "always"]
14+
need_stdout = false
15+
1216
[jobs.check-all]
1317
command = ["cargo", "check", "--all-targets", "--color", "always"]
1418
need_stdout = false

deny.toml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
[licenses]
2+
# The lint level for crates which do not have a detectable license
3+
unlicensed = "deny"
4+
5+
# List of explicitly allowed licenses
6+
# See https://spdx.org/licenses/ for list of possible licenses
7+
# [possible values: any SPDX 3.7 short identifier (+ optional exception)].
8+
allow = []
9+
10+
# List of explicitly disallowed licenses
11+
# See https://spdx.org/licenses/ for list of possible licenses
12+
# [possible values: any SPDX 3.7 short identifier (+ optional exception)].
13+
deny = []
14+
15+
# The lint level for licenses considered copyleft
16+
copyleft = "deny"
17+
18+
# Blanket approval or denial for OSI-approved or FSF Free/Libre licenses
19+
# * both - The license will only be approved if it is both OSI-approved *AND* FSF/Free
20+
# * either - The license will be approved if it is either OSI-approved *OR* FSF/Free
21+
# * osi-only - The license will be approved if is OSI-approved *AND NOT* FSF/Free
22+
# * fsf-only - The license will be approved if is FSF/Free *AND NOT* OSI-approved
23+
# * neither - The license will be denied if is FSF/Free *OR* OSI-approved
24+
allow-osi-fsf-free = "either"
25+
26+
# The confidence threshold for detecting a license from license text.
27+
# The higher the value, the more closely the license text must be to the
28+
# canonical license text of a valid SPDX license file.
29+
# [possible values: any between 0.0 and 1.0].
30+
confidence-threshold = 0.8
31+
32+
exceptions = [
33+
]
34+
35+
[bans]
36+
# Lint level for when multiple versions of the same crate are detected
37+
multiple-versions = "warn"
38+
39+
# The graph highlighting used when creating dotgraphs for crates
40+
# with multiple versions
41+
# * lowest-version - The path to the lowest versioned duplicate is highlighted
42+
# * simplest-path - The path to the version with the fewest edges is highlighted
43+
# * all - Both lowest-version and simplest-path are used
44+
highlight = "all"
45+
46+
# List of crates that are allowed. Use with care!
47+
allow = [
48+
]
49+
50+
# List of crates to deny
51+
deny = [
52+
# Each entry the name of a crate and a version range. If version is
53+
# not specified, all versions will be matched.
54+
]
55+
56+
# Certain crates/versions that will be skipped when doing duplicate detection.
57+
skip = [
58+
]
59+
60+
# Similarly to `skip` allows you to skip certain crates during duplicate detection,
61+
# unlike skip, it also includes the entire tree of transitive dependencies starting at
62+
# the specified crate, up to a certain depth, which is by default infinite
63+
skip-tree = [
64+
]
65+
66+
67+
[advisories]
68+
ignore = [
69+
]
70+
71+

examples/fit-width/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use {
88
cursor::{self, Hide, Show},
99
event::{self, Event},
1010
ExecutableCommand,
11-
terminal::{self, EnterAlternateScreen, LeaveAlternateScreen},
11+
terminal::{self, Clear, ClearType, EnterAlternateScreen, LeaveAlternateScreen},
1212
style::Color::*,
1313
},
1414
termimad::*,
@@ -75,9 +75,14 @@ fn run_app(skin: &MadSkin) -> Result<(), Error> {
7575
Ok(Event::Key(_)) => {
7676
break;
7777
}
78-
Ok(Event::Resize(w, h)) => {
79-
width = w;
80-
height = h;
78+
Ok(Event::Resize(new_width, new_height)) => {
79+
width = new_width;
80+
height = new_height;
81+
cli_log::debug!("Resized to width: {}, height: {}", width, height);
82+
// To fix a bug in Kitty, which rewrites the terminal on resize and
83+
// thus writes characters below the "height" limit, we clear
84+
// the whole terminal.
85+
w.execute(Clear(ClearType::All))?;
8186
}
8287
_ => {}
8388
}
@@ -100,6 +105,7 @@ fn make_skin() -> MadSkin {
100105
}
101106

102107
fn main() -> Result<(), Error> {
108+
cli_log::init_cli_log!();
103109
let skin = make_skin();
104110
run_app(&skin)
105111
}

examples/indented-code/main.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use termimad::*;
2+
3+
static MD: &str = r#"
4+
# Indented Code
5+
6+
To indent code (as demonstrated here) do this:
7+
8+
```rust
9+
fn main() {
10+
let mut skin = MadSkin::default();
11+
skin.code_block.left_margin = 4;
12+
skin.print_text(MD);
13+
}
14+
```
15+
16+
Note that you can add some margin to other kinds of lines, not just code blocks.
17+
18+
"#;
19+
20+
fn main() {
21+
let mut skin = MadSkin::default();
22+
skin.code_block.left_margin = 4;
23+
skin.print_text(MD);
24+
}

examples/inputs/view.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use {
22
crate::clipboard,
33
anyhow::{self},
4-
crokey::key,
4+
crokey::{key, KeyCombination},
55
std::io::Write,
66
termimad::*,
77
termimad::crossterm::{
8-
event::{Event, KeyEvent, MouseEvent},
8+
event::{Event, MouseEvent},
99
queue,
1010
terminal::{
1111
Clear,
@@ -132,15 +132,15 @@ impl View {
132132
self.area = area;
133133
true
134134
}
135-
pub fn apply_key_event(&mut self, key: KeyEvent) -> bool {
135+
pub fn apply_key_combination(&mut self, key: KeyCombination) -> bool {
136136
if key == key!(esc) {
137137
self.set_focus(Focus::Introduction);
138138
true
139139
} else if key == key!(tab) {
140140
self.focus_next();
141141
true
142142
} else if let Some(input) = self.focused_input() {
143-
input.apply_key_event(key) || {
143+
input.apply_key_combination(key) || {
144144
if key == key!(ctrl-c) {
145145
clipboard::copy_from_input(input)
146146
} else if key == key!(ctrl-x) {
@@ -152,7 +152,7 @@ impl View {
152152
}
153153
}
154154
} else {
155-
self.introduction.apply_key_event(key)
155+
self.introduction.apply_key_combination(key)
156156
}
157157
}
158158
pub fn apply_mouse_event(&mut self, mouse_event: MouseEvent, double_click: bool) -> bool {
@@ -169,9 +169,10 @@ impl View {
169169
}
170170
pub fn apply_timed_event(&mut self, timed_event: TimedEvent) -> bool {
171171
match timed_event.event {
172-
Event::Key(key) => self.apply_key_event(key),
172+
Event::Key(key) => self.apply_key_combination(key.into()),
173173
Event::Mouse(me) => self.apply_mouse_event(me, timed_event.double_click),
174174
Event::Resize(w, h) => self.resize(Area::new(0, 0, w, h)),
175+
_ => false,
175176
}
176177
}
177178
/// draw the view (not flushing)

examples/render-input-markdown/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn run_in_alternate<W: Write>(w: &mut W) -> anyhow::Result<()> {
5656
debug!("event: {:?}", timed_event);
5757
if timed_event.is_key(key!(ctrl-q)) {
5858
quit = true;
59-
} else if view.apply_timed_event(timed_event) {
59+
} else if view.apply_timed_event(&timed_event) {
6060
view.queue_on(w)?;
6161
w.flush()?;
6262
}

0 commit comments

Comments
 (0)