refactor: move and add functions

This commit is contained in:
Thomas Frans
2023-05-27 19:08:45 +02:00
committed by Henrik Friedrichsen
parent 04cbe8ac20
commit c36d3cf272
9 changed files with 183 additions and 133 deletions

View File

@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::rc::Rc;
use std::time::{Duration, SystemTime};
use cursive::align::HAlign;
@@ -30,11 +31,11 @@ pub struct Layout {
screenchange: bool,
last_size: Vec2,
ev: events::EventManager,
theme: Theme,
theme: Rc<Theme>,
}
impl Layout {
pub fn new<T: IntoBoxedView>(status: T, ev: &events::EventManager, theme: Theme) -> Layout {
pub fn new<T: IntoBoxedView>(status: T, ev: &events::EventManager, theme: Rc<Theme>) -> Layout {
let style = ColorStyle::new(
ColorType::Color(*theme.palette.custom("cmdline_bg").unwrap()),
ColorType::Color(*theme.palette.custom("cmdline").unwrap()),

View File

@@ -1,3 +1,6 @@
use cursive::{Cursive, CursiveRunner};
use ncspot::BIN_NAME;
pub mod album;
pub mod artist;
pub mod browse;
@@ -19,3 +22,14 @@ pub mod tabview;
#[cfg(feature = "cover")]
pub mod cover;
/// Create a CursiveRunner which implements the drawing logic and event loop.
pub fn create_cursive() -> Result<CursiveRunner<Cursive>, Box<dyn std::error::Error>> {
let backend = cursive::backends::try_default()?;
let buffered_backend = Box::new(cursive_buffered_backend::BufferedBackend::new(backend));
let mut cursive_runner = CursiveRunner::new(cursive::Cursive::new(), buffered_backend);
cursive_runner.set_window_title(BIN_NAME);
Ok(cursive_runner)
}