From 3312e60e364979b6b2b46f396b1adabf65758699 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 6 Apr 2021 20:13:57 +0100 Subject: [PATCH] otterlib: Show sort order in preview Signed-off-by: Ian Jackson --- src/bin/otterlib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index 0483caa2..d9dd022e 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -70,6 +70,7 @@ fn preview(items: Vec) { struct Prep { spec: ItemSpec, + sortkey: Option, p: Box, uos: Vec, bbox: Vec>, @@ -91,6 +92,7 @@ fn preview(items: Vec) { let mut pieces: Vec = items.into_iter().map(|it| { let spec = ItemSpec { lib: it.0, item: it.1.itemname.into() }; + let sortkey = it.1.sortkey; (||{ let (p, _occultable) = spec.clone().find_load(&pcaliases) .context("load")?; @@ -113,7 +115,7 @@ fn preview(items: Vec) { .map(|(min,max)| max-min) .collect::>(); - Ok::<_,AE>(Prep { spec, p, uos, bbox, size }) + Ok::<_,AE>(Prep { spec, p, sortkey, uos, bbox, size }) })().with_context(|| format!("{:?}", &spec)) }).collect::,_>>()?; @@ -126,7 +128,7 @@ fn preview(items: Vec) { println!("{}", &HTML_PRELUDE); println!(r#""#); for s in &pieces { - let Prep { spec, p, uos, bbox, size } = s; + let Prep { spec, sortkey, p, uos, bbox, size } = s; macro_rules! println { ($($x:tt)*) => ({ @@ -141,6 +143,10 @@ fn preview(items: Vec) { Html::from_txt(&spec.lib)); println!(r#""#); println!(r#""#, p.describe_html(&GPiece::dummy(), &default())?); -- 2.30.2
{}"#, Html::from_txt(&spec.item)); + if let Some(sortkey) = sortkey { + println!(r#"
[{}]"#, + Html::from_txt(sortkey)); + } println!(r#"
{}