// Keys that let a list ask its owner something and take the answer: the// words an empty list says (`empty`), a row standing for another record that a// tap opens (`opens`), a slip's typed answers (`answers` — "Close without an// answer"), and a slip's answer in the owner's own words (`reply` — "Answer",// a sheet with the question and a ruled field). Each is drawn once, for any// table that names it; the questions assistants asked (`comment`, the /decide// list) were the first to need all four together.//// The spellings are the shared format's, as the Rust definitions decode them// (`crates/cotton-core/src/definitions`): `empty` is `EmptyWords`, `opens` is// `RecordOpens`, `answers` is `RecordAnswers`. `reply` is new on this side// (FORMAT CHANGE, filed for another Mac). Only `reply` is defined here: `EmptyWords`// and `emptyWords` live with the definition (`TableDefinition`,// `TableDefinition+Reading`), `RecordOpens` and `opening` in `PictureKeys`,// `SlipAnswers` and `isAnswered` (which reads `reply` too) in `AnswerKeys` —// one copy each.//// The reading lives here, pure, so the rules are settled by tests;// `SlipFace`, `ReplySheet` and `RecordListSurface` only draw them.importCottonValuesimportFoundation/// A slip's answer in the owner's own words: the text column the words are/// written to, the verb's words (absent: "Answer") and the field's words./// The words are typed, or spoken through the keyboard's dictation; blank/// words are no answer and send nothing.publictypealiasSlipReply = DefinitionSlipReplyextensionDefinitionSlipReply {publicinit(column: String, label: String? = nil, placeholder: String? = nil) {self.init(_generated: (), column: column)self.label = labelself.placeholder = placeholder }publicvar verb: String { label ?? "Answer" }}extensionTableDefinition {/// The slip's reply, while it may be given: a text column it names, on a/// record whose question is still open. Nil otherwise.publicfunc replyOffered(_ record: TableRecord) -> SlipReply? {guardlet reply = slip.reply, let column = column(reply.column), column.type == .text || column.type == .longtext, !isAnswered(record)else { returnnil }return reply }/// What a reply writes: the words trimmed into the reply's column. Nil/// for words that are only whitespace — a blank answer is no answer, and/// sending one would settle the question with nothing in it to read.publicfunc replyPatch(_ words: String) -> [String: RecordValue]? {guardlet reply = slip.reply else { returnnil }let said = words.trimmingCharacters(in: .whitespacesAndNewlines)guard !said.isEmpty else { returnnil }return [reply.column: .text(said)] }}