modus
Menu
On this page

The entry settings

The settings of the system: the font of the system, the order of the color stripes of the screen, the pointer theme, the grid fit of the vector font, the layout of the keyboard, the appearance of the desktop, the time zone and the languages that the principal reads. The window shows the settings in four sections, each setting with a line that says what it does and its values as buttons ; the export set() and a getter for each setting make the same changes and give the same values from the console and from modustool call.

The language list is the languages that the principal reads, the first first, as records of language_tag.Locale: set_languages() takes a table of them, and the list of the languages of the window adds a common language, moves a language up, or removes it. An empty list is English.

The time zone is a fixed offset from UTC, "+08:00". This process writes it on the settings page; the process date copies it into the date page and wakes waiters on the date page. This process wakes on the date page and moves the appearance in force when the new local time asks for it. So this process computes the appearance in force with the zone of the date page, never with the zone that it writes.

This process is the sole writer of the settings page (modus:contract/settings). A change is written first to its private store, as one record in one object (one commit), then to the page, with the appearance in force that the setting appearance gives now ; the page wakes the compositor, which gives the new font, pointer theme and appearance to each window: every process draws again, with no code of its own for it. With the setting auto, this process waits for the next 07:00 or 19:00 local-time edge and for date-page changes, and updates the appearance in force itself.

At boot the root service starts this process for one pass with no window (the context value VALUE_PASS, the pass Boot): it reads the record of its store, writes the page, and stops. The tile Appearance of the Control Center starts it for the pass Appearance_Next.

What it is for. It shows that a choice of the principal is state like any other: kept in a private store with no save action, and seen by every process at once through one page that each reads and only one writes. No process reads a configuration file, and no process needs code to follow a change.

Start: start("settings") in the console, or the bar of the desktop. Keys: Tab moves between the buttons, Enter presses one; a click works too. From the console, with no window: connect("settings"), then settings.set(font = .spleen).

Grants, as the root service gives them:

  • Settings: the settings page with the right Write. No other process can write it.
  • Store: its private store, which keeps the record of the settings across a stop of the machine.
  • Serve: the exports set, set_time_zone, set_languages, repeat, and a getter for each setting, for the time zone and for the languages.

What a reader sees: the cards Display, Pointer, Keyboard, and Region and language, in one column or two by the width of the window, which the principal resizes; a scroll bar when they do not fit. The log has "settings: the boot pass: ..." at boot, "settings: ok, font vector, ..." when the window opens, and one line for each change, with "kept in the store" or "NOT kept: the store refused". At the boot pass and at each change of the appearance it writes why the appearance in force is what it is: "settings: the appearance in force is dark: auto, light from 07:00 to 19:00 of the local time; the local time is 01:04 with a zone of 0 s, at 1794791040 s since 1970".

See: The text of the system: a vector font with subpixel bands: The setting, The window of settings in the repository, The interface in the language of the principal: The identity of a language in the repository, The time zone in the repository, The appearance in the repository

settings module with an entry

Hash
45093fad77802146d4780160c2ea83a38b1c4c05db026c2057415611974badc1
Size
409481 bytes
Exports
13
Imports
0
Imported by
0
License
MIT

The settings of the system: the font of the system, the order of the color stripes of the screen, the pointer theme, the grid fit of the vector font, the layout of the keyboard, the appearance of the desktop, the time zone and the languages that the principal reads

FactValue
KindModules with an entry
Sourcesrc/modules/system/settings
Boot imageyes: in the boot image, 409481 bytes in this build
Build settingsnone: the defaults of the source
Importsnone
Imported bynone

Neighbours

It imports no module, and no module imports it. The module graph shows it with the other modules that have no edge.

Exports

ExportWhat it does
set(font: Font, subpixel_order: Subpixel_Order, pointer_theme: Pointer_Theme, grid_fit: Grid_Fit, keyboard_layout: Keyboard_Layout, appearance: Appearance, scale: Scale) -> Integerchanges one setting of the system or more, and keeps them in the store: set(font = .spleen), set(keyboard_layout = .french, appearance = .light)
font() -> Fontgives the font of the text of the system: .vector or .spleen
subpixel_order() -> Subpixel_Ordergives the order of the color stripes of the screen: .red_green_blue, .blue_green_red or .none
pointer_theme() -> Pointer_Themegives the pointer theme that the compositor draws: .of_the_owner or .of_the_system
grid_fit() -> Grid_Fitgives whether the glyphs sit on whole pixels: .on or .off
keyboard_layout() -> Keyboard_Layoutgives the layout of the keyboard: .united_states or .french
appearance() -> Appearancegives the appearance that the principal chose: .auto, .dark or .light
scale() -> Scalegives the scale factor of the desktop, in eighths: .ten_eighths is 1.25
set_time_zone(zone: Text) -> Integerchanges the time zone of the system, and keeps it in the store: set_time_zone("+08:00")
time_zone() -> Textgives the time zone of the system as a text: "+08:00"
set_languages(languages: Table(Locale, Read)) -> Integersets the languages that the principal reads, the first first, and keeps them in the store: set_languages([language("fr-CA"), language("en")])
languages() -> Table(Language_Row)gives the languages that the principal reads, the first first: the canonical tag of each, its language, its script and its region
repeat(count: Integer) -> Integerkeeps count records in the store, one commit each, with the font and the subpixel order of each record from its number: the case of the loss of power of the machine test (a loss in the middle gives the record before or the record in flight, never a mix)
entry()The entry of settings: the boot pass, or the window and the service

set

set(font: Font, subpixel_order: Subpixel_Order, pointer_theme: Pointer_Theme, grid_fit: Grid_Fit, keyboard_layout: Keyboard_Layout, appearance: Appearance, scale: Scale) -> 

set changes one setting of the system or more, and keeps them in the store: set(font = .spleen), set(keyboard_layout = .french, appearance = .light).

Each setting is one optional argument of the enum of its values: a line names the parameter and a member, and the console completes both and refuses a member that the enum does not have before the call. A setting that the call leaves out keeps its value. Every window draws again: the settings page wakes the compositor, which gives the new font, pointer theme and appearance to each window. The order is the store first, then the page, so a stop of the machine between the two keeps the new values. Values equal to the values of the page change nothing and return 1. The setting appearance .auto gives the light appearance from 07:00 to 19:00 of the local time and the dark one at night: the page holds the appearance in force, which the log says with the time that the rule read.

The scale factor of the desktop is a count of eighths, from .eight_eighths, 1, to .sixteen_eighths, 2; .ten_eighths, 1.25, is the default. Each window lets its surface go, makes a surface of its size at the scale that the compositor names from its own budget, and draws again. A window whose budget does not pay that surface declines the scale and shows its frame only, until another scale; the window of settings says how many did.

Each parameter names its getter: the export of the same name gives the value in use, and the palette marks its button with it.

  • font: .vector or .spleen.
  • subpixel_order: .red_green_blue, .blue_green_red or .none.
  • pointer_theme: .of_the_owner or .of_the_system.
  • grid_fit: .on or .off.
  • keyboard_layout: .united_states or .french.
  • appearance: .auto, .dark or .light.
  • scale: a count of eighths, .eight_eighths to .sixteen_eighths.

The caller must act for the principal (Acts_For_Principal): the console and the host have it. The result is 1, or a negative number with an error record:

  • No_Grant (-1): the caller does not act for the principal.
  • Absent (-2): the call gives no setting.
  • Bad_Value (-3): a value that names no member of the enum of its setting; the record names the argument and holds the value. No setting changes.
  • Refused (-4): the store did not keep the values. The page keeps the values before: a change is kept in the store first, so no window shows a value that the next start of the machine loses.

Example: settings.set(font = .spleen), then settings.font() gives .spleen.

Parameters
  • font: Font
  • subpixel_order: Subpixel_Order
  • pointer_theme: Pointer_Theme
  • grid_fit: Grid_Fit
  • keyboard_layout: Keyboard_Layout
  • appearance: Appearance
  • scale: Scale
Result
When it fails
a negative result, and the error record
Source
src/modules/system/settings/main.odin:428

font

font() -> Font

font gives the font of the text of the system: .vector or .spleen.

Each getter reads the settings page, which each process can read too: so it needs no grant, and each caller gets the value. A refused page gives the defaults, which each process draws with.

Parameters
none
Result
Font
Source
src/modules/system/settings/main.odin:457

subpixel_order

subpixel_order() -> Subpixel_Order

subpixel_order gives the order of the color stripes of the screen: .red_green_blue, .blue_green_red or .none.

Parameters
none
Result
Subpixel_Order
Source
src/modules/system/settings/main.odin:464

pointer_theme

pointer_theme() -> Pointer_Theme

pointer_theme gives the pointer theme that the compositor draws: .of_the_owner or .of_the_system.

Parameters
none
Result
Pointer_Theme
Source
src/modules/system/settings/main.odin:471

grid_fit

grid_fit() -> Grid_Fit

grid_fit gives whether the glyphs sit on whole pixels: .on or .off.

Parameters
none
Result
Grid_Fit
Source
src/modules/system/settings/main.odin:478

keyboard_layout

keyboard_layout() -> Keyboard_Layout

keyboard_layout gives the layout of the keyboard: .united_states or .french.

Parameters
none
Result
Keyboard_Layout
Source
src/modules/system/settings/main.odin:485

appearance

appearance() -> Appearance

appearance gives the appearance that the principal chose: .auto, .dark or .light.

Parameters
none
Result
Appearance
Source
src/modules/system/settings/main.odin:492

scale

scale() -> Scale

scale gives the scale factor of the desktop, in eighths: .ten_eighths is 1.25.

Parameters
none
Result
Scale
Source
src/modules/system/settings/main.odin:499

set_time_zone

set_time_zone(zone: ) -> 

set_time_zone changes the time zone of the system, and keeps it in the store: set_time_zone("+08:00").

The time zone is a fixed offset from UTC, with no summer time: a sign, the hours and the minutes, from "-12:00" to "+14:00", by quarters of an hour; "+00:00", UTC, is the default. The bar then shows the local time, and the rule of the appearance .auto counts its hours in it. A zone is a number of minutes, not a member of a closed set: so it is a Text, and not an argument of set.

  • zone: the zone, 32 bytes at most.

The caller must act for the principal (Acts_For_Principal). The result is 1, or a negative number with an error record:

  • No_Grant (-1): the caller does not act for the principal.
  • Too_Long (-3): the zone has more than 32 bytes.
  • Bad_Value (-3): the text is no zone: "+8:00", "+08:10", "+15:00", "UTC".
  • Refused (-4): the store did not keep the zone. The page keeps the zone before.

Example: settings.set_time_zone("+08:00"), then settings.time_zone() gives "+08:00".

Parameters
  • zone:
Result
When it fails
a negative result, and the error record
Source
src/modules/system/settings/main.odin:523

time_zone

time_zone() -> 

time_zone gives the time zone of the system as a text: "+08:00".

The result is the length of the text, 6. A buffer shorter than the text gets its first bytes; the result still counts them all.

Parameters
none
Result
Source
src/modules/system/settings/main.odin:548

set_languages

set_languages(languages: (, Read)) -> 

set_languages sets the languages that the principal reads, the first first, and keeps them in the store: set_languages([language("fr-CA"), language("en")]).

A text of the system is written in the first language of the list that has it, else in its source language, English. An empty table sets the empty list: each text is in English. Each window draws again: the settings page wakes the compositor. The order is the store first, then the page. A list equal to the list of the page changes nothing and returns 1.

The caller must act for the principal (Acts_For_Principal). The result is 1, or a negative number with an error record; on each refusal no language changes:

  • No_Grant (-1): the caller does not act for the principal.
  • Too_Long (-3): more than 8 records; value: their count; limit: 8.
  • Out_Of_Range (-3): the count of the table is past its capacity; value: the count; limit: the capacity.
  • Bad_Value (-3): a record that names no locale in its canonical form, or the root locale und; value: the word of its language_tag.Locale_Problem, 0 for the root locale; found: the record, from 1.
  • Exists (-3): a language that the table holds in an earlier record; found: the record, from 1.
  • Refused (-4): the store did not keep the list. The page keeps the list before.

Example: settings.set_languages([language("fr"), language("en")]), then settings.languages() gives fr, then en.

Parameters
  • languages: (, Read)
Result
When it fails
a negative result, and the error record
Source
src/modules/system/settings/main.odin:591

languages

languages() -> ()

languages gives the languages that the principal reads, the first first: the canonical tag of each, its language, its script and its region.

An empty table: each text of the system is in English. The getter reads the settings page, which each process can read too: so it needs no grant. A refused page gives the empty list. The result is the count of languages; a table shorter than the list gets its first rows.

Example: settings.languages() gives a row "fr-CA", "fr", "", "CA", then a row "en", "en", "", "".

Parameters
none
Result
()
Source
src/modules/system/settings/main.odin:633

repeat

repeat(count: ) -> 

repeat keeps count records in the store, one commit each, with the font and the subpixel order of each record from its number: the case of the loss of power of the machine test (a loss in the middle gives the record before or the record in flight, never a mix).

It is a test export, not a setting that a reader changes. The machine test calls it, then cuts the power of the machine during the commits; at the next start, the boot pass must read one whole record. The font of record n is n mod 2, its subpixel order n mod 3, so a mix of two records shows. The page takes the last record.

  • count: the number of records, from 1 to 1000.

The result is the count of records kept, or a negative number with an error record:

  • No_Grant (-1): the caller does not act for the principal.
  • Bad_Value (-3): a count outside 1 to 1000.
  • Refused (-4): the store refused a record; the record of the error holds its number.
