From: Simon Tatham Date: Thu, 4 Jan 2024 12:16:22 +0000 (+0000) Subject: Fill in some fixed initial file positions. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=e785c57b8f4c09bfc9a5a5dfdd7f695511086e38;p=mastodonochrome.git 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! --- 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)) }