fix: squash some small bugs
* Fix text not being wrapped for the blog in some cases * Make `App` not indefinitely block for `TerminalInfo` to be probed
This commit is contained in:
parent
3c089bbdc3
commit
f5fe0f52e6
2 changed files with 20 additions and 15 deletions
13
src/app.rs
13
src/app.rs
|
@ -139,11 +139,14 @@ impl App {
|
||||||
#[cfg(feature = "blog")]
|
#[cfg(feature = "blog")]
|
||||||
self.blog_posts.try_lock()?.register_config_handler(self.config.clone())?;
|
self.blog_posts.try_lock()?.register_config_handler(self.config.clone())?;
|
||||||
|
|
||||||
while let TerminalKind::Unsupported(UnsupportedReason::Unprobed) =
|
for _ in 1..50 {
|
||||||
self.terminal_info.blocking_read().kind()
|
if matches!(
|
||||||
{
|
self.terminal_info.blocking_read().kind(),
|
||||||
tracing::debug!("Waiting for terminal kind to be probed...");
|
TerminalKind::Unsupported(UnsupportedReason::Unprobed)
|
||||||
std::thread::sleep(Duration::from_millis(100));
|
) {
|
||||||
|
tracing::debug!("Waiting for 5s for terminal info to be probed");
|
||||||
|
std::thread::sleep(Duration::from_millis(100));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize components
|
// Initialize components
|
||||||
|
|
|
@ -36,7 +36,9 @@ impl BlogPosts {
|
||||||
font_size: DEFAULT_FONT_SIZE,
|
font_size: DEFAULT_FONT_SIZE,
|
||||||
protocol_type: ProtocolType::Halfblocks,
|
protocol_type: ProtocolType::Halfblocks,
|
||||||
background_color: Rgba([0, 0, 0, 0]),
|
background_color: Rgba([0, 0, 0, 0]),
|
||||||
is_tmux: false, // FIXME: any way to figure this out?
|
// NOTE: Multiplexers such as tmux are currently unsupported, we ensure that we have an
|
||||||
|
// xterm based terminal emulator in ssh.rs, if not, we reject the conection to begin with
|
||||||
|
is_tmux: false,
|
||||||
capabilities: vec![],
|
capabilities: vec![],
|
||||||
}),
|
}),
|
||||||
posts: posts_ref,
|
posts: posts_ref,
|
||||||
|
@ -107,9 +109,10 @@ impl Component for BlogPosts {
|
||||||
// safe to unwrap, guaranteed to not be `None`
|
// safe to unwrap, guaranteed to not be `None`
|
||||||
Action::Tick => {}
|
Action::Tick => {}
|
||||||
Action::Render => {}
|
Action::Render => {}
|
||||||
|
|
||||||
// FIXME: do we reload the image on every single render of a post?
|
|
||||||
Action::Quit | Action::PrevTab | Action::NextTab => self.in_post = (None, None),
|
Action::Quit | Action::PrevTab | Action::NextTab => self.in_post = (None, None),
|
||||||
|
|
||||||
|
// FIXME: This makes it possible to scroll through the list with arrow keys even
|
||||||
|
// when it is not rendered, which is not ideal; should probably fix later, minor bug
|
||||||
Action::Continue(post_id) => self.in_post.1 = post_id,
|
Action::Continue(post_id) => self.in_post.1 = post_id,
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
@ -131,7 +134,9 @@ impl Component for BlogPosts {
|
||||||
let post_body = post.title.clone().map_or(post.content.clone(), |title| {
|
let post_body = post.title.clone().map_or(post.content.clone(), |title| {
|
||||||
format!("# {}\n\n{}", title, post.content)
|
format!("# {}\n\n{}", title, post.content)
|
||||||
});
|
});
|
||||||
let post_content_text = tui_markdown::from_str(&post_body);
|
|
||||||
|
let post_body_widget =
|
||||||
|
Paragraph::new(tui_markdown::from_str(&post_body)).wrap(Wrap { trim: true });
|
||||||
|
|
||||||
// FIXME: content in the body often overlaps with the `Cat` component and gets
|
// FIXME: content in the body often overlaps with the `Cat` component and gets
|
||||||
// formatted weirdly. maybe deal with that at some point? real solution is probably a
|
// formatted weirdly. maybe deal with that at some point? real solution is probably a
|
||||||
|
@ -150,10 +155,7 @@ impl Component for BlogPosts {
|
||||||
.areas(image_area);
|
.areas(image_area);
|
||||||
|
|
||||||
frame.render_stateful_widget(StatefulImage::default(), image_area, img);
|
frame.render_stateful_widget(StatefulImage::default(), image_area, img);
|
||||||
frame.render_widget(
|
frame.render_widget(post_body_widget, text_area);
|
||||||
Paragraph::new(post_content_text).wrap(Wrap { trim: true }),
|
|
||||||
text_area,
|
|
||||||
);
|
|
||||||
} else if self.image_renderer.is_some() {
|
} else if self.image_renderer.is_some() {
|
||||||
// Image not cached, load image and skip rendering for current draw call
|
// Image not cached, load image and skip rendering for current draw call
|
||||||
if let Some(ref post_ogp) = post.ogp {
|
if let Some(ref post_ogp) = post.ogp {
|
||||||
|
@ -163,7 +165,7 @@ impl Component for BlogPosts {
|
||||||
self.in_post.0 = Some(img);
|
self.in_post.0 = Some(img);
|
||||||
} else {
|
} else {
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
post_content_text,
|
post_body_widget,
|
||||||
Rect::new(area.x + 1, area.y + 1, area.width, area.height),
|
Rect::new(area.x + 1, area.y + 1, area.width, area.height),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +184,7 @@ impl Component for BlogPosts {
|
||||||
);
|
);
|
||||||
|
|
||||||
frame.render_widget(
|
frame.render_widget(
|
||||||
post_content_text,
|
post_body_widget,
|
||||||
Rect::new(area.x + 3, area.y + 3, area.width, area.height),
|
Rect::new(area.x + 3, area.y + 3, area.width, area.height),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue