Skip to content

Commit

Permalink
detect screen size change and rerender
Browse files Browse the repository at this point in the history
  • Loading branch information
Bluemi committed Jan 14, 2022
1 parent 253c06a commit f5fc744
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/musicus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub struct Musicus {
playing_song_info: Option<SongInfo>,
volume: i32,
follow: bool,
screen_dimensions: (i32, i32), // height, width
}

struct SongInfo {
Expand Down Expand Up @@ -94,6 +95,7 @@ impl Musicus {

// load playlists
let playlists = load_playlists();
let screen_dimensions = window.get_max_yx();

Musicus {
command_sender: audio_backend_sender,
Expand All @@ -110,6 +112,7 @@ impl Musicus {
playing_song_info: None,
volume: cache.volume,
follow: cache.follow,
screen_dimensions,
}
}

Expand Down Expand Up @@ -267,6 +270,11 @@ impl Musicus {

fn handle_input(&mut self, running: &mut bool) -> bool {
let mut got_valid_input = false;

if self.screen_dimensions != self.window.get_max_yx() {
self.screen_dimensions = self.window.get_max_yx();
got_valid_input = true;
}
if let Some(input) = self.window.getch() {
match input {
Input::Character(c) => {
Expand Down

0 comments on commit f5fc744

Please sign in to comment.