Basic ratatui init
This commit is contained in:
parent
6be3634fdf
commit
4889026749
4 changed files with 19 additions and 8 deletions
12
src/main.rs
12
src/main.rs
|
@ -16,7 +16,6 @@ fn init() -> Result<Receiver<utils::Error>, utils::Error> {
|
||||||
audio::init(settings.clone(), error_in.clone(), player_events_in.clone())?;
|
audio::init(settings.clone(), error_in.clone(), player_events_in.clone())?;
|
||||||
let api_event_chan =
|
let api_event_chan =
|
||||||
ssonic::init(settings.clone(), error_in.clone(), player_events_in.clone())?;
|
ssonic::init(settings.clone(), error_in.clone(), player_events_in.clone())?;
|
||||||
std::thread::sleep(std::time::Duration::from_secs(5));
|
|
||||||
let mut player = player::init(
|
let mut player = player::init(
|
||||||
settings.clone(),
|
settings.clone(),
|
||||||
audio_event_chan,
|
audio_event_chan,
|
||||||
|
@ -29,11 +28,18 @@ fn init() -> Result<Receiver<utils::Error>, utils::Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
match init() {
|
let err_chan = match init() {
|
||||||
Err(x) => {
|
Err(x) => {
|
||||||
eprintln!("{}", x);
|
eprintln!("{}", x);
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
Ok(_) => exit(0),
|
Ok(err_chan) => err_chan,
|
||||||
};
|
};
|
||||||
|
match err_chan.recv() {
|
||||||
|
Err(_) => exit(0),
|
||||||
|
Ok(err) => {
|
||||||
|
eprintln!("{}", err);
|
||||||
|
exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ use super::Player;
|
||||||
|
|
||||||
impl Player {
|
impl Player {
|
||||||
pub fn begin(&mut self) -> Result<(), Error> {
|
pub fn begin(&mut self) -> Result<(), Error> {
|
||||||
unimplemented!()
|
std::thread::sleep(std::time::Duration::from_secs(5));
|
||||||
|
ratatui::restore();
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,15 @@ use std::sync::{
|
||||||
Arc,
|
Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use ratatui::DefaultTerminal;
|
||||||
|
|
||||||
use crate::{audio::AudioEvent, config::Settings, ssonic::APIEvent, utils::Error};
|
use crate::{audio::AudioEvent, config::Settings, ssonic::APIEvent, utils::Error};
|
||||||
|
|
||||||
pub struct PlayerEvent {}
|
pub struct PlayerEvent {}
|
||||||
|
|
||||||
pub struct Player {}
|
pub struct Player {
|
||||||
|
terminal: DefaultTerminal,
|
||||||
|
}
|
||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
settings: Arc<Settings>,
|
settings: Arc<Settings>,
|
||||||
|
@ -16,7 +20,8 @@ pub fn init(
|
||||||
error_chan: Sender<Error>,
|
error_chan: Sender<Error>,
|
||||||
player_chan: Receiver<PlayerEvent>,
|
player_chan: Receiver<PlayerEvent>,
|
||||||
) -> Result<Player, Error> {
|
) -> Result<Player, Error> {
|
||||||
unimplemented!()
|
let mut terminal = ratatui::init();
|
||||||
|
Ok(Player { terminal })
|
||||||
}
|
}
|
||||||
|
|
||||||
mod begin;
|
mod begin;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::io::Read;
|
|
||||||
|
|
||||||
use reqwest::{blocking::Response, header::ACCEPT};
|
use reqwest::{blocking::Response, header::ACCEPT};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue