chiark / gitweb /
mastodonochrome.git
16 months agoPersist the latest read item in the Tui.
Simon Tatham [Sat, 6 Jan 2024 13:34:04 +0000 (13:34 +0000)]
Persist the latest read item in the Tui.

Now it's used to set the initial position when File is constructed,
but there's still no actual effect, because the _position_ from the
last File instance on that feed still takes precedence, and we never
save anything into the Tui without one of those.

16 months agoTrack the latest read item within File's lifetime.
Simon Tatham [Sat, 6 Jan 2024 11:32:09 +0000 (11:32 +0000)]
Track the latest read item within File's lifetime.

Nothing actually uses it yet.

16 months agoMake FileContents store the item ids.
Simon Tatham [Sat, 6 Jan 2024 11:58:18 +0000 (11:58 +0000)]
Make FileContents store the item ids.

This allows it to also search for the index of a specific item.

16 months agoAppend \n when we write out a JSON file.
Simon Tatham [Sat, 6 Jan 2024 13:10:38 +0000 (13:10 +0000)]
Append \n when we write out a JSON file.

I just happened to notice that serde_json::to_string_pretty makes the
result pretty in every way except this one.

16 months agoFix clipping of initial file positions.
Simon Tatham [Sat, 6 Jan 2024 11:57:40 +0000 (11:57 +0000)]
Fix clipping of initial file positions.

It's not enough to just modify the item index - we also have to reset
the line number.

16 months agoWrite configuration files atomically.
Simon Tatham [Fri, 5 Jan 2024 23:35:28 +0000 (23:35 +0000)]
Write configuration files atomically.

This is generally good practice, and clears away a prerequisite for
constantly updating an LDB.

16 months agoApply many uncontroversial style fixes from Clippy.
Simon Tatham [Sat, 6 Jan 2024 00:23:00 +0000 (00:23 +0000)]
Apply many uncontroversial style fixes from Clippy.

I ran 'cargo clippy fix', picked out the changes I didn't disagree
with, and reformatted a few overlong lines that resulted. It's a
combination of redundant clones and borrows, what Clippy considers to
be the antipattern of assert_eq!(boolean, true), and failure to use
the full vocabulary of standard methods like Option::is_none,
Result::is_ok, and the various and_then() or map() etc combinators.

16 months agoClippy fix: borrow the HashMap Entry we want to insert into.
Simon Tatham [Fri, 5 Jan 2024 23:31:21 +0000 (23:31 +0000)]
Clippy fix: borrow the HashMap Entry we want to insert into.

I hadn't known about this method of HashMap at all: you can test
whether a key exists, in such a way that you also get a reference to
the slot you'd want to insert it into if it didn't. Then you don't
need the two hash lookups you would with the more obvious approach of
separately testing for contains_key and then maybe inserting.

16 months agoClippy fix: use write_all to beep.
Simon Tatham [Fri, 5 Jan 2024 22:59:08 +0000 (22:59 +0000)]
Clippy fix: use write_all to beep.

Clippy complains that I used stdout().write(), and although I checked
the error code, I didn't also check whether it had written the full
buffer or only part of it.

But it didn't notice that the buffer was one byte long!

16 months agoClippy fix: rename Config::default().
Simon Tatham [Sat, 6 Jan 2024 08:50:12 +0000 (08:50 +0000)]
Clippy fix: rename Config::default().

Calling it that, Clippy complains that it looks too much like the
method of the Default trait, and suggests I either impl Default or
rename the method. For the moment, I'll rename the method; I don't
know that I have a good use for impl Default right now.

16 months agoFix that horrible loop in the streaming subthread.
Simon Tatham [Fri, 5 Jan 2024 22:55:13 +0000 (22:55 +0000)]
Fix that horrible loop in the streaming subthread.

Clippy complained about it at fatal-error level because it never loops
more than once. I only wrote that loop so I could break it in multiple
places with different return values.

But I've had a better idea for how to write the fiddly bit, thanks to
remembering that Peekable is a thing. This is nicer.

16 months agoEditor: fix handling of abutting scan matches.
Simon Tatham [Fri, 5 Jan 2024 22:26:37 +0000 (22:26 +0000)]
Editor: fix handling of abutting scan matches.

My example test of '#hashtag@mention' _shouldn't_ have highlighted the
mention, because the word character before the @ disqualifies it. But
I was doing the matching on a slice of the string, instead of giving
get_span the whole string and telling it where to start from.

That in turn was because I hadn't bothered to give get_span that
argument. But it's really easy to add! Now done.

16 months agoFix inconsistent colour of visibility keywords.
Simon Tatham [Fri, 5 Jan 2024 22:17:59 +0000 (22:17 +0000)]
Fix inconsistent colour of visibility keywords.

In DetailedStatusDisplay I still had "unlisted" as red, whereas I'd
changed my mind elsewhere.

The easiest fix is to use an actual VisibilityLine object, removing
one place I have to make all these things agree.

16 months agoSupport listing the URLs in a post.
Simon Tatham [Fri, 5 Jan 2024 14:09:59 +0000 (14:09 +0000)]
Support listing the URLs in a post.

I didn't have to trawl RcDom after all (as my TODO item suggested).
All I had to do was to put a mutable reference to a Vec<String> into
OurDecorator, and then that could push URLs on to the vector.

Or rather: firstly I had to do that using a &RefCell<Vec<String>>,
because the same Vec<String> reference had to be passed to the
separate decorator instance spawned for sub-blocks. Secondly that
meant I had to bake a lifetime into the type of OurDecorator (since
the call site must know that the reference to the RefCell went away
when the config object is dropped).

Also, I wanted to exclude the URLs that come from mentions and
hashtags, which meant tracking whether a colour annotation had been
applied to anything inside the link - whether it was already live at
the call to decorate_link_start or was turned on immediately
afterwards.

16 months agoSplit media URLs at w-1 chars, not w.
Simon Tatham [Fri, 5 Jan 2024 12:57:43 +0000 (12:57 +0000)]
Split media URLs at w-1 chars, not w.

This makes no real difference, but now they match the URLs in the text
of posts. In the Python version both split at w, but now that I'm
delegating HTML processing to html2text, that splits overlong words at
the same width it wraps sensible lines to. So I have to either have
them inconsistent or change the media one.

w-1 is more 'Mono' anyway, let's be honest :-)

16 months agoFix last-column glitch in post composition.
Simon Tatham [Fri, 5 Jan 2024 10:13:35 +0000 (10:13 +0000)]
Fix last-column glitch in post composition.

16 months agoMake all the tests compile again (ahem).
Simon Tatham [Fri, 5 Jan 2024 10:27:30 +0000 (10:27 +0000)]
Make all the tests compile again (ahem).

16 months agoFlag readonly mode on the main menu.
Simon Tatham [Fri, 5 Jan 2024 10:12:58 +0000 (10:12 +0000)]
Flag readonly mode on the main menu.

Then I get a reminder of whether I can safely compose embarrassingly
nonsensical test toots, or whether I'm supposed to be being coherent :-)

16 months agoCeremonially delete the Python prototype!
Simon Tatham [Fri, 5 Jan 2024 09:58:28 +0000 (09:58 +0000)]
Ceremonially delete the Python prototype!

We've reached feature parity, although I haven't been running the Rust
version live for more than a few hours so far, so there's still a
possibility of finding a bug the old version lacked.

But it's now actually awkward to have it in the same directory - the
two clients look similar enough that I can accidentally run
'./mastodonochrome' in place of './target/debug/mastodonochrome'
during testing, and then be puzzled when it doesn't behave _quite_ the
same.

So, if I need it in an emergency, I can always recover it from the git
log.

16 months agoRemove an obsolete FIXME comment.
Simon Tatham [Fri, 5 Jan 2024 09:50:59 +0000 (09:50 +0000)]
Remove an obsolete FIXME comment.

Primed extensibility indicators have been working for _days_.

16 months agoSupport highlighting the user name in a UserListEntry.
Simon Tatham [Fri, 5 Jan 2024 09:50:03 +0000 (09:50 +0000)]
Support highlighting the user name in a UserListEntry.

So you can look at a list of followers/favers/boosters and go to
Examine User from there.

