Comments (10)
Please don't do a PR for that. I follow crossterm and every release involves a lot of tests and adaptations. I'll manage that myself.
from termimad.
I did the migration. I also migrated broot (there was a lot to rewrite).
I'm still not 100% sure there's no problem with crossterm 0.14 event system, though. I'll go on testing. I pushed so that you may test too. Please let me know how it works fo you.
from termimad.
OK, found why the macro makes my code fail on windows and how to fix it.
The problem with macros is that arguments are repeated instead of being used.
So
Ok(queue!(w, PrintStyledContent(self.apply_to(val)))?)
is very different from
let command = PrintStyledContent(self.apply_to(val));
Ok(queue!(w, command)?)
I'm fixing it.
from termimad.
Awesome, thanks. I'll try it out.
from termimad.
Worked great! Now the docs view will updated when resized.
from termimad.
Oh, my CI build found a compile error on Windows:
error[E0382]: use of moved value: `val`
--> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/termimad-0.8.3/src/compound_style.rs:149:55
|
144 | pub fn queue<W, D>(&self, w: &mut W, val: D) -> Result<()>
| - --- move occurs because `val` has type `D`, which does not implement the `Copy` trait
| |
| consider adding a `Copy` constraint to this type argument
...
149 | Ok(queue!(w, PrintStyledContent(self.apply_to(val)))?)
| ^^^ value moved here, in previous iteration of loop
error: aborting due to previous error
from termimad.
That seems to mean that the Windows version of the queue!
doesn't accept non Copy
values.
That's weird because I didn't expect this to have changed between crossterm 0.13.3 and crossterm 0.14 and I guess we'll have to dive into the source of crossterm.
Problem is probably there: https://docs.rs/crossterm/0.14.0/src/crossterm/macros.rs.html#37
from termimad.
The val
should implement both Display
and Clone
. https://github.com/crossterm-rs/crossterm/blob/master/src/style/content_style.rs#L20, I am not sure how this relates to the queue
macro. It seems to be the problem of self.apply_to
or PrintStyledContent
. Can you perhaps try to call clone
on val
?
from termimad.
I confirm the problem is related to the macro. If I comment some part, there's no more compilation problem on windows:
/// Writes/executes the given command.
#[doc(hidden)]
#[macro_export]
macro_rules! handle_command {
($writer:expr, $command:expr) => {{
// Silent warning when the macro is used inside the `command` module
#[allow(unused_imports)]
use $crate::{write_ansi_code, Command};
#[cfg(windows)]
{
// // ansi code is not always a string, however it does implement `Display` and `Write`.
// // In order to check if the code is supported we have to make it a string.
// let ansi_code = format!("{}", $command.ansi_code());
//
// if $command.is_ansi_code_supported() {
// write_ansi_code!($writer, &ansi_code)
// } else {
$command.execute_winapi().map_err($crate::ErrorKind::from)
// }
}
#[cfg(unix)]
{
write_ansi_code!($writer, $command.ansi_code())
}
}};
}
At this point I'm not sure of how to fix it.
Should we clone the value when in Windows ? Should the argument have the Copy constraint on Windows ?
I'll propose we pursue the discussion on the crossterm discord: https://discordapp.com/channels/560857607196377088/560857607196377090
from termimad.
CI is happy again. Thanks. 👍 🎉
from termimad.
Related Issues (20)
- Cannot escape markdown characters HOT 5
- board creation returns 500 HOT 2
- Update to crossterm 0.20.0 HOT 5
- provide simple render as a binary HOT 5
- Termimad Parses some random text when used with TUI HOT 2
- Pass InputField into a MadSkin HOT 5
- example compile error on M1 mac
- Crossterm 0.25.0 breaking changes HOT 4
- Cannot compile inputs or render-input-markdown examples HOT 6
- Rendering inline code with newlines HOT 4
- Feature request: please add custom style syntax HOT 1
- Indented list rendering HOT 5
- How to render markdown dynamically in real time HOT 6
- How to render a code block that has new lines in it in one block. HOT 2
- Display fenced code block issue HOT 3
- Hyperlinks are not rendered correctly HOT 10
- Code blocks are 100 columns even if `Some(< 100)` is passed to `text` HOT 2
- "coloor" dependency introduces LGPL-3.0 HOT 4
- Lone newlines not interpreted as space HOT 1
- Incorrect handling of list entry text HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from termimad.