mirror of
https://github.com/itsjunetime/tdf.git
synced 2026-06-01 23:51:46 -04:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3026cbce32 | |||
| a4c04c71b6 |
@@ -11,6 +11,7 @@ on:
|
|||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
tip_release_path: RELEASE.md
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-build:
|
test-build:
|
||||||
@@ -106,3 +107,39 @@ jobs:
|
|||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
files: release-artifacts/*
|
files: release-artifacts/*
|
||||||
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
|
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
|
||||||
|
|
||||||
|
tip-release:
|
||||||
|
name: Release tip on push to main
|
||||||
|
runs-on: ubuntu-slim
|
||||||
|
if: github.event_name == 'push' && github.ref_name == 'main'
|
||||||
|
needs: test-build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- name: Download prebuilt artifacts
|
||||||
|
uses: actions/download-artifact@v7
|
||||||
|
with:
|
||||||
|
path: release-artifacts
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
|
- name: Generate release notes
|
||||||
|
run: |
|
||||||
|
tree release-artifacts/
|
||||||
|
echo "From commit: $(git rev-parse --short HEAD)" > ${{ env.tip_release_path }}
|
||||||
|
echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> ${{ env.tip_release_path }}
|
||||||
|
cat ${{ env.tip_release_path }}
|
||||||
|
|
||||||
|
- name: Update the tip tag
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
git tag --force tip && git push --force origin tag tip
|
||||||
|
|
||||||
|
- name: Update the draft tip release
|
||||||
|
uses: softprops/action-gh-release@v2
|
||||||
|
with:
|
||||||
|
prerelease: true
|
||||||
|
files: release-artifacts/*
|
||||||
|
tag_name: tip
|
||||||
|
name: Tip Build
|
||||||
|
body_path: ${{ env.tip_release_path }}
|
||||||
|
|||||||
+1
-1
Submodule ratatui-image updated: 8ad154a219...a276a87cb8
+16
-23
@@ -1,12 +1,11 @@
|
|||||||
use std::{
|
use std::{
|
||||||
io::Cursor,
|
|
||||||
num::NonZeroUsize,
|
num::NonZeroUsize,
|
||||||
time::{SystemTime, UNIX_EPOCH}
|
time::{SystemTime, UNIX_EPOCH}
|
||||||
};
|
};
|
||||||
|
|
||||||
use flume::{Receiver, SendError, Sender, TryRecvError};
|
use flume::{Receiver, SendError, Sender, TryRecvError};
|
||||||
use futures_util::stream::StreamExt as _;
|
use futures_util::stream::StreamExt as _;
|
||||||
use image::{DynamicImage, codecs::pnm::PnmDecoder};
|
use image::DynamicImage;
|
||||||
use kittage::{NumberOrId, action::NONZERO_ONE};
|
use kittage::{NumberOrId, action::NONZERO_ONE};
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use ratatui_image::{
|
use ratatui_image::{
|
||||||
@@ -112,26 +111,22 @@ pub async fn run_conversion_loop(
|
|||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
let decoder = PnmDecoder::new(Cursor::new(&page_info.img_data.pixels)).map_err(|e| {
|
let mut dyn_img = image::load_from_memory_with_format(
|
||||||
RenderError::Converting(format!(
|
&page_info.img_data.pixels,
|
||||||
"The image data provided from mupdf was not in pnm format ({e}); don't know how to convert"
|
image::ImageFormat::Pnm
|
||||||
))
|
)
|
||||||
})?;
|
.map_err(|e| RenderError::Converting(format!("Can't load image: {e}")))?;
|
||||||
|
|
||||||
// The image we get should always already be `ImageRgb8`, so this `into` shouldn't do any
|
match dyn_img {
|
||||||
// conversions or anything, but just in case some underlying detail of mupdf or image
|
DynamicImage::ImageRgb8(ref mut img) =>
|
||||||
// changes, we do the `into` instead of just `match + unreachable!()` to avoid panicking
|
for quad in &*page_info.result_rects {
|
||||||
let mut dyn_img = DynamicImage::from_decoder(decoder)
|
img.par_enumerate_pixels_mut()
|
||||||
.map_err(|e| RenderError::Converting(format!("Can't load image: {e}")))?
|
.filter(|(x, y, _)| {
|
||||||
.into_rgb8();
|
*x > quad.ul_x && *x < quad.lr_x && *y > quad.ul_y && *y < quad.lr_y
|
||||||
|
})
|
||||||
for quad in &*page_info.result_rects {
|
.for_each(|(_, _, px)| px.0[2] = px.0[2].saturating_sub(u8::MAX / 2));
|
||||||
dyn_img
|
},
|
||||||
.par_enumerate_pixels_mut()
|
_ => unreachable!()
|
||||||
.filter(|(x, y, _)| {
|
|
||||||
*x > quad.ul_x && *x < quad.lr_x && *y > quad.ul_y && *y < quad.lr_y
|
|
||||||
})
|
|
||||||
.for_each(|(_, _, px)| px.0[2] = px.0[2].saturating_sub(u8::MAX / 2));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let img_area = Rect {
|
let img_area = Rect {
|
||||||
@@ -141,8 +136,6 @@ pub async fn run_conversion_loop(
|
|||||||
y: 0
|
y: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
let dyn_img = DynamicImage::ImageRgb8(dyn_img);
|
|
||||||
|
|
||||||
let txt_img = match picker.protocol_type() {
|
let txt_img = match picker.protocol_type() {
|
||||||
ProtocolType::Kitty => {
|
ProtocolType::Kitty => {
|
||||||
let rn = SystemTime::now()
|
let rn = SystemTime::now()
|
||||||
|
|||||||
Reference in New Issue
Block a user