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).
The window library. Loop makes the Wayland display a GSource
(libwayland's prepare_read protocol) so D-Bus and the window are served
from one thread without the library's StartSync, which runs a loop of
its own that serves no GMainContext and would starve the bus; the app
owns its frame callback too — a redraw is a frame request and a bare
commit, the compositor's done runs one Window::Update, and nothing
re-arms unless something is dirty or animating — or the day changes: the
captions name the day and an idle window draws no frame by itself, so a
timer on the wall clock, which wakes at the next local midnight and
whenever that clock is set, asks for one when the local date is another
one (DayWatch); when the compositor's connection breaks the source stops
and says so (App's onDisplayLost), since the process cannot connect its
display again. Canvas initialises the device once per process and holds
the window, the font with a word wrapper and a text width over its
unrounded advances, as DrawText draws them, and four compositing layers
(background, the clipped scrolling content, the chrome, an overlay):
within one fused dispatch all quads composite before all text, so the
layers are separate dispatches in that order. The layers' buffer slots
hand their numbers back to the descriptor heap when they go, so the heap
is declared before them and outlives them. Screens draw the conversation
list (avatars, previews, time captions, unread badges, the
new-conversation button, with room under the last row to scroll clear of
it) and one conversation (day separators, wrapped bubbles, clock and
state captions — only what is in view, the layer's glyph budget being
finite) and record the regions a tap can hit. App wires them to the
store and Sync: mouse events become gestures (the detector's slop and
fling threshold set from the window's scale, the positions being buffer
pixels), a tap is resolved against the last frame's regions (which name
the conversation or message they drew, not a position a reload may
shift), scrolling is by wheel, drag or fling (a press stops a fling; a
screen change stops a fling and cancels the press under it, so the
scroll left behind keeps no velocity for a return to revive and a
release after a link's or a notification's Open is no tap on the new
screen), the window is created on the first Show (when the library
cannot and says so — no display, a compositor without wl_shm,
wl_compositor or xdg_wm_base, no Vulkan driver — Show logs why, Open
opens nothing, and the app runs on without one; a later Show fails at
once, the device's set-up running only once) and torn down in order on
Shutdown. ScreenshotThenQuit renders one frame outside the compositor's
pacing and saves it; a window it creates first waits 600 ms for the
compositor's configure, which sizes it (to the screen, on a phone). A
capture with no window to render it — none could be made, or it went
before the frame — is logged and sets App's exitCode to 1.
project.cpp gains Crafter.Graphics (--local takes the branch worktree with
the Wayland input work until it is merged), the imsd-messages-ui library,
and libevdev from the prefix of packaging/build-libevdev.sh on the
library's include path and the executable's library path (a sysroot
build looks for it in the sysroot instead).
What a finger or a mouse did, decided from raw Down/Move/Up/Cancel
phases over the app's own point type: a short press within the slop is a
tap at the press position, a press held past the long-press time (the
host's timer) a long press, movement past the slop a drag with its
deltas, a fast release a fling with a velocity (the last 100 ms of
movement before it: a finger held still before letting go flings
nothing). With it the scroll physics of a list (clamped offset, a
decaying fling that stops at the edges) and the topmost hit region under
a point.
Tested: tests/Gesture.
The SMS app for imsd's net.catcrafts.IMS1.Messaging interface starts
here: the licence (GPL-3.0-only), FUNDING.yml, README and AGENTS, a
project.cpp with the three build products (imsd-messages-core: std and
Crafter.DB; imsd-messages-bus: GLib; the imsd-messages executable),
their module units as stubs, the version constant, the bundled Noto Sans
font with its OFL text, and the first test. This commit is the base every
later range is reviewed against.
Tested: crafter-build builds the three products and --version answers,
crafter-build test passes the one test, lint and format --check are clean
on every text rule and on the AST rules for the eleven files without a
global module fragment; the four files that include gio/gio.h are not
parsed by the lint driver's libclang (no C++ standard library on its
include path: 'type_traits' file not found), which is a Crafter.Build
matter.