mirror of
https://github.com/talwat/lowfi
synced 2024-12-25 18:51:54 +00:00
feat: add minimalist flag
This commit is contained in:
parent
8f805d7119
commit
baa2e095d9
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -982,7 +982,7 @@ checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "lowfi"
|
||||
version = "1.3.4"
|
||||
version = "1.3.5"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"arc-swap",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lowfi"
|
||||
version = "1.3.4"
|
||||
version = "1.3.5"
|
||||
edition = "2021"
|
||||
description = "An extremely simple lofi player."
|
||||
license = "MIT"
|
||||
|
@ -13,6 +13,10 @@ struct Args {
|
||||
#[clap(long, short)]
|
||||
alternate: bool,
|
||||
|
||||
/// Whether to hide the bottom control bar.
|
||||
#[clap(long, short)]
|
||||
minimalist: bool,
|
||||
|
||||
/// The command that was ran.
|
||||
/// This is [None] if no command was specified.
|
||||
#[command(subcommand)]
|
||||
|
@ -57,7 +57,7 @@ lazy_static! {
|
||||
///
|
||||
/// `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.
|
||||
async fn interface(player: Arc<Player>) -> eyre::Result<()> {
|
||||
async fn interface(player: Arc<Player>, minimalist: bool) -> eyre::Result<()> {
|
||||
loop {
|
||||
let action = components::action(&player, WIDTH);
|
||||
|
||||
@ -78,8 +78,17 @@ async fn interface(player: Arc<Player>) -> eyre::Result<()> {
|
||||
|
||||
let controls = components::controls(WIDTH);
|
||||
|
||||
let menu = if minimalist {
|
||||
vec![action, middle]
|
||||
} else {
|
||||
vec![action, middle, controls]
|
||||
};
|
||||
|
||||
// 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!(
|
||||
stdout(),
|
||||
@ -89,7 +98,7 @@ async fn interface(player: Arc<Player>) -> eyre::Result<()> {
|
||||
Print(menu.join("")),
|
||||
Print(format!("└{}┘", "─".repeat(WIDTH + 2))),
|
||||
MoveToColumn(0),
|
||||
MoveUp(4)
|
||||
MoveUp(menu.len() as u16 + 1)
|
||||
)?;
|
||||
|
||||
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 {
|
||||
let event::Event::Key(event) = event::read()? else {
|
||||
|
Loading…
Reference in New Issue
Block a user