From: Ian Jackson Date: Tue, 6 Apr 2021 19:13:57 +0000 (+0100) Subject: otterlib: Show sort order in preview X-Git-Tag: otter-0.5.0~143 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=3312e60e364979b6b2b46f396b1adabf65758699;p=otter.git otterlib: Show sort order in preview Signed-off-by: Ian Jackson --- 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())?);
{}"#, Html::from_txt(&spec.item)); + if let Some(sortkey) = sortkey { + println!(r#"
[{}]"#, + Html::from_txt(sortkey)); + } println!(r#"
{}