16 months agoMore robust handling of fatal errors in sync_channel.
Simon Tatham [Fri, 5 Jan 2024 09:48:58 +0000 (09:48 +0000)]
More robust handling of fatal errors in sync_channel.

They were being squelched with a triple-FIXME comment, probably from
very early in development. Now it seems clear that we just propagate
them up to an 'abort the whole Tui' error, because if that goes wrong
then surely there's a disaster too weird to recover from.

16 months agoTrivial indentation fix.
Simon Tatham [Fri, 5 Jan 2024 09:48:44 +0000 (09:48 +0000)]
Trivial indentation fix.

16 months agoAdd a proper TODO list.
Simon Tatham [Fri, 5 Jan 2024 09:13:25 +0000 (09:13 +0000)]
Add a proper TODO list.

My previous jottings were kept outside source control and not very
organised. This is a version I wouldn't be embarrased about showing to
an outsider!

16 months agoFix rendering glitch when ExtensibleIndicator vanishes.
Simon Tatham [Fri, 5 Jan 2024 06:29:57 +0000 (06:29 +0000)]
Fix rendering glitch when ExtensibleIndicator vanishes.

We'd end up drawing three fewer lines of the top of the revised file
than would have fitted on the screen.

16 months agoAdd feature to show posts by the user you're examining.
Simon Tatham [Fri, 5 Jan 2024 06:25:53 +0000 (06:25 +0000)]
Add feature to show posts by the user you're examining.

16 months agoGet the default language from the locale.
Simon Tatham [Thu, 4 Jan 2024 21:09:36 +0000 (21:09 +0000)]
Get the default language from the locale.

Turns out Rust has a handy crate for that.

16 months agoShow visibility of posts with an extra header.
Simon Tatham [Thu, 4 Jan 2024 20:41:12 +0000 (20:41 +0000)]
Show visibility of posts with an extra header.

Also, changed my mind: 'unlisted' doesn't deserve to be alarming red.
Boring grey is enough.

16 months agoExamine User: compact way of displaying fields.
Simon Tatham [Thu, 4 Jan 2024 20:33:58 +0000 (20:33 +0000)]
Examine User: compact way of displaying fields.

This is much simpler than my previous idea of trying to modify the
HTML DOM to insert the heading at the start of the first paragraph!

16 months agoEditor: keystrokes to go to top/bottom of buffer.
Simon Tatham [Thu, 4 Jan 2024 20:23:12 +0000 (20:23 +0000)]
Editor: keystrokes to go to top/bottom of buffer.

I almost forgot about those until I caught myself doing them in real
Mono today.

16 months agoEditor: scroll to keep the cursor in view.
Simon Tatham [Thu, 4 Jan 2024 20:20:55 +0000 (20:20 +0000)]
Editor: scroll to keep the cursor in view.

16 months agoList modes that shouldn't throw you into mentions.
Simon Tatham [Thu, 4 Jan 2024 20:13:47 +0000 (20:13 +0000)]
List modes that shouldn't throw you into mentions.

16 months agoHighlight media of a status as well as text.
Simon Tatham [Thu, 4 Jan 2024 20:11:26 +0000 (20:11 +0000)]
Highlight media of a status as well as text.

If the status has _only_ media, this will be important!

16 months agoShow what user you're logged in as.
Simon Tatham [Thu, 4 Jan 2024 20:05:16 +0000 (20:05 +0000)]
Show what user you're logged in as.

Useful when testing two dummy accounts on a dev server, but might come
in useful for real people maintaining more than one config directory
as well.

16 months agoFetch the two main feeds on startup.
Simon Tatham [Thu, 4 Jan 2024 19:55:13 +0000 (19:55 +0000)]
Fetch the two main feeds on startup.

Mostly, this fixes missing message beeps. But it also means the UI
won't pause annoyingly the first time I go to one of those feeds.

17 months agoImplement searching within files.
Simon Tatham [Thu, 4 Jan 2024 13:55:28 +0000 (13:55 +0000)]
Implement searching within files.

I think that's now all the functionality from the Python prototype,
and we're ready to switch over!

17 months agoRemove leftover diagnostics.
Simon Tatham [Thu, 4 Jan 2024 13:38:40 +0000 (13:38 +0000)]
Remove leftover diagnostics.

