Krolyxon
Commit 05c4b17

rmptuisrcmain.rs

63 lines · 1.6 KB · Rust

1#![allow(unused_imports)]
2use clap::Parser;
3use rmptui::app;
4use rmptui::app::App;
5use rmptui::app::AppResult;
6use rmptui::cli::Args;
7use rmptui::cli::Command;
8use rmptui::connection::Connection;
9use rmptui::event::Event;
10use rmptui::event::EventHandler;
11use rmptui::handler;
12use rmptui::tui;
13use std::io;
14
15use crossterm::event::{self, KeyCode, KeyEvent, KeyEventKind};
16use ratatui::{
17 prelude::*,
18 symbols::border,
19 widgets::{block::*, *},
20};
21
22pub type Result<T> = core::result::Result<T, Error>;
23pub type Error = Box<dyn std::error::Error>;
24
25fn main() -> AppResult<()> {
26 // let args = Args::parse();
27
28 // if args.no_tui {
29 // handle_tui()?;
30 // } else {
31 // match args.command {
32 // Command::Volume { vol } => {
33 // conn.set_volume(vol);
34 // }
35 // Command::Dmenu => conn.play_dmenu().unwrap(),
36 // Command::Fzf => conn.play_fzf().unwrap(),
37 // Command::Status => conn.status(),
38 // Command::Pause => conn.pause(),
39 // Command::Toggle => conn.toggle_pause(),
40 // };
41 // }
42
43 let backend = CrosstermBackend::new(io::stderr());
44 let terminal = Terminal::new(backend)?;
45 let mut app = App::builder("127.0.0.1:6600")?;
46 let events = EventHandler::new(250);
47
48 let mut tui = tui::Tui::new(terminal, events);
49 tui.init()?;
50
51 while app.running {
52 tui.draw(&mut app)?;
53 match tui.events.next()? {
54 Event::Tick => app.tick(),
55 Event::Key(key_event) => handler::handle_key_events(key_event, &mut app)?,
56 Event::Mouse(_) => {}
57 Event::Resize(_, _) => {}
58 }
59 }
60
61
62 Ok(())
63}