diff --git a/Cargo.lock b/Cargo.lock index b4cafdd..c19786f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4696,6 +4696,7 @@ dependencies = [ "futures", "gag", "itertools 0.13.0", + "log", "rat-text", "ratatui", "rodio", diff --git a/youtui/Cargo.toml b/youtui/Cargo.toml index 9704c08..cc691ce 100644 --- a/youtui/Cargo.toml +++ b/youtui/Cargo.toml @@ -39,6 +39,7 @@ itertools = "0.13.0" tokio-stream = "0.1.16" async_cell = "0.2.2" bytes = "1.8.0" +log = "0.4.22" [dependencies.rusty_ytdl] # version = "0.7.4" diff --git a/youtui/src/app.rs b/youtui/src/app.rs index 3d30c36..7066700 100644 --- a/youtui/src/app.rs +++ b/youtui/src/app.rs @@ -7,6 +7,7 @@ use crossterm::{ execute, terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen}, }; +use log::LevelFilter; use ratatui::{backend::CrosstermBackend, Terminal}; use server::{Server, TaskMetadata}; use std::borrow::Cow; @@ -210,6 +211,7 @@ fn init_tracing(debug: bool) -> Result<()> { .with(tui_logger_layer.and_then(log_file_layer)) .with(context_layer) .init(); + tui_logger::init_logger(LevelFilter::Debug); info!("Started in debug mode, logging to {:?}.", log_file_name); } else { // TODO: Confirm if this filter is correct. @@ -219,6 +221,7 @@ fn init_tracing(debug: bool) -> Result<()> { .with(tui_logger_layer) .with(context_layer) .init(); + tui_logger::init_logger(LevelFilter::Debug); } Ok(()) } diff --git a/youtui/src/app/ui/browser.rs b/youtui/src/app/ui/browser.rs index 0708f37..a7655d9 100644 --- a/youtui/src/app/ui/browser.rs +++ b/youtui/src/app/ui/browser.rs @@ -267,7 +267,10 @@ impl Browser { } pub async fn async_update(&mut self) -> StateMutationBundle { // TODO: Size - self.async_tx.get_next_mutations(10).await + tokio::select! { + browser = self.async_tx.get_next_mutations(10) => browser, + search = self.artist_list.search.async_tx.get_next_mutations(10) => search.map(|b: &mut Self| &mut b.artist_list.search), + } } fn left(&mut self) { // Doesn't consider previous routing. diff --git a/youtui/src/app/ui/browser/artistalbums/artistsearch.rs b/youtui/src/app/ui/browser/artistalbums/artistsearch.rs index 9296258..36b5f10 100644 --- a/youtui/src/app/ui/browser/artistalbums/artistsearch.rs +++ b/youtui/src/app/ui/browser/artistalbums/artistsearch.rs @@ -41,7 +41,7 @@ pub struct SearchBlock { pub search_contents: TextInputState, pub search_suggestions: Vec, pub suggestions_cur: Option, - async_tx: AsyncCallbackSender, + pub async_tx: AsyncCallbackSender, } #[derive(Clone, Debug, PartialEq)] diff --git a/youtui/src/app/ui/browser/draw.rs b/youtui/src/app/ui/browser/draw.rs index 1dfcdda..8ef3bd0 100644 --- a/youtui/src/app/ui/browser/draw.rs +++ b/youtui/src/app/ui/browser/draw.rs @@ -120,14 +120,21 @@ fn draw_text_box( contents: &mut TextInputState, chunk: Rect, ) { + let block_widget = Block::default() + .borders(Borders::ALL) + .border_style(Style::default().fg(SELECTED_BORDER_COLOUR)) + .title(title.as_ref()); + let text_chunk = block_widget.inner(chunk); + let text_chunk = Rect { + x: text_chunk.x, + y: text_chunk.y, + width: text_chunk.width.saturating_sub(1), + height: text_chunk.height, + }; // TODO: Scrolling, if input larger than box. - let text_widget = TextInput::new().block( - Block::default() - .borders(Borders::ALL) - .border_style(Style::default().fg(SELECTED_BORDER_COLOUR)) - .title(title.as_ref()), - ); - f.render_stateful_widget(text_widget, chunk, contents); + let text_widget = TextInput::new(); + f.render_widget(block_widget, chunk); + f.render_stateful_widget(text_widget, text_chunk, contents); if let Some(cursor_pos) = contents.screen_cursor() { f.set_cursor_position(cursor_pos) };