![]() |
Displaying source | ![]() |
When the environment variable preamble is true, every bridge of the typesetter is built by make_inactive_bridge (
bridge.cpp:53
): paragraphs of a document stay paragraphs, and every other subtree is typeset through the macro inactive_auto, that is <rewrite-inactive|x|recurse*>. The source style (
styles/source.ts
), which style files and packages use, assigns preamble and sets mode to src; Document\(\rightarrow\)Source\(\rightarrow\)Edit source tree toggles preamble as an initial value of the document (toggle-source-mode in
document-edit.scm
). When preamble is true, typeset_exec_until also sets the mode to src when it computes the environment at the cursor (
edit_typeset.cpp:498
).
The preamble of a document is its first paragraph, hide-preamble or show-preamble, which holds the local macro definitions. Document\(\rightarrow\)Part\(\rightarrow\)Show preamble (Create preamble when there is none; the Part menu is hidden in projects) or Source\(\rightarrow\)Edit preamble (toggle-preamble-mode,
document-part.scm
) changes it into show-preamble and hides the rest of the document. The macro show-preamble sets mode to src and preamble to true for its body, while hide-preamble only executes the style assignments in it (
std-fold.ts
).
A subtree wrapped in inactive is shown as source with its children typeset normally; inactive* shows the children as source too. Inside source, active and style-only apply the tag to its arguments shown as source, while active* and style-only* typeset the whole subtree normally (
env_inactive.cpp:452
). Outside source, the active and style-only tags are the identity (
env_default.cpp:425
).
inactive and inactive* are macros whose body is the primitive rewrite-inactive with the mode once, resp. recurse; erroneous markup uses error. edit_env_rep::rewrite_inactive (
env_inactive.cpp
) turns the tree into ordinary markup made of the style macros src-regular, src-var, src-arg, src-textual, src-numeric, src-unknown, src-error, … and of the four primitives inline-tag, open-tag, middle-tag and close-tag, whose children are arg references back to the original tree. Typesetting these references gives boxes with the paths of the source, so that the cursor moves and edits in the source tree itself. The details of this rewriting, and its memoization by the style rewriter, are in macro expansion: inactive markup.
A tag with inline arguments becomes one inline-tag; a tag with block arguments (according to the DRD and to src-compact) becomes an open-tag, a middle-tag between block arguments and a close-tag, with the arguments as separate paragraphs. typeset_src_tag (
concat_inactive.cpp:168
) draws them: the name in the src-tag-color (blue by default) and in sans serif (typeset_blue), and the delimiters as ghosts, characters which are shown but are not part of the document.
The look is controlled by four environment variables, read in update_src_style, … (
env_semantics.cpp:729
). Unrecognized values are ignored and the previous setting is kept.
The delimiters: angular (<name|a|b>, the default), scheme ((name a b)), latex (name{a}{b}) or functional (name(a, b)).
Which tags get a special rendering instead of the generic one: raw (none), format (formatting tags), normal or maximal.
When arguments are put on separate lines: none, inline, normal, inline args or all.
How block tags are closed: repeat (the name again), long, compact (the default) or minimal.
They are set for a document in the Preferences group of Document\(\rightarrow\)Source (document-source-preferences-menu in
document-menu.scm
; a dialog in the compressed menus). Locally, Source\(\rightarrow\)Presentation\(\rightarrow\)Compact and Source\(\rightarrow\)Presentation\(\rightarrow\)Stretched insert a style-with for src-compact; the other variables need a style-with written by hand. The user documentation of these settings is global presentation.