mirror of
https://codeberg.org/JasterV/teatui.git
synced 2026-04-26 18:10:03 +00:00
release: 0.4.0
This commit is contained in:
parent
f32c6e9dd9
commit
29a16f368c
6 changed files with 15 additions and 15 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1162,7 +1162,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "teatui"
|
||||
version = "0.2.1"
|
||||
version = "0.3.0"
|
||||
dependencies = [
|
||||
"crossterm",
|
||||
"ratatui",
|
||||
|
|
|
|||
|
|
@ -101,14 +101,14 @@ pub fn update(model: Model, msg: Message) -> Update<Model, Effect> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn run_effects(_model: &Model, _effect: Effect) -> Option<Message> {
|
||||
pub fn run_effects(_model: Model, _effect: Effect) -> Option<Message> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Elm-like View function.
|
||||
///
|
||||
/// Given the current state (read-only), return a drawable widget.
|
||||
pub fn view(model: &Model) -> Paragraph<'static> {
|
||||
pub fn view(model: Model) -> Paragraph<'static> {
|
||||
let counter = model.counter;
|
||||
|
||||
let title = Line::from("Ratatui Actor-based Counter")
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "teatui"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
description = "An elm-like abstraction over Ratatui"
|
||||
license.workspace = true
|
||||
authors.workspace = true
|
||||
|
|
|
|||
|
|
@ -18,14 +18,14 @@ pub(crate) fn run<M, Msg, Eff, F>(
|
|||
) -> Result<(), EffectsError<Msg>>
|
||||
where
|
||||
Msg: Send + Sync + 'static,
|
||||
F: Fn(&M, Eff) -> Option<Msg>,
|
||||
F: Fn(M, Eff) -> Option<Msg>,
|
||||
{
|
||||
loop {
|
||||
let Ok((model, effect)) = rx.recv() else {
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
if let Some(msg) = effects_fn(&model, effect) {
|
||||
if let Some(msg) = effects_fn(model, effect) {
|
||||
tx.send(msg)?;
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ where
|
|||
Msg: Send + Sync + 'static,
|
||||
Eff: Send + Sync + 'static,
|
||||
Fut: Future<Output = Option<Msg>> + Send,
|
||||
F: Fn(&M, Eff) -> Fut + Send + Sync + 'static,
|
||||
F: Fn(M, Eff) -> Fut + Send + Sync + 'static,
|
||||
{
|
||||
let rt = tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
|
|
@ -56,7 +56,7 @@ where
|
|||
};
|
||||
|
||||
// We spawn the effect in the tokio reactor so they can run concurrently
|
||||
let fut = effects_fn(&model, effect);
|
||||
let fut = effects_fn(model, effect);
|
||||
|
||||
if let Some(msg) = fut.await {
|
||||
let _ = tx.send(msg);
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ where
|
|||
W: Widget,
|
||||
IF: Fn() -> (M, Option<Eff>) + Send + Sync + 'static,
|
||||
UF: Fn(M, Msg) -> Update<M, Eff> + Send + Sync + 'static,
|
||||
VF: Fn(&M) -> W + Send + Sync + 'static,
|
||||
EF: Fn(&M, Eff) -> Option<Msg> + Send + Sync + 'static,
|
||||
VF: Fn(M) -> W + Send + Sync + 'static,
|
||||
EF: Fn(M, Eff) -> Option<Msg> + Send + Sync + 'static,
|
||||
{
|
||||
run_program(init_fn, update_fn, view_fn, move |effects_rx, update_tx| {
|
||||
effects::run(effects_fn, effects_rx, update_tx)
|
||||
|
|
@ -110,8 +110,8 @@ where
|
|||
W: Widget,
|
||||
IF: Fn() -> (M, Option<Eff>) + Send + Sync + 'static,
|
||||
UF: Fn(M, Msg) -> Update<M, Eff> + Send + Sync + 'static,
|
||||
VF: Fn(&M) -> W + Send + Sync + 'static,
|
||||
EF: Fn(&M, Eff) -> Fut + Send + Sync + 'static,
|
||||
VF: Fn(M) -> W + Send + Sync + 'static,
|
||||
EF: Fn(M, Eff) -> Fut + Send + Sync + 'static,
|
||||
Fut: std::future::Future<Output = Option<Msg>> + Send,
|
||||
{
|
||||
run_program(init_fn, update_fn, view_fn, move |effects_rx, update_tx| {
|
||||
|
|
@ -133,7 +133,7 @@ where
|
|||
W: Widget,
|
||||
IF: Fn() -> (M, Option<Eff>) + Send + Sync + 'static,
|
||||
UF: Fn(M, Msg) -> Update<M, Eff> + Send + Sync + 'static,
|
||||
VF: Fn(&M) -> W + Send + Sync + 'static,
|
||||
VF: Fn(M) -> W + Send + Sync + 'static,
|
||||
SF: FnOnce(
|
||||
std::sync::mpsc::Receiver<(M, Eff)>,
|
||||
std::sync::mpsc::Sender<Msg>,
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ pub(crate) fn run<M, F, W>(
|
|||
) -> Result<(), ViewError>
|
||||
where
|
||||
W: Widget,
|
||||
F: Fn(&M) -> W,
|
||||
F: Fn(M) -> W,
|
||||
{
|
||||
loop {
|
||||
let widget = view_fn(&model);
|
||||
let widget = view_fn(model);
|
||||
|
||||
terminal.draw(|frame| frame.render_widget(widget, frame.area()))?;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue