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 anyhow::Result;
|
||||||
use base64::{engine::general_purpose, Engine};
|
use base64::{engine::general_purpose, Engine};
|
||||||
|
|
@ -33,8 +36,6 @@ impl Iterm2 {
|
||||||
|
|
||||||
async fn encode(img: DynamicImage) -> Result<Vec<u8>> {
|
async fn encode(img: DynamicImage) -> Result<Vec<u8>> {
|
||||||
tokio::task::spawn_blocking(move || {
|
tokio::task::spawn_blocking(move || {
|
||||||
let size = (img.width(), img.height());
|
|
||||||
|
|
||||||
let mut jpg = vec![];
|
let mut jpg = vec![];
|
||||||
JpegEncoder::new_with_quality(&mut jpg, 75).encode_image(&img)?;
|
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{}",
|
"{}]1337;File=inline=1;size={};width={}px;height={}px;doNotMoveCursor=1:{}\x07{}",
|
||||||
START,
|
START,
|
||||||
jpg.len(),
|
jpg.len(),
|
||||||
size.0,
|
img.width(),
|
||||||
size.1,
|
img.height(),
|
||||||
general_purpose::STANDARD.encode(&jpg),
|
general_purpose::STANDARD.encode(&jpg),
|
||||||
CLOSE
|
CLOSE
|
||||||
)?;
|
)?;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue