modus
Menu
On this page

The entry edit

The source src/modules/system/edit built with the setting DRAWING_THROUGH_MODULE=true. The text after this paragraph is the comment of that source.

The editor of a text: a text object of its private store, or of any granted store opened with edit(store, name), in a window, with the keys that most principals know from other systems and no modes .

The text has no save action. The editor commits a group of changes when the group ends: after a space, a tab or a line end, before a change of another kind (a deletion after typed characters), when the caret moves to another line, after a cut or a paste, and before an undo, a redo or a search. Each commit is a version of the object, so Ctrl+Z restores the version before the one shown, also after a restart; Ctrl+Y goes forward again along the restores that Ctrl+Z made. A stop of the process loses only the group in progress.

What it is for. It edits the text that a principal writes in modus, and shows that undo needs no code of its own to keep the states: the store keeps each one.

Start: start("edit") or edit(store, name) in the console. Keys: a character goes in at the caret, in place of the selection; the arrows, Home, End, Page Up and Page Down move the caret, and Control with Home or End goes to the start or the end of the text; with Shift each of them selects; Ctrl+A selects all. Ctrl+H shows or hides the pane of the versions of the text. Backspace and Delete remove the selection or one character. Escape ends the selection or closes search. Ctrl+C copies, Ctrl+X cuts, Ctrl+V pastes multi-line UTF-8 text through the compositor clipboard. Ctrl+F opens incremental search; Enter or F3 finds next, Shift+Enter or Shift+F3 finds previous, wrapping around the text. Ctrl+Z is undo, Ctrl+Y is redo. A press of the pointer places the caret, a drag selects, and the wheel or the scroll bar scrolls. A drag of the divider resizes the pane of the versions.

Grants, as the root service gives them:

  • Store: its private store, which holds the object "text" and its versions.

What a reader sees: a window that the principal resizes, laid out by the layout tree of modus:layout. In the top band: the search field while search is open, and a state label that says whether the store keeps the text or a change waits for its commit. Under it the text in the font of the cells, a line that is longer than 80 cells on more rows, the number of each line in a gutter at the left, the caret, the selection with its text in white on the chosen blue, and a scroll bar; with Ctrl+H, a pane of the versions at the right of a divider. At the bottom a status band: a problem of the store or of a key at the left, the line, the column and the bytes of the text at the right; then the action bar. The log has, at the start, one of:

  • edit: a new store: an empty text;
  • edit: restored a text of N bytes, L lines (with the count of the invalid sequences that it replaced, when there are some);
  • edit: no store: the text is not kept;
  • edit: the text in the store is damaged: ....

Then edit: undo: the text has N bytes, the caret at byte C, ... and the same for redo, and edit: the selection has N bytes, from byte A to byte B, over L lines after a selection with Shift or the pointer.

See: The editor `edit` in the repository, The layout tree in the repository

edit module with an entry

Hash
02e9b5ee5ddb25e38d7f31613281a9b98d3986c9b6117cf044891fbb54910367
Size
271489 bytes
Exports
0
Imports
1
Imported by
0
License
MIT

The editor of a text: a text object of its private store, or of any granted store opened with edit(store, name), in a window, with the keys that most principals know from other systems and no modes

FactValue
KindModules with an entry
Sourcesrc/modules/system/edit
Boot imageyes: in the boot image, 271489 bytes in this build
Build settings
  • DRAWING_THROUGH_MODULE=true
Imports
Imported bynone

Neighbours

What it imports, at its left, and what imports it, at its right: the part of the module graph that touches it.

edit drawing

Exports

ExportWhat it does
entry()The entry of edit: it reads the text of its store, then edits it until the principal closes the window

entry

entry()

The entry of edit: it reads the text of its store, then edits it until the principal closes the window.

With no window it stops with Failed. With no store it runs, and keeps nothing. Then one loop waits for the events of the window and draws after each of them: a key, a press of the pointer, a drag, a turn of the wheel, a resize, and the clipboard events Copy_Asked (Ctrl+C, Ctrl+X) and Pasted (Ctrl+V).

Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/system/edit/main.odin:1288

Read from the source of the module, as the build reads it to describe the exports (tools/modustool/build/describe.odin).

What the root service gives it

WhatValueAs the root service says
GrantsThe text that it edits and the versions of the text live in its private store: a commit of a text of 32 KiB holds 8 blocks of data and their nodes, and the store keeps each version for 10 minutes before the thinning.
Other terms of its start grant setstore_blocks = 4500
Budget that it asks for
  • working memory pages 1313
  • pages of its threads 72
  • pages of the pictures of its window 9600
  • pages of the module and its imports from the files of the build
  • processes the least
  • threads the least
The least budget of 2048 pages, in which it ran before it stated its window, less that window at the scale 1 (735 pages): its module, with its layout tree and the states of its boxes, its stack, its text, its tables and its glyph memory. The tool counts the window at the window bound, at its largest size. See: Module contract: The budget that a module asks for

The start grant set is read from start_grant_sets in src/modules/system/root/start_grant_sets.odin. The stated budget is read from the constant MODULE_BUDGET of the source of the module (its line); the build adds the counted parts and writes the sum in the module (tools/modustool/build/budget_count.odin); the root service accepts it up to the largest budget of a process, and adds the limits of processor time and of log records (src/modules/system/root/budgets.odin).