17 months agoSave and restore file positions when changing activity.
Simon Tatham [Thu, 4 Jan 2024 12:24:28 +0000 (12:24 +0000)]
Save and restore file positions when changing activity.

Now you go back to where you last were in the file.

17 months agoStore an actual FileType in File.
Simon Tatham [Thu, 4 Jan 2024 12:54:34 +0000 (12:54 +0000)]
Store an actual FileType in File.

That way it can remember what feed the file is about, so as to save
the file position later.

17 months agoMake new_activity_state a method of TuiLogicalState.
Simon Tatham [Thu, 4 Jan 2024 12:21:18 +0000 (12:21 +0000)]
Make new_activity_state a method of TuiLogicalState.

I got away without it having to be for a long time, but now it's going
to need to fetch file positions.

17 months agoFill in some fixed initial file positions.
Simon Tatham [Thu, 4 Jan 2024 12:16:22 +0000 (12:16 +0000)]
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!

17 months agoAdd an initial_pos to the File constructor.
Simon Tatham [Thu, 4 Jan 2024 11:58:51 +0000 (11:58 +0000)]
Add an initial_pos to the File constructor.

17 months agoRework FilePosition to cache the last known width.
Simon Tatham [Thu, 4 Jan 2024 11:38:40 +0000 (11:38 +0000)]
Rework FilePosition to cache the last known width.

This way, it doesn't have to eagerly throw away its 'fine' position:
it can keep it until it's next called on, and then reuse it if the
new render width happens to match.

I think it's also simpler than the previous approach!

17 months agoFix extending user-list feeds.
Simon Tatham [Thu, 4 Jan 2024 10:42:36 +0000 (10:42 +0000)]
Fix extending user-list feeds.

In lists of followers, favers, boosters etc, the ids you have to pass
in the 'max_id' or 'since_id' URL query parameters are not the same as
the account ids you get back. That's not surprising, now I think about
it, since the chronological order in which users did things has
nothing to do with any intrinsic ordering on the users themselves.

For status feeds, they seemed to match, so I got away without having
to pay attention to the Link: headers in the HTTP responses. But now I
realise I do have to worry about that after all. Happily, there's a
handy Rust crate that saves me having to do the work of parsing that
complicated header type!

17 months agoCLI option to log HTTP transactions to a file.
Simon Tatham [Thu, 4 Jan 2024 10:17:27 +0000 (10:17 +0000)]
CLI option to log HTTP transactions to a file.

This allows me to actually see what's going on when the client
misbehaves.

17 months agoCreate a log entry for every HTTP transaction.
Simon Tatham [Thu, 4 Jan 2024 09:50:52 +0000 (09:50 +0000)]
Create a log entry for every HTTP transaction.

These are built into a struct and passed to a 'consume' method which
currently does nothing with them.

In the immediate short term, I want to add a --debug option which
writes them to a log file on disk, so I can look at a misbehaving
session and see what went wrong.

In the longer term, I think I might also want to keep a rolling buffer
of these log entries, and make it accessible through the Logs Menu.

17 months agoFold the send() into Client::api_request.
Simon Tatham [Thu, 4 Jan 2024 09:08:46 +0000 (09:08 +0000)]
Fold the send() into Client::api_request.

One fewer line of faff at every call site. Plus, now I can centralise
logging usefully.

17 months agoImplement the various user lists.
Simon Tatham [Thu, 4 Jan 2024 08:30:49 +0000 (08:30 +0000)]
Implement the various user lists.

Lists of users who followed or boosted a given post, or who a given
user follows or is followed by.

But something goes wrong when you try to extend these feeds. I'll
debug that in a moment ... but first, let's write some debugging
framework.

17 months agoImplement replying to posts.
Simon Tatham [Thu, 4 Jan 2024 08:09:21 +0000 (08:09 +0000)]
Implement replying to posts.

This involves a new Post constructor that fills in in_reply_to,
propagates visibility, and populates the post text with appropriate
@mentions; and a new pair of activities (these ones Util rather than
non-Util) to pass the reply back and forth between the composer and
the post-compose menu.

17 months agoMove some code into an InReplyToLine::from_id constructor.
Simon Tatham [Thu, 4 Jan 2024 07:38:26 +0000 (07:38 +0000)]
Move some code into an InReplyToLine::from_id constructor.