Parameters
  • count:
Result
When it fails
a negative result, and the error record
Source
src/modules/system/settings/main.odin:662

entry

entry()

The entry of settings: the boot pass, or the window and the service.

The entry maps the settings page; with no page it writes "settings: no settings page" and stops with Refused when the context names no page or a handle that it cannot map, and with Failed for any other status. It opens its private store; a process with no store still runs, and says "NOT kept: no store".

  • The boot pass (the context value VALUE_PASS is Boot): it reads the record of its store, writes the page, wakes the compositor, writes "settings: the boot pass: ..." with its time, and stops with Done. A missing or unreadable record gives the defaults. A record of another version gives the defaults, which the pass keeps in its place. A store that fails the read or refuses that write gives the defaults too, and the pass stops with Failed.
  • The next appearance (VALUE_PASS is Appearance_Next): the tile of the Control Center. It keeps and writes the appearance after the one of the page (settings.appearance_next), and stops with Done, or with Failed when the store did not keep it.
  • A word that names no pass: it writes its fact and stops with Refused, with no write.
  • Otherwise: it opens its window (with none, it stops with Failed) and its service, draws, and writes "settings: ok, ...". Then one loop waits on the events of the window and on the service ring, runs the calls, and draws after an event. It never stops by itself.
Form
The entry of the module: one parameter, an address, fixed by the contract.
Source
src/modules/system/settings/main.odin:1662

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
GrantsIt writes the settings, keeps them in its private store, and serves set() and get().
Other terms of its start grant setnone
Budget that it asks for
  • working memory pages 7800
  • pages of its threads 72
  • pages of the pictures of its window 6400
  • 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 (648 pages): its module, its stack, its tables and its glyph memory, 1400 pages. A resize holds the old surface and the new one together until the compositor shows the new one, so the working memory also holds a second surface at the largest size: 1024 x 800 logical pixels are 2048 x 1600 at the largest scale, 2, two pictures of 4 bytes a pixel, 26 214 400 bytes, 6400 pages. 1400 + 6400 = 7800. The tool counts the window at its largest size, at the largest scale. 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).

Integer wire form

A wire form of the module contract: one word of a call. A signed integer of 64 bits, in a register.

Error_Record record of a module

A record of the module settings: 56 bytes, aligned on 8 bytes, 0 bytes of padding.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

Text wire form

A wire form of the module contract: one word of a call. The address of a slice record {address, count} of UTF-8 bytes.

Table wire form

A wire form of the module contract: one word of a call. Records of one description that follow each other (a table).

Locale record of a module

A record of the module settings: 48 bytes, aligned on 4 bytes, 0 bytes of padding.

  • languageText(8)08 bytes
  • scriptText(4)84 bytes
  • regionText(4)124 bytes
  • variant_firstText(8)168 bytes
  • variant_secondText(8)248 bytes
  • calendaru8321 bytes
  • numbering_systemu8331 bytes
  • first_dayu8341 bytes

and 5 more

Language_Row record of a module

A record of the module settings: 144 bytes, aligned on 1 bytes, 0 bytes of padding.

  • tagText(128)0128 bytes
  • languageText(8)1288 bytes
  • scriptText(4)1364 bytes
  • regionText(4)1404 bytes

Error_Record struct

A struct of the package errors: 56 bytes, aligned on 8 bytes, 0 bytes of padding. The error record: what a call that failed says about why, as seven integers.

  • kindi6408 bytes
  • uniti6488 bytes
  • operationi64168 bytes
  • argumenti64248 bytes
  • valuei64328 bytes
  • limiti64408 bytes
  • foundi64488 bytes

set_languages procedure of the package settings_process

set_languages :: proc "c" (languages: ^system.Table_To_Read(language_tag.Locale), error: ^errors.) -> i64

set_languages sets the languages that the principal reads, the first first, and keeps them in the store: set_languages([language("fr-CA"), language("en")]).

src/modules/system/settings/main.odin:591

Locale type of the package language_tag

Locale :: struct {...}

Locale: a language tag as a record.

src/library/modus/contract/language_tag/locale.odin:33

Locale_Problem type of the package language_tag

Locale_Problem :: enum u8 {...}

Why tag_read refuses a text, or locale_valid a record.

src/library/modus/contract/language_tag/locale.odin:53

VALUE_PASS constant of the package settings

VALUE_PASS :: op.CONTEXT_VALUE_SETTINGS_PASS

The process settings: the word of its Pass.

src/library/modus/contract/settings/settings.odin:69