chiark / gitweb /
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.
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!
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.
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.
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.
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.
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".
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.
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.
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.
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.
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!
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.
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.
Simon Tatham [Mon, 1 Jan 2024 13:04:35 +0000 (13:04 +0000)]
Fill in the rest of View Post Info.
Simon Tatham [Mon, 1 Jan 2024 12:14:45 +0000 (12:14 +0000)]
Remove some assorted dbg! I don't need any more.
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.
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!
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.
Simon Tatham [Mon, 1 Jan 2024 11:58:03 +0000 (11:58 +0000)]
Show account relationships.
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.
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.
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!
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.
Simon Tatham [Mon, 1 Jan 2024 10:11:07 +0000 (10:11 +0000)]
UNFINISHED examine
Simon Tatham [Mon, 1 Jan 2024 09:47:08 +0000 (09:47 +0000)]
Abstract out FeedDataSource.
Now a FileContents doesn't _have_ to contain a FeedId; I can replace
it with an alternative trait implementation containing a fixed set of
things.
Simon Tatham [Mon, 1 Jan 2024 09:21:22 +0000 (09:21 +0000)]
Rename FeedFile and friends.
The scrolling-file system is about to be reused for things that aren't
feeds, so it will be confusing to have the structs all called FeedThing.
Simon Tatham [Mon, 1 Jan 2024 09:18:23 +0000 (09:18 +0000)]
Ability to abort a bottom-line prompt.
The new PopOverlay logical action returns to the previous non-overlay
activity, without reinitialising it.
Simon Tatham [Mon, 1 Jan 2024 09:14:45 +0000 (09:14 +0000)]
Use todo!() in place of panic!("FIXME").
I only just found out about that, and I should start getting into the
habit.
Simon Tatham [Mon, 1 Jan 2024 09:13:38 +0000 (09:13 +0000)]
Make the Examine prompt chain to another activity.
Doesn't _work_, because I haven't actually implemented that activity
yet. We now panic in a FIXME in tui.rs. But it's a start.
Simon Tatham [Mon, 1 Jan 2024 08:14:02 +0000 (08:14 +0000)]
UNFINISHED: first overlay activity: Examine User prompt.
This doesn't actually examine users yet. When you press Return at the
prompt, it just beeps, because transferring the data to where you
actually wanted it is not yet implemented. But it's enough to test the
editing itself.
Simon Tatham [Mon, 1 Jan 2024 07:21:08 +0000 (07:21 +0000)]
Introduce the concept of an 'overlay activity'.
This will be used for bottom-line editor prompts. Some of those are
triggered within the context of an existing activity (for example, if
you're reading a file and press the not-yet-implemented search key).
Others can be imposed from outside, e.g. pressing Alt+E while reading
a file. So there's a slightly fiddly mechanism to make the latter
work, and not treat it as two totally independent ESC and E
keystrokes (which would leave you looking at the Utilities Menu while
entering the name of a user to examine, instead of at the screen you
saw the username on).
The overlay activity is drawn on top of the topmost non-overlay
activity on the stack, at the bottom of the screen.
Simon Tatham [Sun, 31 Dec 2023 20:21:28 +0000 (20:21 +0000)]
Enough editing keys for a single-line editor.
Simon Tatham [Sun, 31 Dec 2023 19:25:44 +0000 (19:25 +0000)]
Start of text editing: the EditorCore type.
This is the common piece between bottom-line text entry and the
full-screen post composer, handling all the editing keys that work the
same in both.
Simon Tatham [Sun, 31 Dec 2023 15:11:07 +0000 (15:11 +0000)]
Fix panic when going to Read Mentions.
My rewrite of the ensure_enough_rendered loop introduced a further bug
in which we counted the number of visible lines of the bottom item
_plus_ its full height. Should have been _instead of_ its full height.
So we didn't get right to the top of the screen.
Simon Tatham [Sun, 31 Dec 2023 15:06:29 +0000 (15:06 +0000)]
Braino: < for <=.
Would have caused an unnecessary coarsen_pos() if we were sitting on
the first _non-header_ item in a file at the point when it failed to
extend backwards.
Simon Tatham [Sun, 31 Dec 2023 15:00:07 +0000 (15:00 +0000)]
Don't put '?' on the end of parameterless URLs.
If you call reqwest::Url::parse_with_params and give it an empty
parameter iterator, it still appends '?' to the URL, and then doesn't
put anything after it.
I don't _think_ that actually makes any difference, but it looks ugly.
More to the point, I noticed it while pasting HTTP transcripts to
report a bug in the Mastodon dev setup, and thought I'd better try
again without the spurious '?', in case it did make a difference.
Simon Tatham [Sun, 31 Dec 2023 14:29:20 +0000 (14:29 +0000)]
Make this program build on Windows!
I tried it out of pure curiosity. As I expected, the 'xdg' crate
didn't work (I already knew it was documented to not work on Windows),
but everything else was fine, and it compiles and runs!
Simon Tatham [Sun, 31 Dec 2023 14:01:44 +0000 (14:01 +0000)]
Report HTTP errors from all URLs we retrieve.
Simon Tatham [Sun, 31 Dec 2023 14:01:00 +0000 (14:01 +0000)]
Fix misreporting of HTTP errors not about auth.
The prefix "unable to read authentication" was in the wrong part of my
error handling edifice.
Simon Tatham [Sun, 31 Dec 2023 13:46:49 +0000 (13:46 +0000)]
Fix extending a totally empty home timeline.
Again, probably only likely to come up in a new dev instance - but in
that situation, you do need it to work!
Simon Tatham [Sun, 31 Dec 2023 13:38:24 +0000 (13:38 +0000)]
UNTESTED: go to Read Mentions if user is mentioned.
Annoyingly, I can't test this on the dev instance, because its
streaming API doesn't work!
Simon Tatham [Sun, 31 Dec 2023 13:37:49 +0000 (13:37 +0000)]
File draw method: add a missing bounds check.
Don't try to render an item that doesn't even exist at all.
Simon Tatham [Sun, 31 Dec 2023 13:37:01 +0000 (13:37 +0000)]
ensure_enough_rendered: forgot to render bottom item!
We must render the actual item that our current position points at, as
well as the ones before that. I had my loop backwards.
Simon Tatham [Sun, 31 Dec 2023 13:36:15 +0000 (13:36 +0000)]
Call ensure_enough_rendered even if feed update failed.
Because then we're tinkering with the ExtendableIndicator, so we still
need to re-check our drawability.
Simon Tatham [Sun, 31 Dec 2023 13:25:07 +0000 (13:25 +0000)]
Replace an assert with sensible handling.
It came up the first time I tried to test on a dev instance.
Simon Tatham [Sun, 31 Dec 2023 11:39:11 +0000 (11:39 +0000)]
Initial command-line parser.
Allows '-c some_directory' to specify a non-default config dir.
Simon Tatham [Sun, 31 Dec 2023 11:26:32 +0000 (11:26 +0000)]
Reorganise startup to pass in a config location.
This begins to set up for specifying a non-default one on the command
line, which I'm going to need in order to start doing testing that
depends on a local test Mastodon instance.
Simon Tatham [Sun, 31 Dec 2023 09:53:02 +0000 (09:53 +0000)]
Implement the Ego Log.
This also meant fixing a loose end in the NotificationLog text
fragment type: it was still expecting to receive a Vec<Paragraph>,
because that's what it would have had available before we moved back
to html2text. Now it takes a single Paragraph, expecting that
Html::to_para() has sorted that out already.
Simon Tatham [Sun, 31 Dec 2023 08:58:43 +0000 (08:58 +0000)]
Add the Read Mentions feed.
Simon Tatham [Sun, 31 Dec 2023 09:37:27 +0000 (09:37 +0000)]
Teach Client about the Notification type in the API.
Simon Tatham [Sun, 31 Dec 2023 08:59:03 +0000 (08:59 +0000)]
Make FeedFile generic across type of item.
Now it can hold some other kind of TextFragment, instead of always
being StatusDisplay.
Simon Tatham [Sun, 31 Dec 2023 08:35:52 +0000 (08:35 +0000)]
Remove some pubs from html.rs.
Just spotted that those aren't really needed.
Simon Tatham [Sun, 31 Dec 2023 07:31:19 +0000 (07:31 +0000)]
Use feed updates to lengthen the home timeline.
Untested as yet, but this _should_ replicate the behaviour from the
Python version where you're reading your home timeline and a new post
quietly appears below what you can currently see.
Simon Tatham [Sun, 31 Dec 2023 07:31:07 +0000 (07:31 +0000)]
Fix help message.
Simon Tatham [Sat, 30 Dec 2023 11:57:51 +0000 (11:57 +0000)]
Begin setting up the streaming subthread system.
This gives Client two new methods. The first starts a subthread
listening to a stream, given a lambda function that you pass into the
subthread to handle the response. The second runs in the context of
the main thread, and the idea is that you give that same response
straight back to the client.
The owner of a Client object is responsible for doing the plumbing in
between, to arrange that a response passed to the lambda in the
subthread is transferred back to the main thread and given to
process_stream_update.
The implementation of that plumbing in Tui sends the data back to the
main thread over a clone of the sync_channel we already had, so that
it's received in the same event loop as terminal input.
So far, nothing is done with the updates.
Also not done: it would be nice to be able to ask a subthread to
terminate, if it's not needed any more. That way if the user tries to
read one of the fast-moving public timelines, we can dismiss its
update thread as soon as they're not looking at that file any more.
Simon Tatham [Sat, 30 Dec 2023 11:25:27 +0000 (11:25 +0000)]
Add a couple more primary timelines.
Simon Tatham [Sat, 30 Dec 2023 09:30:09 +0000 (09:30 +0000)]
Ability to extend the feed backwards in time.
Haven't yet tested the part where extension runs out, though. That
will be easier when we get some more kinds of feed, so I've left a
FIXME comment in there.
Simon Tatham [Sat, 30 Dec 2023 09:01:57 +0000 (09:01 +0000)]
Remove an unnecessary drop.
I had imagined that explicitly dropping a reference would terminate a
borrow. But firstly, rustc 1.74 says it does nothing at all, and
secondly, therefore I infer that this particular borrow wasn't in the
way in any case.
Simon Tatham [Fri, 29 Dec 2023 20:01:04 +0000 (20:01 +0000)]
Migrate back to html2text.
I gave up on using it previously because it lacked some important
features - in particular, it didn't support CSS on <a> elements, which
is necessary for identifying hashtags and mentions in Mastodon's
output HTML.
In 0.9.2 that feature is present, so I can try again! Also, 0.9.2 has
the neat ability to save the RenderTree that's an intermediate product
of the pipeline, just before we depend on the width. So we can keep
that after parsing a toot, and then only re-run the necessary back end
of the pipeline to re-render at a different width.
The amount of code is extremely reduced.
Simon Tatham [Fri, 29 Dec 2023 22:29:36 +0000 (22:29 +0000)]
Use ratatui's Color::Gray instead of Color::White.
The former is the ESC[37m colour. The latter seems like the natural
name to my way of thinking, but it means tell the terminal you're
_really serious_ about wanting proper #ffffff.
Simon Tatham [Fri, 29 Dec 2023 18:35:49 +0000 (18:35 +0000)]
Go to top and bottom of file.
I think this is all the basic 'paging around' actions done!
Simon Tatham [Fri, 29 Dec 2023 18:31:50 +0000 (18:31 +0000)]
Add a file header!
Simon Tatham [Fri, 29 Dec 2023 18:24:19 +0000 (18:24 +0000)]
Clip position at the top of the file.
Simon Tatham [Fri, 29 Dec 2023 18:14:01 +0000 (18:14 +0000)]
Scrolling downward, too.
Simon Tatham [Fri, 29 Dec 2023 18:08:43 +0000 (18:08 +0000)]
Scrolling upward mostly works.
Doesn't clip at the top of the file yet, but this is a start!
Simon Tatham [Fri, 29 Dec 2023 16:59:20 +0000 (16:59 +0000)]
More or less principled file-position tracking.
We still can't actually _scroll_ through the file, because I haven't
made any actual keystrokes work yet. But we begin displaying it at the
bottom, and do something sensible on resizing.
Simon Tatham [Fri, 29 Dec 2023 16:10:56 +0000 (16:10 +0000)]
Notify ActivityState mutably when it gets resized.
This should enable it to prepare anything it needs for the next
redraw.
Simon Tatham [Fri, 29 Dec 2023 16:05:30 +0000 (16:05 +0000)]
Pass client through to handle_keypress.
Simon Tatham [Fri, 29 Dec 2023 14:34:18 +0000 (14:34 +0000)]
Forgot to break overlong logical lines.
Now URLs show up in a way that you can actually paste into a browser.
Simon Tatham [Fri, 29 Dec 2023 14:32:23 +0000 (14:32 +0000)]
Fix paragraph wrap width.
We were wrapping to the full screen width, instead of Monochrome's
traditional w-1.
Simon Tatham [Fri, 29 Dec 2023 14:18:28 +0000 (14:18 +0000)]
Basically correct-looking display of toots \o/
Simon Tatham [Fri, 29 Dec 2023 13:26:50 +0000 (13:26 +0000)]
Now we display the separator line of each toot. Progress!
Simon Tatham [Fri, 29 Dec 2023 12:12:43 +0000 (12:12 +0000)]
URL in statuses is optional.
Reblogs don't have one: you can't view the reblogging status in the
web UI, only the reblogged one.
Simon Tatham [Fri, 29 Dec 2023 11:49:24 +0000 (11:49 +0000)]
Now we try to actually fetch a feed.
It doesn't work! JSON parsing error.
Simon Tatham [Fri, 29 Dec 2023 11:15:05 +0000 (11:15 +0000)]
Prepare to pass a Client through to activity constructors.
Simon Tatham [Fri, 29 Dec 2023 11:10:05 +0000 (11:10 +0000)]
Temporarily squelch some warnings.
I _know_ all those things are unused - I haven't finished writing the
program yet. Shut up about them until I'm done!
Simon Tatham [Fri, 29 Dec 2023 11:09:46 +0000 (11:09 +0000)]
Allow error reporting as a PhysicalAction.
Could easily come in useful!
Simon Tatham [Fri, 29 Dec 2023 11:08:52 +0000 (11:08 +0000)]
Make a Client and put it in the Tui.
This involved souping up the error handling so that we can absorb
errors from various different sources during Tui construction.
Simon Tatham [Fri, 29 Dec 2023 10:54:00 +0000 (10:54 +0000)]
Untested code to fetch feeds of items.
Simon Tatham [Thu, 28 Dec 2023 18:07:48 +0000 (18:07 +0000)]
Readonly mode for the client.
This was very useful when I was testing the editor last time round,
and surely it'll be just as useful this time.
Simon Tatham [Thu, 28 Dec 2023 18:06:52 +0000 (18:06 +0000)]
Forgot to make sure ESC G worked!
It _worked_ in the Python version, but I apparently left it out of the
visible menu options. But here they're more tightly tied together, so
leaving it out of the visible options made it not work at all.
Simon Tatham [Thu, 28 Dec 2023 16:49:06 +0000 (16:49 +0000)]
Improved first couple of client operations.
Now we check errors sensibly rather than via cavalier .unwrap(); we
cache accounts as well as statuses per id; and we verify the returned
id against the one we asked for (to make it not an obvious attack
avenue to file things under the returned id).
Simon Tatham [Thu, 28 Dec 2023 14:16:53 +0000 (14:16 +0000)]
Filled in all the rest of the menus.
Also, the actions that aren't implemented yet are clearly marked with
'NYI', and been if you try to select them.
Simon Tatham [Thu, 28 Dec 2023 12:33:30 +0000 (12:33 +0000)]
Enough menu handling to [ESC][X][X]!
Simon Tatham [Thu, 28 Dec 2023 12:11:57 +0000 (12:11 +0000)]
Don't let menu items go way over to the right.
The allocation of 3/4 of padding space to the left-hand side is
intended for cases where there isn't room to put the = signs in the
middle. When there is, we should do it.
Simon Tatham [Thu, 28 Dec 2023 12:01:44 +0000 (12:01 +0000)]
Forgot trailing '.' on FileStatusLine without proportion.
Simon Tatham [Thu, 28 Dec 2023 11:49:02 +0000 (11:49 +0000)]
Begin actually displaying menu options!
Simon Tatham [Thu, 28 Dec 2023 11:38:42 +0000 (11:38 +0000)]
Reduce some of the unused-stuff warnings.
Perhaps I should turn all these warnings off until I've actually used
all the unused stuff? I'm sure they're very useful once your program
is supposed to be finished, but while it's still only half-written,
yes I _know_ I haven't got round to using all these fields yet.
Simon Tatham [Thu, 28 Dec 2023 11:06:15 +0000 (11:06 +0000)]
Changed my mind about using Box<dyn TextFragment>.
I think it's going to be a better idea to have each user of
TextFragment separately make an enum that permits precisely the kinds
of TextFragment they want. Firstly, this means we can be statically
sure no rogue weird ones got in there by accident; secondly, it
immediately solves all the problems of finding the ones that need
special handling at render time (extensible-file indicators etc).
And thirdly - this is definitely a thing I'm having trouble getting
used to in Rust - if I _do_ need one particular client of TextFragment
to do everything by means of a list of perfectly generic Box<dyn
TextFragment>, I can choose to do it in _that_ client module, and
text.rs doesn't have to lift a finger to support it!
Simon Tatham [Thu, 28 Dec 2023 09:01:13 +0000 (09:01 +0000)]
Delete some of my commented-out prototype code.
The new Tui structure now replicates almost all the useful
functionality of that. The only exception is the extra loop where we
re-split each line returned from render() to the screen width, in case
it's overlong. But that can't be centralised into the current code: it
will have to live in the draw() method of ActivityState types that
need it (particularly, those rendering paragraphs), because they'll
need to know when it happened in order to count screen lines
correctly.
Simon Tatham [Thu, 28 Dec 2023 08:45:45 +0000 (08:45 +0000)]
Store an OurKey in FileStatusLine and MenuKeypressLine.
Now we have a representation for keystrokes that can trigger actions,
this is the first step towards a DRY representation in which each menu
and status line configures just once the a set of triples (keypress,
help text, action to take).
Not sure what form the 'action' part of that triple will take yet,
though.
Simon Tatham [Thu, 28 Dec 2023 08:32:21 +0000 (08:32 +0000)]
Put x first in all coordinate pairs.
This is the universal convention _almost_ everywhere. When writing
actual curses programs I've sometimes reversed it, because curses's
API puts line before column. But (a) ratatui is the sensible way round
in the first place; (b) if my plan in this code is to localise the
curses-type library as hard as possible into one module, then I
wouldn't want to allow its conventions to leak into the rest of the
code _anyway_.
So, here we speak (x,y) like normal people, and since ratatui happens
to be sensible, we do so _everywhere_; if for some reason we had to
work with actual curses, we'd localise the swap to tui.rs.
Simon Tatham [Thu, 28 Dec 2023 08:30:09 +0000 (08:30 +0000)]
Make a start on ActivityStates drawing themselves.
This begins to bring the pieces together: our Main Menu now has its
correct header line, although as yet nothing else.
Simon Tatham [Wed, 27 Dec 2023 20:35:50 +0000 (20:35 +0000)]
More structure.
Now we hand off to subsidiary traits that can treat menus, files and
editors all differently.
Simon Tatham [Wed, 27 Dec 2023 17:17:58 +0000 (17:17 +0000)]
Start of the main TUI code.
So far, I've made a struct that encapsulates the Ratatui state and
some subthread comms machinery, i.e. does the physical work. Then
there's a sub-struct to contain the logical UI state (so it can be
borrowed mutably without having to re-borrow the main struct), which
gets to draw things on the screen, update itself in response to
keypresses, and tell the physical side what to do after the
keypress (options currently limited to 'beep', 'exit', or 'just redraw
and go round the loop again').
Currently the UI itself is just "hello, world". I think menus are
next.
Simon Tatham [Wed, 27 Dec 2023 16:31:26 +0000 (16:31 +0000)]
Implement a specialised stack of UI activities.
I think this mostly matches Monochrome's rules about what activities
you can and can't have stacked on top of each other. To wit, you
basically get an arbitrary keypath of menus from the Main Menu, plus
optionally a single utilities-menu thing pushed on top of that.
Utilities things replace each other rather than stacking, so that
popping the stack returns to the non-utility below it.
(An exception on real Monochrome is that popping from Send Message
replaces it with the Users On screen - also a utility-class activity -
rather than popping back to the topmost non-util. Mastodon has no such
thing, so we can omit that special case here. If anything like that
were needed anyway, it could be special-cased inside pop().)
Simon Tatham [Wed, 27 Dec 2023 14:32:41 +0000 (14:32 +0000)]
Forgot to wrap overlong lines.
Simon Tatham [Tue, 26 Dec 2023 22:08:04 +0000 (22:08 +0000)]
End-to-end PoC: we format and display a sample toot!
Simon Tatham [Tue, 26 Dec 2023 17:17:21 +0000 (17:17 +0000)]
Half-arsed attempt to set up a Client type.
It _compiles_, but I'm not at all sure the API is what it ought to be.
Still, I'll press on with it for the moment and figure out how it's
wrong later.