From e785c57b8f4c09bfc9a5a5dfdd7f695511086e38 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 4 Jan 2024 12:16:22 +0000 Subject: [PATCH] Fill in some fixed initial file positions. Examine User and Post Info should start at the top, not the bottom, now that we have the ability to do that easily. And when you view the thread of a post, it makes sense to me to focus _that post_ to start with! --- src/file.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/file.rs b/src/file.rs index 9ef42c3..599775e 100644 --- a/src/file.rs +++ b/src/file.rs @@ -1217,7 +1217,8 @@ pub fn examine_user(client: &mut Client, account_id: &str) -> &format!("Information about user {username}"), 'H'); let file = File::::new( - client, StaticSource::singleton(ac.id), title, None)?; + client, StaticSource::singleton(ac.id), title, + Some(FilePosition::item_top(isize::MIN)))?; Ok(Box::new(file)) } @@ -1242,7 +1243,8 @@ pub fn view_single_post(client: &mut Client, status_id: &str) -> &format!("Information about post {}", st.id), 'H'); let file = File::::new( - client, StaticSource::singleton(st.id), title, None)?; + client, StaticSource::singleton(st.id), title, + Some(FilePosition::item_top(isize::MIN)))?; Ok(Box::new(file)) } @@ -1277,7 +1279,12 @@ pub fn view_thread(client: &mut Client, start_id: &str, full: bool) -> }; let title = ColouredString::uniform(&title, 'H'); + // Focus the id in question, assuming we can + let index = ids.iter().position(|x| x == start_id) + .map_or(isize::MIN, |u| u as isize); + let file = File::::new( - client, StaticSource::vector(ids), title, None)?; + client, StaticSource::vector(ids), title, + Some(FilePosition::item_top(index as isize)))?; Ok(Box::new(file)) } -- 2.30.2