That will make it easier to reuse later.

17 months agoImplement viewing the thread of a selected post.
Simon Tatham [Thu, 4 Jan 2024 08:06:15 +0000 (08:06 +0000)]
Implement viewing the thread of a selected post.

Just as in the Python version, I provide an extra convenience method
which calls the API service twice, once to find the post's ultimate
top-level ancestor, and then again on that post to show the full
thread (maximal connected component) that it's a part of, not just its
own particular line.

17 months agoGeneralise SingletonSource to hold a whole vector.
Simon Tatham [Thu, 4 Jan 2024 07:42:16 +0000 (07:42 +0000)]
Generalise SingletonSource to hold a whole vector.

The previous new() constructor is now a singleton(), so it can still
work for its current purpose.

17 months agoImplement favouriting and boosting posts.
Simon Tatham [Thu, 4 Jan 2024 08:02:03 +0000 (08:02 +0000)]
Implement favouriting and boosting posts.

For these uses of selection, we have to support different keystrokes
to fave and unfave, which means we also need to know which keystroke
is valid when. So I've had to plumb the Client through to all of the
methods that move the selection, because those methods need to
retrieve the newly pointed-to status and cache whether it's already
faved/boosted. Otherwise draw(), which can't mutate things, can't
find that out to display the right status line.

17 months agoImplement selecting things in File.
Simon Tatham [Thu, 4 Jan 2024 07:45:08 +0000 (07:45 +0000)]
Implement selecting things in File.

This makes the [E] and [I] keystrokes begin working in general, to
examine a selected user and to view the full info for a selected
status.

17 months agoFactor out feed extension code into a method of File.
Simon Tatham [Thu, 4 Jan 2024 07:48:00 +0000 (07:48 +0000)]
Factor out feed extension code into a method of File.

Mostly just because it's large and cumbersome and it's nice to keep
the key-handling match cases short.

17 months agoActually implement the highlighting methods!
Simon Tatham [Thu, 4 Jan 2024 07:39:44 +0000 (07:39 +0000)]
Actually implement the highlighting methods!

Everything up to here just added API. Now I'm actually providing
non-default implementations so that TextFragments that need to
highlight can be highlighted.

17 months agoStore ids in all the TextFragments that will need them.
Simon Tatham [Thu, 4 Jan 2024 07:36:52 +0000 (07:36 +0000)]
Store ids in all the TextFragments that will need them.

The method of finding out _what_ thing was highlighted has to return
it by its string id. So anything that will have to highlight a
contained object will also need a way to return its id, so they all
have to store those ids.

17 months agoAdd highlighting methods to the TextFragment trait.
Simon Tatham [Thu, 4 Jan 2024 07:30:41 +0000 (07:30 +0000)]
Add highlighting methods to the TextFragment trait.

I've chosen to have three rather than two classes of thing you can
highlight, by separately indicating whether a text fragment contains
highlightable 'statuses' or 'whole statuses'. The distinction is that
a 'whole status' means you can see all the text, whereas a 'status'
just means you can somehow identify which post it is. I'll use that to
arrange that replying, favouriting and boosting only apply to whole
statuses (too easy to make a mistake otherwise), whereas any 'get
more info' commands apply to any old status.

(In particular, this way, you can see a one-line summary of a status,
press [I] to look at the whole thing, and _then_ fave/boost/reply.)

17 months agoTidy up: make Option and Vec pass through TextFragment.
Simon Tatham [Thu, 4 Jan 2024 07:26:14 +0000 (07:26 +0000)]
Tidy up: make Option and Vec pass through TextFragment.

Now if you have an Option<TextFragment>, or a Vec<TextFragment> (or
even, heaven help you, an Option<Vec> or a Vec<Option<Vec>> etc), you
can just call .render() on the whole thing without having to manually
loop over it. I'm starting to like this feature of Rust!

17 months agoWhen caching a status, cache its reblog too.
Simon Tatham [Wed, 3 Jan 2024 16:26:46 +0000 (16:26 +0000)]
When caching a status, cache its reblog too.

That's another whole status, which we should be able to look up.

