~hime/protochat

(repo) update readme to mention linetest crate
3d896ca7 — drbawb 4 months ago
(repo) Release project under BSD license.
eb9a9fe2 — drbawb 4 months ago
(ui/buffer): fix panic when using home/end keys

Home needs to update the position of `end` to be consistent w/ the
currently rendered span length, otherwise subtractions involving the end
of the span will underflow.

End likewise needs to update not just the cursor position, but also the
start and end of the current span. Otherwise the cursor will be
inserting text into a span that is rendered off-screen.
(net): add tests for client state machine

- brings in `sluice` crate to create an in-memory bidirectional
  stream which we can use to model a fake TCP connection.

- adds tests surrounding the initial client/server registration
  handshake.
(crate) use `Into` trait where possible

removes `as` for infallible casts. a little gross in a few places
where it requires additional `let` bindings because inference
falls down.

remaining casts are guarded w/ `assert!` as a means to declare
my intent that these *should not* fail in practice, even though they
might in some super future, where you have a 65636p display.

("This software doesn't work on my 65K display! D:" - what a nice problem
that'd be to solve. lol.)
(ui): implement Home & End keys

- (term) adds event handlers for `KeyCode::Home` and `KeyCode::End`.
- (buffer) adds `goto_head` and `goto_tail` methods for `InputBuffer`.
(linetest/ui/buffer): reconcile interaction of resizing w/ pager logic.

This commit implements some changes to the pager which allow it to track
the line index which created the multiline span. We can use this
information to determine which line is currently drawn at the top of
the buffer's viewport.

If the span at the top of the viewport is not the first line in
the buffer then we allow the user to continue scrolling up. Likewise if
the span at the bottom of the viewport is not the last line we allow
them to scroll down.

In the special case where the user resizes their terminal to display
more rows _while at the top of the buffer_ we fill the new rows with
additional lines from the buffer.
(linetest/net) fix issue w/ malformed packets

- Currently malformed packets will termiante the decoder. The protocol is,
  at present, not robust enough to continue following loss of sync. This decision
  may be revisited later if the protocol ever grows some packet framing.

- Added a `quit` channel to allow packet decoding task failure to cascade into
  the main event loop itself.
(deps) bump crossterm to 0.17.7

Upstream yanked 17.6; fixes a potential panic in `cursor::position()`
(linetest/ui/buffer) return more generalized iterator

This returns a double ended iterator, which gives callers
downstream a bit more flexibility in how lines are presented
to the client.

This may be useful if we later add buffers that are painted from
top-down, rather than bottom-up.
make sure we clear rest of the buffer panel
change buffer scrolling to be line oriented

Vastly simplify the buffer handling. The page approach had many problems
when scrolling a page and then making the terminal wider (i.e: reducing
the number of span lines.)

This approach simply tracks the current "buffer line" the user wishes
to view and always keeps that at the bottom of the viewport; then it
fills in the rest of the viewport with as many spans as possible.

This has the added advantage of drawing exactly as many spans as is
necessary to fill the viewport; as opposed to the previous approach
which required drawing two full screens worth of spans on every repaint.
clean up some lints about unused imports & vars
(linetest/ui/buffer) Work on buffer pager mechanism

This commit implements the `scroll_up` and `scroll_down` functions of
the buffer. This is accomplished by storing the current page in a
so-called `front_buffer` and the next neighboring page in a `back_buffer`.
When the user offsets w/in a page we draw some combination of the two
pages: some care is taken to ensure that we don't fall off either end
of the front/back buffer.

When the user seeks *outside* the current page we swap the front & back
buffer and redraw the next nearest page into the back buffer. This allows
us to avoid needing to redraw the neighboring page (which is immutable at
this point) unnecessarily.
(server) cleanup some old comments

- removes old line oriented TCP stream reading code.
- describes the various channels used in the client task.
(server): start returning `UnknownRoom` error again
(server) update documentation in main binary
(docs) add protocol notes
add notice support and fix some protocol bugs

- encode packet for notice was using type 0x20 not 0x21
- notice packet test missing #[test] attribute
- we were not properly setting the name on an accepted client, making
  it fail the "sniff test" for being properly registered. as a result:
  the disconnection loop was not sending the `Disconnect` message
  for a registered peer.
(linetest): implement notice handling

allow the server to specifically address things to be sent
to a global per-server buffer. useful for the case where the
server needs to report an error to a client.
Next