feat: add minimalist flag

This commit is contained in:
talwat 2024-10-06 09:36:06 +02:00
parent 8f805d7119
commit baa2e095d9
4 changed files with 19 additions and 6 deletions

2
Cargo.lock generated
View File

@ -982,7 +982,7 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]] [[package]]
name = "lowfi" name = "lowfi"
version = "1.3.4" version = "1.3.5"
dependencies = [ dependencies = [
"Inflector", "Inflector",
"arc-swap", "arc-swap",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "lowfi" name = "lowfi"
version = "1.3.4" version = "1.3.5"
edition = "2021" edition = "2021"
description = "An extremely simple lofi player." description = "An extremely simple lofi player."
license = "MIT" license = "MIT"

View File

@ -13,6 +13,10 @@ struct Args {
#[clap(long, short)] #[clap(long, short)]
alternate: bool, alternate: bool,
/// Whether to hide the bottom control bar.
#[clap(long, short)]
minimalist: bool,
/// The command that was ran. /// The command that was ran.
/// This is [None] if no command was specified. /// This is [None] if no command was specified.
#[command(subcommand)] #[command(subcommand)]

View File

@ -57,7 +57,7 @@ lazy_static! {
/// ///
/// `volume_timer` is a bit strange, but it tracks how long the `volume` bar /// `volume_timer` is a bit strange, but it tracks how long the `volume` bar
/// has been displayed for, so that it's only displayed for a certain amount of frames. /// has been displayed for, so that it's only displayed for a certain amount of frames.
async fn interface(player: Arc<Player>) -> eyre::Result<()> { async fn interface(player: Arc<Player>, minimalist: bool) -> eyre::Result<()> {
loop { loop {
let action = components::action(&player, WIDTH); let action = components::action(&player, WIDTH);
@ -78,8 +78,17 @@ async fn interface(player: Arc<Player>) -> eyre::Result<()> {
let controls = components::controls(WIDTH); let controls = components::controls(WIDTH);
let menu = if minimalist {
vec![action, middle]
} else {
vec![action, middle, controls]
};
// Formats the menu properly // Formats the menu properly
let menu = [action, middle, controls].map(|x| format!("{}\r\n", x.reset()).to_string()); let menu: Vec<String> = menu
.into_iter()
.map(|x| format!("{}\r\n", x.reset()).to_string())
.collect();
crossterm::execute!( crossterm::execute!(
stdout(), stdout(),
@ -89,7 +98,7 @@ async fn interface(player: Arc<Player>) -> eyre::Result<()> {
Print(menu.join("")), Print(menu.join("")),
Print(format!("{}", "".repeat(WIDTH + 2))), Print(format!("{}", "".repeat(WIDTH + 2))),
MoveToColumn(0), MoveToColumn(0),
MoveUp(4) MoveUp(menu.len() as u16 + 1)
)?; )?;
sleep(Duration::from_secs_f32(FRAME_DELTA)).await; sleep(Duration::from_secs_f32(FRAME_DELTA)).await;
@ -117,7 +126,7 @@ pub async fn start(queue: Arc<Player>, sender: Sender<Messages>, args: Args) ->
)?; )?;
} }
task::spawn(interface(Arc::clone(&queue))); task::spawn(interface(Arc::clone(&queue), args.minimalist));
loop { loop {
let event::Event::Key(event) = event::read()? else { let event::Event::Key(event) = event::read()? else {