From f32b6a19851b8b103ac843503ab008197f0639cd Mon Sep 17 00:00:00 2001
From: lukeflo
Date: Thu, 24 Oct 2024 12:53:09 +0200
Subject: rearrange code again, prepare for command-action setup
---
src/tui.rs | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
(limited to 'src/tui.rs')
diff --git a/src/tui.rs b/src/tui.rs
index 83d0b13..7b8b81f 100644
--- a/src/tui.rs
+++ b/src/tui.rs
@@ -15,12 +15,12 @@
// along with this program. If not, see .
/////
-pub mod app;
pub mod command;
+pub mod commandnew;
pub mod handler;
pub mod ui;
-use crate::tui::app::App;
+use crate::App;
use crossterm::{
cursor,
event::{
@@ -59,9 +59,9 @@ pub struct Tui {
/// Interface to the Terminal.
pub terminal: ratatui::Terminal>,
/// Event sender channel.
- sender: mpsc::UnboundedSender,
+ evt_sender: mpsc::UnboundedSender,
/// Event receiver channel.
- receiver: mpsc::UnboundedReceiver,
+ evt_receiver: mpsc::UnboundedReceiver,
/// Event handler thread.
handler: tokio::task::JoinHandle<()>,
cancellation_token: CancellationToken,
@@ -71,13 +71,13 @@ impl Tui {
// Constructs a new instance of [`Tui`].
pub fn new() -> Result {
let terminal = ratatui::Terminal::new(CrosstermBackend::new(stdout()))?;
- let (sender, receiver) = mpsc::unbounded_channel();
+ let (evt_sender, evt_receiver) = mpsc::unbounded_channel();
let handler = tokio::spawn(async {});
let cancellation_token = CancellationToken::new();
Ok(Self {
terminal,
- sender,
- receiver,
+ evt_sender,
+ evt_receiver,
handler,
cancellation_token,
})
@@ -88,7 +88,7 @@ impl Tui {
self.cancel();
self.cancellation_token = CancellationToken::new();
let event_loop = Self::event_loop(
- self.sender.clone(),
+ self.evt_sender.clone(),
self.cancellation_token.clone(),
tick_rate,
);
@@ -203,7 +203,10 @@ impl Tui {
}
pub async fn next(&mut self) -> Result {
- self.receiver.recv().await.ok_or_eyre("This is an IO error")
+ self.evt_receiver
+ .recv()
+ .await
+ .ok_or_eyre("This is an IO error")
}
}
--
cgit v1.2.3