aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rwxr-xr-xsrc/main.rs71
1 files changed, 55 insertions, 16 deletions
diff --git a/src/main.rs b/src/main.rs
index 09c7363..3fbfc14 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,24 +1,63 @@
-mod cli;
-mod connection;
+#![allow(unused_imports)]
use clap::Parser;
-use cli::Args;
-use cli::Command;
-use connection::Connection;
+use rmptui::app;
+use rmptui::app::App;
+use rmptui::app::AppResult;
+use rmptui::cli::Args;
+use rmptui::cli::Command;
+use rmptui::connection::Connection;
+use rmptui::event::Event;
+use rmptui::event::EventHandler;
+use rmptui::handler;
+use rmptui::tui;
+use std::io;
-fn main() -> Result<(), Box<dyn std::error::Error>> {
- let args = Args::parse();
- let mut conn = Connection::new("127.0.0.1:6600")?;
+use crossterm::event::{self, KeyCode, KeyEvent, KeyEventKind};
+use ratatui::{
+ prelude::*,
+ symbols::border,
+ widgets::{block::*, *},
+};
- match args.command {
- Command::Volume { vol } => {
- conn.set_volume(vol);
+pub type Result<T> = core::result::Result<T, Error>;
+pub type Error = Box<dyn std::error::Error>;
+
+fn main() -> AppResult<()> {
+ // let args = Args::parse();
+
+ // if args.no_tui {
+ // handle_tui()?;
+ // } else {
+ // match args.command {
+ // Command::Volume { vol } => {
+ // conn.set_volume(vol);
+ // }
+ // Command::Dmenu => conn.play_dmenu().unwrap(),
+ // Command::Fzf => conn.play_fzf().unwrap(),
+ // Command::Status => conn.status(),
+ // Command::Pause => conn.pause(),
+ // Command::Toggle => conn.toggle_pause(),
+ // };
+ // }
+
+ let backend = CrosstermBackend::new(io::stderr());
+ let terminal = Terminal::new(backend)?;
+ let mut app = App::new("127.0.0.1:6600");
+ let events = EventHandler::new(250);
+
+ let mut tui = tui::Tui::new(terminal, events);
+ tui.init()?;
+
+ while app.running {
+ tui.draw(&mut app)?;
+ match tui.events.next()? {
+ Event::Tick => app.tick(),
+ Event::Key(key_event) => handler::handle_key_events(key_event, &mut app)?,
+ Event::Mouse(_) => {}
+ Event::Resize(_, _) => {}
}
- Command::Dmenu => conn.play_dmenu(),
- Command::Fzf => conn.play_fzf(),
- Command::Status => conn.status(),
- Command::Pause => conn.pause(),
- Command::Toggle => conn.toggle_pause(),
}
+
Ok(())
}