Skip to main content

Module text

Module text 

Source
Expand description

Saving a text (.txt) item edited in the app’s text viewer.

Eagle’s text editor writes the new text to a temporary file beside the original (<name>.txt.<ms>) and moves it over the original, so a half-written file is never left in place. It refuses to save empty text. It leaves the item’s metadata.json alone, so size and mtime go stale; falcon refreshes them (and lastModified, as every item edit does) so the inspector and size filters stay right. btime and modificationTime keep their values.

A text item also carries the start of its text in the item record, under the text key, as Eagle’s text importer writes it: the grid draws the card from it instead of a thumbnail (there is no _thumbnail.png), and search reads it. preview makes that value.

Constants§

PREVIEW_UNITS
How much text the record keeps: 32 Ki UTF-16 code units, as Eagle’s importer cuts it.
RECORD_KEYS
The keys of a text item’s metadata.json in the order Eagle writes them: no width, height or palettes, and text just before lastModified.
TEXT_KEY
The item key holding the start of a text item’s text.

Functions§

cut
The start of text that fits in PREVIEW_UNITS UTF-16 code units, never splitting a character.
preview
The value of TEXT_KEY for the text file at path: its start, read as UTF-8 with invalid bytes replaced, as Eagle reads it.