lotabout.skim/examples/fine-grain.rs
LoricAndre bb6c03f377
feat: reduce binary size by removing uncommon image formats and color_eyre (#1118)
* Shrink binary: trim image decoders and swap color-eyre for eyre

Two dependency changes that cut the default `sk` binary from 13.6 MiB to
8.55 MiB (-5.06 MiB, -37%) with no loss of core functionality:

- image: build the `image` crate with only the common decoders (png,
  jpeg, gif, webp) instead of its full default format set, and drop
  ratatui-image's `image-defaults`. This removes AVIF encoding (ravif,
  avif-serialize), OpenEXR (exr), TIFF, QOI and other decoders that are
  irrelevant to terminal image previews. Previewing those formats now
  falls back to the normal command preview.

- error handling: replace color-eyre with plain eyre. color-eyre only
  provided colored panic/error backtraces; skim used none of its
  Section/Help extension APIs. This drops the backtrace/gimli/addr2line/
  color-spantrace stack. `color_eyre::install()` is no longer needed.

Tests, benches and examples are migrated from color_eyre to eyre so the
crate is fully removed from the dependency graph.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQtxeCS4gM7dumghqmNgST

* chore: fmt

* docs: ARCHITECTURE.md

* chore(flake): add cargo-bloat

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-17 17:29:43 +00:00

37 lines
991 B
Rust

//! Demonstrates fine-grained control over skim lifecycle events.
extern crate skim;
use eyre::Result;
use skim::prelude::*;
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<()> {
let options = SkimOptionsBuilder::default().height("50%").multi(true).build()?;
let (tx_item, rx_item): (SkimItemSender, SkimItemReceiver) = unbounded();
let mut skim = Skim::init(options, Some(rx_item))?;
skim.start();
skim.init_tui()?;
let event_tx = skim.event_sender();
skim.enter().await?;
let output = skim
.run_until(async move {
for i in 1..=10 {
let _ = event_tx.try_send(Event::ClearItems);
let _ = tx_item.send(vec![Arc::new(format!("item {i}")) as Arc<dyn SkimItem>]);
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
})
.await?;
for item in &output.selected_items {
println!("{}", item.output());
}
Ok(())
}