chiark / gitweb /
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.
Simon Tatham [Tue, 26 Dec 2023 14:09:50 +0000 (14:09 +0000)]
And prime the ExtendableIndicator.
Perhaps we're ready to start on another module now!
Simon Tatham [Tue, 26 Dec 2023 12:52:22 +0000 (12:52 +0000)]
MenuKeypressLine
Simon Tatham [Tue, 26 Dec 2023 12:13:07 +0000 (12:13 +0000)]
FileStatusLine priority-sensitive rendering.
Simon Tatham [Tue, 26 Dec 2023 12:12:59 +0000 (12:12 +0000)]
All right, ColouredString wants an is_empty()
Simon Tatham [Tue, 26 Dec 2023 10:29:18 +0000 (10:29 +0000)]
Wait, we can match on strings! Much nicer.
Simon Tatham [Tue, 26 Dec 2023 10:20:58 +0000 (10:20 +0000)]
Mass change of .to_string() to .to_owned().
I've just figured out that the former means 'use the Display trait'
whereas the latter means 'change ownership and lifetime'. In the case
of &str, both do what I want, but .to_owned() is a clearer
specification of how _little_ I wanted.
Simon Tatham [Tue, 26 Dec 2023 10:18:18 +0000 (10:18 +0000)]
First half of FileStatusLine. Rendering undone.
Simon Tatham [Tue, 26 Dec 2023 10:18:08 +0000 (10:18 +0000)]
Changed my mind again about constructor API
Simon Tatham [Tue, 26 Dec 2023 09:20:45 +0000 (09:20 +0000)]
Media entries.
Simon Tatham [Tue, 26 Dec 2023 09:01:17 +0000 (09:01 +0000)]
UserListEntry, which was easy
Simon Tatham [Tue, 26 Dec 2023 07:57:03 +0000 (07:57 +0000)]
Notification log formatting
Simon Tatham [Mon, 25 Dec 2023 21:16:03 +0000 (21:16 +0000)]
Re: header.
Simon Tatham [Mon, 25 Dec 2023 20:43:55 +0000 (20:43 +0000)]
ExtendableIndicator, without the hard part
Simon Tatham [Mon, 25 Dec 2023 20:06:24 +0000 (20:06 +0000)]
Diagnose unsupported markup tags
Simon Tatham [Mon, 25 Dec 2023 19:58:15 +0000 (19:58 +0000)]
Aha, Iterator::position is a bit nicer
Simon Tatham [Mon, 25 Dec 2023 16:16:11 +0000 (16:16 +0000)]
First-draft HTML parser
Simon Tatham [Mon, 25 Dec 2023 15:56:39 +0000 (15:56 +0000)]
Get the QualNames out of my html::Receiver.
Simon Tatham [Mon, 25 Dec 2023 15:56:08 +0000 (15:56 +0000)]
push_para
Simon Tatham [Mon, 25 Dec 2023 15:55:47 +0000 (15:55 +0000)]
FileHeader text implementation
Simon Tatham [Mon, 25 Dec 2023 13:12:45 +0000 (13:12 +0000)]
Render paragraphs by wrapping them.
Simon Tatham [Mon, 25 Dec 2023 10:42:14 +0000 (10:42 +0000)]
Build paragraphs, in a bodgy slow way.
For the moment, I've made a CharIterator that returns each coloured
character of a ColouredString one by one. That's nasty, but easy. I
think more ideally I'd want an iterator that returned contiguous
chunks of a ColouredString according to a filter function passed in
that classifies characters as wanting to be in the same chunk. But
that involves function parameters, so I can try that later.
Simon Tatham [Sun, 24 Dec 2023 22:29:48 +0000 (22:29 +0000)]
Factor out truncation of a ColouredString
Simon Tatham [Sun, 24 Dec 2023 22:13:47 +0000 (22:13 +0000)]
Username headers
Simon Tatham [Sun, 24 Dec 2023 21:48:03 +0000 (21:48 +0000)]
EditorHeaderSeparator, which is really easy
Simon Tatham [Sun, 24 Dec 2023 21:26:32 +0000 (21:26 +0000)]
SeparatorLine (with proper date formatting!)
Simon Tatham [Sun, 24 Dec 2023 21:26:23 +0000 (21:26 +0000)]
More ColouredString stuff I needed
Simon Tatham [Sun, 24 Dec 2023 21:07:45 +0000 (21:07 +0000)]
Start of the text module.
Simon Tatham [Sun, 24 Dec 2023 21:01:13 +0000 (21:01 +0000)]
Oh wait I don't need to _implement_ Eq
Simon Tatham [Sun, 24 Dec 2023 16:46:59 +0000 (16:46 +0000)]
Maybe the version with slices?
Simon Tatham [Sun, 24 Dec 2023 16:08:43 +0000 (16:08 +0000)]
Basic version of split.
Returns a newly allocated ColouredString. Perhaps it would be nice to
be able to return a lighter-weight thing containing a pair of &str?
Simon Tatham [Sun, 24 Dec 2023 15:41:55 +0000 (15:41 +0000)]
Successful frags iterator!
Simon Tatham [Sun, 24 Dec 2023 13:48:15 +0000 (13:48 +0000)]
More, but still not finished
I'm not at all sure that counting by chars is what I really want, hmmm.
Simon Tatham [Sun, 24 Dec 2023 13:37:48 +0000 (13:37 +0000)]
UNFINISHED: ColouredString class.
Simon Tatham [Sat, 23 Dec 2023 20:35:50 +0000 (20:35 +0000)]
OK, now it doesn't.
Looks as if the only problem there was trying to link the document
root to itself.
Simon Tatham [Sat, 23 Dec 2023 20:01:06 +0000 (20:01 +0000)]
Try walking the tree. It crashes, oops.
Simon Tatham [Sat, 23 Dec 2023 18:26:56 +0000 (18:26 +0000)]
Abandon html2text and try html5ever.
I _think_ this gets me a tree structure containing the HTML DOM. Now I
have to do the same formatting and wrapping that I'm doing in the
Python version, but that really should just be a matter of conversion.
Simon Tatham [Sat, 23 Dec 2023 17:04:36 +0000 (17:04 +0000)]
Now the scanners seem to be working!
Simon Tatham [Sat, 23 Dec 2023 16:31:06 +0000 (16:31 +0000)]
First cut at transcribing the scanning regexes.
Simon Tatham [Sat, 23 Dec 2023 15:22:29 +0000 (15:22 +0000)]
First cut at parsing HTML of a toot.
But it doesn't work right, because the CSS is ignored. I think that's
because html2text only processes CSS classes on <span> elements, not
on <a> where the Mastodon server puts them.
Simon Tatham [Sat, 23 Dec 2023 14:41:57 +0000 (14:41 +0000)]
Now we can draw directly without ratatui widgets.
I didn't really want to have to structure my program around their
widget API, and now I don't have to.
Simon Tatham [Sat, 23 Dec 2023 14:29:09 +0000 (14:29 +0000)]
Looks as if this is the best way to go beep!
Simon Tatham [Sat, 23 Dec 2023 14:16:22 +0000 (14:16 +0000)]
Set up ratatui and demonstrate event handling.
I've had to put the event-reading in another thread, because I
couldn't see any way to tie extra fds into ratatui's poll loop. So
instead I'm going to have to make subthreads communicate to the main
loop via an interthread channel.
Simon Tatham [Sat, 23 Dec 2023 12:56:07 +0000 (12:56 +0000)]
Update .gitignore.
Simon Tatham [Sat, 23 Dec 2023 12:51:03 +0000 (12:51 +0000)]
Process raw stream data into UTF-8 lines.
Simon Tatham [Sat, 23 Dec 2023 12:36:52 +0000 (12:36 +0000)]
Get rid of the rest of the unwraps.
Simon Tatham [Sat, 23 Dec 2023 12:29:03 +0000 (12:29 +0000)]
Made auth file handling fallible.
There are no doubt many ways to do it better, but this is a start -
now it will at least print what went wrong.
Simon Tatham [Sat, 23 Dec 2023 12:14:50 +0000 (12:14 +0000)]
Move auth file handling out into a module.
It ought to be fallible, though.
Simon Tatham [Sat, 23 Dec 2023 11:58:04 +0000 (11:58 +0000)]
Try using xdg to get the config directory location.
Simon Tatham [Sat, 23 Dec 2023 11:52:07 +0000 (11:52 +0000)]
Replace copy_to with direct use of the Read trait
Simon Tatham [Sat, 23 Dec 2023 11:37:08 +0000 (11:37 +0000)]
First demo of a streaming API working.
Had to bodgily pull in the Python version's auth data for this, but
it's a start. I can sort that part out properly later.
Simon Tatham [Sat, 23 Dec 2023 11:15:28 +0000 (11:15 +0000)]
Move the types out into a separate module.
Simon Tatham [Sat, 23 Dec 2023 11:15:12 +0000 (11:15 +0000)]
Experimented with a reqwest Client.