17 months agoReclassify status info as a utility activity.
Simon Tatham [Wed, 3 Jan 2024 13:40:51 +0000 (13:40 +0000)]
Reclassify status info as a utility activity.

I meant it to be that in the first place - that's why I entered
InfoStatus in the utilities enum. But then I forgot it was there and
made a separate entry for it.

When you're invoking status info from within a file, I think it makes
more sense as a utility, the way I first had it.

17 months agoSupport saving login details. We can now log in!
Simon Tatham [Wed, 3 Jan 2024 10:55:39 +0000 (10:55 +0000)]
Support saving login details. We can now log in!

17 months agoMove TopLevelError up to the root of the crate.
Simon Tatham [Wed, 3 Jan 2024 10:55:17 +0000 (10:55 +0000)]
Move TopLevelError up to the root of the crate.

If that's not a candidate for putting at the top level then I don't
know what is.

17 months agoImplement the login procedure, without saving.
Simon Tatham [Wed, 3 Jan 2024 08:19:37 +0000 (08:19 +0000)]
Implement the login procedure, without saving.

Currently, the JSON-serialised AuthConfig is written to stdout, just
to prove during development that it works. Next step is to save it to
where it ought to live.

17 months agoActually post something!
Simon Tatham [Wed, 3 Jan 2024 07:18:14 +0000 (07:18 +0000)]
Actually post something!

17 months agoPost-compose menu, up to but not including posting.
Simon Tatham [Tue, 2 Jan 2024 18:16:10 +0000 (18:16 +0000)]
Post-compose menu, up to but not including posting.

17 months agoGive MenuKeypressLine a width reset option.
Simon Tatham [Wed, 3 Jan 2024 06:56:05 +0000 (06:56 +0000)]
Give MenuKeypressLine a width reset option.

Then when I change menu items on the fly they won't always remember
the largest width the menu has ever had.

17 months agoMove prompt into SingleLineEditor.
Simon Tatham [Wed, 3 Jan 2024 06:55:03 +0000 (06:55 +0000)]
Move prompt into SingleLineEditor.

It was a mistake to put it in the wrapping BottomLineEditorOverlay,
because I'm going to want to put single-line editors elsewhere on the
screen with the same kind of prompt.

17 months agoUpdate html2text to 0.10.1.
Simon Tatham [Tue, 2 Jan 2024 17:30:34 +0000 (17:30 +0000)]
Update html2text to 0.10.1.

Chris has released a version containing my pull request that supports
the <del> tag, which I encountered in a toot last month.

17 months agoEditor: implement cut to end of line.
Simon Tatham [Tue, 2 Jan 2024 14:38:25 +0000 (14:38 +0000)]
Editor: implement cut to end of line.

17 months agoFix handling of newlines in is_char_boundary.
Simon Tatham [Tue, 2 Jan 2024 17:09:30 +0000 (17:09 +0000)]
Fix handling of newlines in is_char_boundary.

Newlines have width 0, so we were mis-classifying them as a combining
character, causing the point just before one to be considered not a
character boundary!

17 months agoEditor: support beginning/end of line.
Simon Tatham [Tue, 2 Jan 2024 14:20:50 +0000 (14:20 +0000)]
Editor: support beginning/end of line.

17 months agoEditor: support page-up and page-down.
Simon Tatham [Tue, 2 Jan 2024 14:15:57 +0000 (14:15 +0000)]
Editor: support page-up and page-down.

Not very useful just yet while we're not able to scroll to keep the
cursor in view, but even so, it's nice to be able to get to the bottom
quickly!

17 months agoEditor: implement Up and Down keystrokes.
Simon Tatham [Tue, 2 Jan 2024 14:11:47 +0000 (14:11 +0000)]
Editor: implement Up and Down keystrokes.

17 months agoEditor: make the cursor position persist.
Simon Tatham [Tue, 2 Jan 2024 13:56:46 +0000 (13:56 +0000)]
Editor: make the cursor position persist.

Then we'll still have it available to refer to when processing
keystrokes.

17 months agoFix an edge case of watching a nearly empty feed.
Simon Tatham [Tue, 2 Jan 2024 13:39:56 +0000 (13:39 +0000)]
Fix an edge case of watching a nearly empty feed.

This just came up when testing against a dev instance, which starts
off with 0 posts anywhere, of course.

17 months agoDevelop an explicit HTTP redirection policy.
Simon Tatham [Tue, 2 Jan 2024 11:27:00 +0000 (11:27 +0000)]
Develop an explicit HTTP redirection policy.

The Mastodon dev system runs its streaming API on a different port of
its VM. So you need to be able to follow an HTTP redirect from
http://mastodon.local to http://mastodon.local:4000 and still pass the
same auth token to that server.

But in general, one should not keep authentication configuration when
traversing a cross-site redirection! reqwest's automated redirect
following won't do it at all, and rightly so.

So I've written a custom redirection policy which allows _same_-host
redirection (just in case something turns out to need it), and doesn't
follow cross-site redirection (which would in general be useless
anyway because of this auth issue). And when setting up the streaming
API in particular, we catch the unfollowed redirection, vet it very
carefully (against the official streaming API location which the
instance happily advertises in its configuration record), and if we're
satisfied, make a fresh request to the target URL which _does_ pass
the same authentication.

As a result, now we can do streaming to the Mastodon dev instance,
which the Python version of this client _never_ managed!

17 months agoMake AuthError into a subcase of ClientError.
Simon Tatham [Tue, 2 Jan 2024 11:35:06 +0000 (11:35 +0000)]
Make AuthError into a subcase of ClientError.

Now tui.rs doesn't have to handle it directly, and our client setup
can return the more general ClientError.

17 months agoFix movement by words in the editor buffer.
Simon Tatham [Tue, 2 Jan 2024 11:05:17 +0000 (11:05 +0000)]
Fix movement by words in the editor buffer.

I apparently only half-finished writing is_word_boundary: it tested
that the _next_ character wasn't a space, but not that the previous
one was.

17 months agoStart of a full-screen editor for composing toots.
Simon Tatham [Mon, 1 Jan 2024 16:13:15 +0000 (16:13 +0000)]
Start of a full-screen editor for composing toots.

You can't actually post anything. And none of the keystrokes special
to the composing editor is implemented yet (ok, except [^O][Q] to quit
the editor). But you can at least start typing text into the buffer,
and it gets wrapped, colourised, and checked for being too long.

17 months agoMake our regex scanner into a lazy_static.
Simon Tatham [Tue, 2 Jan 2024 07:27:07 +0000 (07:27 +0000)]
Make our regex scanner into a lazy_static.

That way we only construct it once per runtime, not once per Editor we
instantiate. I've just realised that that must be what's making some
of my half-written editor unit tests slow.

17 months agoDecentralise version component of API URLs.
Simon Tatham [Tue, 2 Jan 2024 07:01:41 +0000 (07:01 +0000)]
Decentralise version component of API URLs.

I thought it was /api/v1/whatever, but I've just realised that it's
actually /api/v2/instance in particular. _That's_ why I keep seeing
"uri" from some servers and "domain" from others: if I requested the
up-to-date version of the record, it would agree on "domain".

17 months agoFix test failure introduced by format_date.
Simon Tatham [Mon, 1 Jan 2024 15:57:11 +0000 (15:57 +0000)]
Fix test failure introduced by format_date.

I didn't read carefully enough the code I was replacing with a
function call. It had an extra space at the end of the date format
string.

17 months agoSupport retrieving the Instance object.
Simon Tatham [Mon, 1 Jan 2024 15:25:23 +0000 (15:25 +0000)]
Support retrieving the Instance object.

Not much of it is decoded at the moment, but we'll need a few pieces
of configuration to inform the post composer about important things
like how to tell when it's hit its length limit.

17 months agoFill in percentage in file status lines.
Simon Tatham [Mon, 1 Jan 2024 14:02:05 +0000 (14:02 +0000)]
Fill in percentage in file status lines.

I was putting that off because I had a half-formed clever idea about
trying to do linear regression on the posts we _have_ formatted to the
current width, and using it to estimate the likely line height of the
ones we haven't. But then I decided that was either the perfect being
the enemy of the good, or a silly idea that was bound to explode in an
edge case, or both, and so I've done something simple instead.

The _main_ purpose is that '100%' means 'nothing more to read' and
anything less means there is. As long as we get that much right, we're
in reasonably good shape.

17 months agoElide 'foo: foo' in struct literals where possible.
Simon Tatham [Mon, 1 Jan 2024 13:51:45 +0000 (13:51 +0000)]
Elide 'foo: foo' in struct literals where possible.

Another thing I only just realised: although in general you're
supposed to explicitly say the name of each field you're initialising,
there's a special case where you can leave it out if the name of the
local variable you're initialising it _to_ is exactly the same.
Presumably on the grounds that that still doesn't allow much
confusion, and is terser.

17 months agoRemove lots of commas after braced match arms.
Simon Tatham [Mon, 1 Jan 2024 13:50:00 +0000 (13:50 +0000)]
Remove lots of commas after braced match arms.

I only just noticed from reading someone else's Rust code that they
aren't syntactically necessary!

17 months agoStop using ~ around struck-out text.
Simon Tatham [Mon, 1 Jan 2024 13:40:26 +0000 (13:40 +0000)]
Stop using ~ around struck-out text.

Apparently html2text is completely happy to render strikeout via
U+0336 COMBINING LONG STROKE OVERLAY, and needs no support from the
terminal escape-sequence system at all. So I don't need an artificial
indication that it happened.

17 months agoSupport reading hashtag feeds.
Simon Tatham [Mon, 1 Jan 2024 13:12:01 +0000 (13:12 +0000)]
Support reading hashtag feeds.

No trouble at all given the existing infrastructure.

17 months agoFill in the rest of View Post Info.
Simon Tatham [Mon, 1 Jan 2024 13:04:35 +0000 (13:04 +0000)]
Fill in the rest of View Post Info.

17 months agoRemove some assorted dbg! I don't need any more.
Simon Tatham [Mon, 1 Jan 2024 12:14:45 +0000 (12:14 +0000)]
Remove some assorted dbg! I don't need any more.

17 months agoStart of View Post Info.
Simon Tatham [Mon, 1 Jan 2024 12:14:17 +0000 (12:14 +0000)]
Start of View Post Info.

Currently it just shows the post in the ordinary way, without all the
extra detail. But it's plumbed through the menus, which is a start.

17 months agoFilled in account flags.
Simon Tatham [Mon, 1 Jan 2024 12:05:24 +0000 (12:05 +0000)]
Filled in account flags.

I think that's Examine User all done now!

17 months agoLeave out the double-check of the account name.
Simon Tatham [Mon, 1 Jan 2024 12:05:07 +0000 (12:05 +0000)]
Leave out the double-check of the account name.

Turns out it's case-insensitive, bah.

17 months agoShow account relationships.
Simon Tatham [Mon, 1 Jan 2024 11:58:03 +0000 (11:58 +0000)]
Show account relationships.

17 months agoFilled in most of the Examine User data.
Simon Tatham [Mon, 1 Jan 2024 11:36:50 +0000 (11:36 +0000)]
Filled in most of the Examine User data.

The missing part is Relationships, because those are a separate
server-side data structure.

17 months agoSorted out the approximate dates in Account.
Simon Tatham [Mon, 1 Jan 2024 11:31:37 +0000 (11:31 +0000)]
Sorted out the approximate dates in Account.

I couldn't parse last_status_at as a DateTime<Utc> in all cases at
all, and even in created_at, the time part was clearly nonsense.

chrono has an actual type for this, so let's use it! With bonus Baby's
First Custom Deserialize Impl.

17 months agoMake the [ESC][Y] shortcut work.
Simon Tatham [Mon, 1 Jan 2024 10:26:47 +0000 (10:26 +0000)]
Make the [ESC][Y] shortcut work.

Useful to do this before I start filling in the rest of the Examine
User display, so that it's quick to test it each time!

17 months agoStart of an actual Examine User display.
Simon Tatham [Mon, 1 Jan 2024 10:23:16 +0000 (10:23 +0000)]
Start of an actual Examine User display.

Doesn't contain most of the information yet, but we have the Account
struct in hand and can start filling it in.

17 months agoUNFINISHED examine
Simon Tatham [Mon, 1 Jan 2024 10:11:07 +0000 (10:11 +0000)]
UNFINISHED examine