mirror of
https://github.com/youwen5/iamb.git
synced 2025-08-04 03:28:28 -07:00
Update to latest modalkit
, modalkit-ratatui
and ratatui-image
(#422)
This commit is contained in:
parent
5f927ce9c3
commit
af96bfbb41
5 changed files with 99 additions and 53 deletions
12
src/base.rs
12
src/base.rs
|
@ -1319,7 +1319,7 @@ fn emoji_map() -> CompletionMap<String, &'static Emoji> {
|
|||
|
||||
#[cfg(unix)]
|
||||
fn picker_from_termios(protocol_type: Option<ProtocolType>) -> Option<Picker> {
|
||||
let mut picker = match Picker::from_termios() {
|
||||
let mut picker = match Picker::from_query_stdio() {
|
||||
Ok(picker) => picker,
|
||||
Err(e) => {
|
||||
tracing::error!("Failed to setup image previews: {e}");
|
||||
|
@ -1327,12 +1327,8 @@ fn picker_from_termios(protocol_type: Option<ProtocolType>) -> Option<Picker> {
|
|||
},
|
||||
};
|
||||
|
||||
// `guess_protocol` also does tmux detection,
|
||||
// run it always then overwrite the guessed protocol if needed
|
||||
picker.guess_protocol();
|
||||
|
||||
if let Some(protocol_type) = protocol_type {
|
||||
picker.protocol_type = protocol_type;
|
||||
picker.set_protocol_type(protocol_type);
|
||||
}
|
||||
|
||||
Some(picker)
|
||||
|
@ -1355,8 +1351,8 @@ fn picker_from_settings(settings: &ApplicationSettings) -> Option<Picker> {
|
|||
}) = image_preview_protocol
|
||||
{
|
||||
// User forced type and font_size: use that.
|
||||
let mut picker = Picker::new(font_size);
|
||||
picker.protocol_type = protocol_type;
|
||||
let mut picker = Picker::from_fontsize(font_size);
|
||||
picker.set_protocol_type(protocol_type);
|
||||
Some(picker)
|
||||
} else {
|
||||
// Guess, but use type if forced.
|
||||
|
|
|
@ -70,7 +70,7 @@ mod printer;
|
|||
|
||||
pub use self::compose::text_to_message;
|
||||
|
||||
type ProtocolPreview<'a> = (&'a dyn Protocol, u16, u16);
|
||||
type ProtocolPreview<'a> = (&'a Protocol, u16, u16);
|
||||
|
||||
pub type MessageKey = (MessageTimeStamp, OwnedEventId);
|
||||
|
||||
|
@ -826,7 +826,7 @@ impl<'a> MessageFormatter<'a> {
|
|||
pub enum ImageStatus {
|
||||
None,
|
||||
Downloading(ImagePreviewSize),
|
||||
Loaded(Box<dyn Protocol>),
|
||||
Loaded(Protocol),
|
||||
Error(String),
|
||||
}
|
||||
|
||||
|
@ -1046,7 +1046,7 @@ impl Message {
|
|||
style: Style,
|
||||
hide_reply: bool,
|
||||
emoji_shortcodes: bool,
|
||||
) -> (Text, Option<&dyn Protocol>) {
|
||||
) -> (Text, Option<&Protocol>) {
|
||||
if let Some(html) = &self.html {
|
||||
(html.to_text(width, style, hide_reply, emoji_shortcodes), None)
|
||||
} else {
|
||||
|
@ -1066,8 +1066,8 @@ impl Message {
|
|||
placeholder_frame(Some("Downloading..."), width, image_preview_size)
|
||||
},
|
||||
ImageStatus::Loaded(backend) => {
|
||||
proto = Some(backend.as_ref());
|
||||
placeholder_frame(Some("Loading..."), width, &backend.rect().into())
|
||||
proto = Some(backend);
|
||||
placeholder_frame(Some("Loading..."), width, &backend.area().into())
|
||||
},
|
||||
ImageStatus::Error(err) => Some(format!("[Image error: {err}]\n")),
|
||||
};
|
||||
|
|
|
@ -1402,7 +1402,7 @@ impl<'a> StatefulWidget for Scrollback<'a> {
|
|||
// line.
|
||||
for (x, y, backend) in image_previews {
|
||||
let image_widget = Image::new(backend);
|
||||
let mut rect = backend.rect();
|
||||
let mut rect = backend.area();
|
||||
rect.x = x;
|
||||
rect.y = y;
|
||||
// Don't render outside of scrollback area
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue