Loading...
Searching...
No Matches
long_text.h File Reference

One text setting too long for the settings blob, which rides its own message key and the face's own storage. More...

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  LongText
 The face's long text setting: its key, its cap, and the provider and receiver. More...

Macros

#define LONG_TEXT_CAP_MAX   1024
 The most bytes a long text can take, its end included. Its buffer sits on the stack for one send or compare.

Typedefs

typedef void(*) LongTextReceiver(const char *text)
 Called with a long text setting the phone sent, for the face to store.
typedef void(*) LongTextProvider(char *out, size_t size)
 Called to write the long text setting the face holds, for the settings reply and to tell a save that changed it from one that did not.

Functions

bool long_text_set (LongText *slot, uint32_t key, uint16_t cap, LongTextProvider provider, LongTextReceiver receiver, bool opened)
 Sets up the face's long text setting, replacing one set before.
bool long_text_fits (uint32_t text_bytes, uint32_t reply_bytes, uint32_t outbox_max, uint32_t inbox_room)
 Whether the text at its cap fits both buffers: the outbox beside the rest of the settings reply, and the inbox on its own.
void long_text_held (const LongText *slot, char *out)
 Writes the text the face holds, as its provider writes it, ended inside the cap.
bool long_text_arrived (const LongText *slot, const char *text)
 Hands a text that arrived to the receiver when it differs from the one the face holds.

Detailed Description

One text setting too long for the settings blob, which rides its own message key and the face's own storage.

A settings field lives in a blob of at most 256 bytes, so a face with a text setting that can run longer, such as a packed list of colours, keeps it itself, split however it likes. The phone sends it on its own key with every save, and the watch sends it back in the settings reply. The face names the key and the most bytes the text can take, and hands over a provider that writes the text it holds and a receiver that stores a new one.

The deciding needs nothing from the SDK beyond a log line. The transport owns one of these, reads and writes the key, and asks here whether the setting can be taken, whether it fits the buffers, whether an arrival changed anything, and what text the reply carries, which keeps the deciding testable on the host.