mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
adaptor/src/iterm2.rs: optimize code readability
This commit is contained in:
parent
df0cb36d41
commit
0d5c0eee8e
1 changed files with 6 additions and 5 deletions
|
|
@ -1,4 +1,7 @@
|
|||
use std::{io::{stdout, BufWriter, Write}, path::Path};
|
||||
use std::{
|
||||
io::{stdout, BufWriter, Write},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use anyhow::Result;
|
||||
use base64::{engine::general_purpose, Engine};
|
||||
|
|
@ -33,8 +36,6 @@ impl Iterm2 {
|
|||
|
||||
async fn encode(img: DynamicImage) -> Result<Vec<u8>> {
|
||||
tokio::task::spawn_blocking(move || {
|
||||
let size = (img.width(), img.height());
|
||||
|
||||
let mut jpg = vec![];
|
||||
JpegEncoder::new_with_quality(&mut jpg, 75).encode_image(&img)?;
|
||||
|
||||
|
|
@ -44,8 +45,8 @@ impl Iterm2 {
|
|||
"{}]1337;File=inline=1;size={};width={}px;height={}px;doNotMoveCursor=1:{}\x07{}",
|
||||
START,
|
||||
jpg.len(),
|
||||
size.0,
|
||||
size.1,
|
||||
img.width(),
|
||||
img.height(),
|
||||
general_purpose::STANDARD.encode(&jpg),
|
||||
CLOSE
|
||||
)?;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue