Ui: the compose field and the send bar

A text message needs several lines and UTF-8, and the library's
InputField is one line edited by byte, so the field is the app's own.
Its state and editing are the core's (ImsdMessages:Edit, tested without
a window): a plain struct, insertion at the cursor, Backspace and Delete
by code point, Home and End within the line, a newline. Ui:Compose turns
the keys into those edits and draws the field one to five lines tall —
as many as half the area under the header and the banner holds, and one
at the least — with the canvas's word wrapper (a longer text shows the
lines that end at the caret's, or the first ones while the caret is
among them), a placeholder when empty, the caret at the cursor, and a
tap placing the cursor at the nearest byte by the widths the glyphs are
drawn at, in the text as it is when the tap lands (an edit since the
last frame only asked for one; a field no frame has laid out yet takes a
tap as one at its text's end; a tap at or past the last line's end asks
for the text's end, where a space the wrapper hung off the line may be).
The bar under a conversation holds the field and Send, enabled only with
text, a sendable status and an address to send to; Send hands the text
to Sync with that address and clears the field (a store that refuses the
text keeps the draft) (Model's SendAddress: as a link gave it, else the
latest message's — the network's form of a received text, the dialled
form of ours — never the key, whose completed country code is a guess
that groups; a conversation with neither has Send off, and so has one
whose address is not international — a national number, a short code;
typed, linked or the message's — and was typed or written under another
SIM's plan than the one known now, which the plan each row and the view
carry tells (the view's is that of the SIM the address was typed under,
which Number's AfterStatus keeps; Number's AnotherPlan, its second
caller)); Sync's StateChanged moves the bubble's caption. Keys reach the
field while a conversation is open (Escape goes back, Ctrl+Enter sends),
a held key repeats through a timer since frames are on demand, and the
caret blinks on one. A text typed and not sent is its conversation's,
not the view's: leaving the conversation (Back, another one opened by a
notification or a link) keeps it by the conversation's key for the run,
and opening the conversation again takes it up (Edit's Drafts: an empty
field keeps nothing and drops nothing; the draft of a typed or linked
address follows imsd's status as the open conversation's key does —
Number's AfterStatus over the address and the plan kept with it — so one
left before the status brought the country code is found under the key
the address makes afterwards; and a second text kept under one key — two
keys that became one — goes after the first on a line of its own).

Tested: tests/Model, the address a text goes to (the typed or linked
one, the latest message's, none for an emptied conversation, none under
another SIM's plan than it was typed or written under — a national
number with or without a trunk prefix under another country's SIM, a
short code under another operator's too, though dialled under the same
operator, the own number read when it was typed or not; a national
number typed before the own number was read, none under another operator
— an international one under any — and a typed address judged by its own
plan, whatever the latest row's); tests/Edit (code points of one to four
bytes, the moves within a line, the edits that change nothing, the first
line shown as the caret moves down a long text; the drafts: kept and
taken up by key with the cursor, taken once, an empty field keeping and
dropping nothing, one per conversation, a second text under one key on a
line of its own; a typed address's following the status — moved when the
code comes, not while texts are stored under its key, not under another
SIM's status, a list conversation's left alone and the store not asked,
the learned plan kept, two keys that became one keeping both texts).
This commit is contained in:
Jorijn van der Graaf 2026-10-18 00:35:39 +02:00
commit efd8dd92d3
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
12 changed files with 727 additions and 22 deletions

View file

@ -4,12 +4,14 @@
/*
ImsdMessages.Ui — the window: Crafter.Graphics driven from the GLib main
loop. Loop makes the Wayland display a GSource and owns the frame callback,
Canvas holds the window, the font and the four compositing layers, Screens
draw the conversation list and a conversation, App wires them to the store
and to Sync.
Canvas holds the window, the font and the four compositing layers, Compose
lays a field out and draws it over the core's editing (ImsdMessages:Edit),
turning keys into its edits, Screens draw the conversation list and a
conversation, App wires them to the store and to Sync.
*/
export module ImsdMessages.Ui;
export import :Loop;
export import :Canvas;
export import :Compose;
export import :Screens;
export import :App;