Document (std text) and (std unicode grapheme)
Module pages for both, entries in the standard library chapter, and sections on grapheme clusters and on text for editing in the language basics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
93025b7b35
commit
1a2a43bf5a
5 changed files with 85 additions and 0 deletions
|
|
@ -47,6 +47,16 @@ For more details, see @link["modules/std/rx.html"]{@code{(std rx)}}.
|
|||
Reading a line by a pattern, after OCaml's @code{Scanf}. The pattern is a quoted list of what the line holds, in order: @code{(scan "3-17" '(long "-" long))} is 3 and 17, and @code{'(int "x" int ": " int ... #:sep " ")} reads @code{"12x5: 1 0 3"} as two ints and a vec of them. There are items for numbers, a character, a word, the rest of the line, a run of given characters and the text up to one, with a width, a skip, a repetition, an option and a choice. The type of the result comes from the pattern, so @code{'(int "," int)} gives a @code{(Tuple int int)}. The macro compiles the pattern into straight code over the line's bytes, and a pattern of numbers and strings allocates nothing. The whole line must match. @code{try-scan} gives an @code{Err} that says at which column it failed, instead of raising. A scan does not search and does not backtrack: use @code{(std rx)} to find text in a line.
|
||||
For more details, see @link["modules/std/scan.html"]{@code{(std scan)}}.
|
||||
|
||||
@subsection{std/text}
|
||||
|
||||
Text that is cheap to edit anywhere, for an editor's buffer or any large text that changes in many places. A @code{Text} is a balanced tree of UTF-8 chunks: inserting, deleting, splitting, appending, taking a substring and finding a line take O(log n) time, and an edit shares everything it does not change, so old versions stay valid for undo. The API is a string's, with @code{text-} for @code{string-}: positions are cursors, the cursor functions take the text and the cursor, and no function takes a byte offset. @code{text-count} is O(1), @code{text-cursor-forward} moves any number of characters in O(log n), and @code{text-cursor-index} gives a cursor's index to carry across an edit. A @code{TransientText} edits in place for a run of edits such as typing, and @code{TextBuilder} and the @code{texting} collector build a text in one pass. @code{text-cursor-next-grapheme} and the others step by grapheme clusters.
|
||||
For more details, see @link["modules/std/text.html"]{@code{(std text)}}.
|
||||
|
||||
@subsection{std/unicode/grapheme}
|
||||
|
||||
Grapheme clusters, the characters a reader sees, by Unicode's rules (UAX #29): a letter and its accents, a flag, an emoji sequence, CR LF. @code{string-cursor-next-grapheme} and @code{string-cursor-prev-grapheme} move a cursor by one, as an editor's arrow keys and backspace do, and @code{string-grapheme-count} and @code{string->graphemes} count and split. A cluster has no limit on its length, but a loop by clusters takes O(n) time in either direction, so long runs of accents or flags cannot make it quadratic. The rules are two state machines over characters, which other containers can drive with their own cursors: @code{(std text)} does, for texts.
|
||||
For more details, see @link["modules/std/unicode/grapheme.html"]{@code{(std unicode grapheme)}}.
|
||||
|
||||
@subsection{std/http}
|
||||
|
||||
The @code{std/http} module allows you to build and send HTTP requests. Sending a request three ways — blocking, suspending, or as an event — is the only thing that differs between the entry points. There is no C# in this module: @code{System.Net.Http} is reached with @code{import/extern}, and the response body is an ordinary @code{TextInputPort}.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue