GNU TeXmacsUser manualReferenceAboutEnglish
Loci in the typesetter and the editor

1.Registering loci: build_locus

Loci are registered when they are typeset, by build_locus (env, t, ids, col, ref, anchor) in

Typeset/Concat/concat_active.cpp

. It is called for inline loci (concater_rep::typeset_locus), for loci typeset as atomic boxes (

concater.cpp

), for block loci (bridge_locus_rep::my_typeset) and for loci in the lazy typesetter (make_lazy_locus,

Typeset/Line/lazy_typeset.cpp

). It expands the body (the last argument) and evaluates the other arguments one by one:

(id name)

If the body is accessible (it comes from the document rather than from a macro definition), the locus is registered under name with insert_locus. Otherwise, if the source location of the body can be decoded, the parent of the corresponding subtree of the document is registered under &name, so that the locus can still be found (the Scheme function id-update uses both forms).

(link type v1 …)

The link is completed with an attribute argument (attr … "secure" flag), which records whether the document is secure (see scripts and security), and registered with insert_link. Links are registered even when the body is not accessible.

(observer name callback)

If the body is accessible and the callback is allowed (the document is secure, or the callback is declared secure), the body is registered with a Scheme callback (insert_locus (id, t, cb)).

All of this is skipped if there is no current link repository (env->link_env is null), which happens when trees are typeset outside an editor, for instance in output widgets. build_locus also returns the identifiers in ids, the destination of a url vertex in ref and the name of an id vertex in anchor, and computes the colour col of the locus: visited-color if one of its identifiers or destinations has been visited, locus-color otherwise, subject to the rules described in the link registry. The return value tells whether the body is accessible.

Since the repository belongs to the bridge being typeset (see the link registry), the consequences are:

2.Locus boxes and printed links

For an inline locus whose body is not accessible, typeset_locus wraps the typeset material, in pieces, in locus boxes (locus_box,

change_boxes.cpp

). A locus box remembers the identifiers, the ref and the anchor:

For accessible loci, links are printed by box_rep::display_links (

boxes.cpp

), which is called for non-screen renderers only: it walks up from the source of a box, looks up the identifiers of each subtree with get_ids, and emits an href for every hyperlink whose target is a url.

3.Active loci in the editor

The editor keeps two lists of identifiers (

edit_interface.hpp

):

mouse_ids

Computed by update_mouse_loci (

edit_mouse.cpp

) when the mouse moves: the identifiers of the locus boxes under the mouse (eb->loci) and of the subtree under the mouse and its ancestors (get_ids), filtered by the Scheme functions link-mouse-ids (which drops identifiers whose only links are of type focus) and link-active-ids (which keeps identifiers which admit a link that can be followed). The outlines of the corresponding loci and of the active ancestors (link-active-upwards) are collected in locus_new_rects and drawn by the repaint code.

focus_ids

Computed by update_focus_loci from the cursor position: the active identifiers of the subtree containing the cursor and its ancestors.

These lists are used as follows:

The Scheme side of these calls is described in creating and following links from Scheme.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".