Skip to content

Commit

Permalink
opt: code format
Browse files Browse the repository at this point in the history
  • Loading branch information
Kingtous committed Jun 13, 2022
1 parent 817d63a commit d37026d
Show file tree
Hide file tree
Showing 23 changed files with 292 additions and 235 deletions.
5 changes: 3 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ use crate::{
music_board::{draw_music_board, MusicController},
radio::{draw_radio_list, RadioExplorer},
EventType,
}, util::m3u8::empty_cache,
},
util::m3u8::empty_cache,
};

pub enum InputMode {
Expand Down Expand Up @@ -165,7 +166,7 @@ impl App {
EventType::Radio => {
let radio = &mut self.radio;
radio.tick();
},
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright (C) 2022 Kingtous
//
//
// This file is part of RustPlayer.
//
//
// RustPlayer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// RustPlayer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.

Expand All @@ -31,4 +31,4 @@ impl Config {
home_page: "https://github.com/Kingtous",
}
}
}
}
14 changes: 8 additions & 6 deletions src/handler/help.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright (C) 2022 Kingtous
//
//
// This file is part of RustPlayer.
//
//
// RustPlayer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// RustPlayer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.

Expand All @@ -31,6 +31,8 @@ pub fn handle_help(app: &mut App, code: KeyCode) -> bool {
open::that(config_dir);
return true;
}
_ => {return false;}
_ => {
return false;
}
}
}
}
9 changes: 6 additions & 3 deletions src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ use crossterm::event::KeyCode;
use crate::app::{ActiveModules, App, Routes};

use self::{
fs::handle_fs, help::handle_help, music_controller::{handle_music_controller, handle_radio_controller},
player::{handle_player, handle_radio}, radio::handle_radio_fs,
fs::handle_fs,
help::handle_help,
music_controller::{handle_music_controller, handle_radio_controller},
player::{handle_player, handle_radio},
radio::handle_radio_fs,
};

mod fs;
Expand Down Expand Up @@ -95,7 +98,7 @@ pub fn handle_keyboard_event(app: &mut App, key: KeyCode) {
if flag {
return;
}
flag = handle_radio(app, key);
flag = handle_radio(app, key);
if flag {
return;
}
Expand Down
23 changes: 15 additions & 8 deletions src/handler/music_controller.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
// Copyright (C) 2022 Kingtous
//
//
// This file is part of RustPlayer.
//
//
// RustPlayer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// RustPlayer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.

use std::cmp::max;

use crossterm::event::KeyCode;

use crate::{app::{ActiveModules, App}, media::player::Player};
use crate::{
app::{ActiveModules, App},
media::player::Player,
};

pub fn handle_music_controller(app: &mut App, code: KeyCode) -> bool {
// if app.active_modules != ActiveModules::MusicController {
Expand All @@ -39,7 +42,9 @@ pub fn handle_music_controller(app: &mut App, code: KeyCode) -> bool {
player.next();
return true;
}
_ => {return false;}
_ => {
return false;
}
}
}

Expand All @@ -57,6 +62,8 @@ pub fn handle_radio_controller(app: &mut App, code: KeyCode) -> bool {
}
return true;
}
_ => {return false;}
_ => {
return false;
}
}
}
}
18 changes: 11 additions & 7 deletions src/handler/player.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright (C) 2022 Kingtous
//
//
// This file is part of RustPlayer.
//
//
// RustPlayer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// RustPlayer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.

Expand All @@ -35,7 +35,9 @@ pub fn handle_player(app: &mut App, code: KeyCode) -> bool {
app.player.set_volume(new_volume);
return true;
}
_ => {return false;}
_ => {
return false;
}
}
}

Expand All @@ -53,6 +55,8 @@ pub fn handle_radio(app: &mut App, code: KeyCode) -> bool {
app.radio.set_volume(new_volume);
return true;
}
_ => {return false;}
_ => {
return false;
}
}
}
}
20 changes: 10 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// Copyright (C) 2022 Kingtous
//
//
// This file is part of RustPlayer.
//
//
// RustPlayer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// RustPlayer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.

Expand All @@ -22,18 +22,18 @@ use ui::*;
use util::*;

mod app;
mod ui;
mod config;
mod handler;
mod media;
mod config;
mod ui;
mod util;

fn main() {
let mut app = App::new().unwrap();
match app.run() {
Ok(_) => {},
Ok(_) => {}
Err(e) => {
println!("{:?}",e);
},
println!("{:?}", e);
}
}
}
}
11 changes: 5 additions & 6 deletions src/media/media.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
// Copyright (C) 2022 Kingtous
//
//
// This file is part of RustPlayer.
//
//
// RustPlayer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// RustPlayer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.

use crate::ui::radio::RadioConfig;


pub enum Source {
Http(String),
M3u8(RadioConfig),
Expand All @@ -26,4 +25,4 @@ pub enum Source {

pub struct Media {
pub src: Source,
}
}
10 changes: 5 additions & 5 deletions src/media/mod.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// Copyright (C) 2022 Kingtous
//
//
// This file is part of RustPlayer.
//
//
// RustPlayer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// RustPlayer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.

pub mod media;
pub mod player;
pub mod media;
5 changes: 1 addition & 4 deletions src/media/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ use crate::{
app,
util::lyrics::{Lyric, Lyrics},
};
use crate::{
m3u8::download_m3u8_playlist,
util::{net::download_as_bytes},
};
use crate::{m3u8::download_m3u8_playlist, util::net::download_as_bytes};

use super::media::Media;

Expand Down
29 changes: 15 additions & 14 deletions src/ui/fs.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
// Copyright (C) 2022 Kingtous
//
//
// This file is part of RustPlayer.
//
//
// RustPlayer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// RustPlayer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with RustPlayer. If not, see <http://www.gnu.org/licenses/>.

use std::{fs, os};
use std::env::current_dir;
use std::fmt::{Debug, Display, Formatter};
use std::fs::{DirEntry, ReadDir};
use std::path::Path;
use std::{fs, os};

use crossterm::style::Colors;
use failure::{Error, Fail};
use tui::backend::Backend;
use tui::Frame;
use tui::layout::{Alignment, Constraint, Direction, Layout, Rect};
use tui::style::{Color, Style};
use tui::text::Text;
use tui::widgets::{Block, Borders, BorderType, List, ListItem, ListState, Paragraph, Widget, Wrap};
use tui::widgets::{
Block, BorderType, Borders, List, ListItem, ListState, Paragraph, Widget, Wrap,
};
use tui::Frame;

use crate::App;
use crate::app::ActiveModules;
use crate::App;

pub struct FsExplorer {
pub current_path: String,
Expand Down Expand Up @@ -161,16 +163,15 @@ where
draw_file_item(entry, &mut items);
}
let mut blk = Block::default()
.title("Explorer")
.title_alignment(Alignment::Center)
.borders(Borders::ALL).border_type(BorderType::Rounded);
.title("Explorer")
.title_alignment(Alignment::Center)
.borders(Borders::ALL)
.border_type(BorderType::Rounded);
if app.active_modules == ActiveModules::Fs {
blk = blk.border_style(Style::default().fg(Color::Cyan));
}
let file_list = List::new(items)
.block(
blk
)
.block(blk)
.highlight_style(Style::default().bg(Color::Cyan))
.highlight_symbol("> ");
frame.render_stateful_widget(file_list, fs_chunks[1], &mut fse.index);
Expand Down
Loading

0 comments on commit d37026d

Please sign in to comment.