Skip to content

Commit

Permalink
Fix logging, fix cursor rendering in wall of block, fix no search sug…
Browse files Browse the repository at this point in the history
…gestions
  • Loading branch information
nick42d committed Nov 22, 2024
1 parent 1dd8f06 commit 1ae6431
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions youtui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions youtui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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(())
}
5 changes: 4 additions & 1 deletion youtui/src/app/ui/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ impl Browser {
}
pub async fn async_update(&mut self) -> StateMutationBundle<Self> {
// 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.
Expand Down
2 changes: 1 addition & 1 deletion youtui/src/app/ui/browser/artistalbums/artistsearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct SearchBlock {
pub search_contents: TextInputState,
pub search_suggestions: Vec<SearchSuggestion>,
pub suggestions_cur: Option<usize>,
async_tx: AsyncCallbackSender<ArcServer, Self, TaskMetadata>,
pub async_tx: AsyncCallbackSender<ArcServer, Self, TaskMetadata>,
}

#[derive(Clone, Debug, PartialEq)]
Expand Down
21 changes: 14 additions & 7 deletions youtui/src/app/ui/browser/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
};
Expand Down

0 comments on commit 1ae6431

Please sign in to comment.