![]() |
Tables and dynamic markup | ![]() |
Tables are edited mostly by C++ routines of the editor (table-insert-row, table-insert-column, cell-set-format, table-set-format, …), which the Scheme code in
progs/table/
combines into commands. The mode predicate in-table? holds when the cursor is inside a table tag; the hooks use the finer predicate table-markup-context? (
generic/generic-edit.scm
), which recognizes the table environments (tabular, block, …) around a tformat or table.
table/table-edit.scm
The groups table-tag and wide-table-tag (which also make tabulars and blocks variants of each other); ↩ inserts a new row below the current one (or a paragraph break inside a multi-paragraph cell); the structured insertion and removal hooks insert and remove columns (horizontal) and rows (vertical); the geometry and swipe hooks change the horizontal and vertical alignment of the current cells (and geometry-default removes their formatting); and the commands behind the table and cell menus (table-set-halign, cell-set-span, cell-set-border, table-insert-blank-row, …). The setters cell-set-format* and table-set-format* keep the *-hmode and *-width (and the vertical counterparts) consistent.
table/table-kbd.scm
The ⌘⌃T… prefix (in the mode in-table?): ⌘⌃T⇧H, ⌘⌃T⇧V, ⌘⌃T⇧B and ⌘⌃T⇧P for table alignment, borders and padding, the lower case letters for cells, and ⌘⌃TM followed by C, H, V or T for the cell mode (set-cell-mode), which decides whether cell commands act on the current cell, row, column or the whole table.
table/table-menu.scm
The table and cell menus, and a redefinition of standard-focus-menu for tables, which shows the table and cell menus directly in the focus menu.
table/table-widgets.scm,
table/table-tools.scm
The table and cell property dialogs and side tools.
The directory
progs/dynamic/
groups the markup whose content changes during editing or presentation. Its modules are loaded lazily through their menus and keyboards (
init-texmacs.scm
); the folding, script and spreadsheet keyboards are registered for the mode always?, so their conditions are tested by the keymaps themselves.
dynamic/fold-edit.scm
handles three families of tags, recognized by dynamic-context?:
Tags with a folded and an unfolded form (the groups folded-tag and unfolded-tag, declared with define-fold in
dynamic/dynamic-drd.scm
, and summarized/detailed tags; toggle-context?). alternate-toggle switches between the two forms.
Tags with several branches of which one is shown (the groups alternative-tag, unroll-tag and expanded-tag; switch-context?). The routines switch-index, switch-to, switch-insert-at and switch-remove-at manipulate the branches; the structured insertion hooks insert and remove branches.
The overlays tag of presentations, with the current overlay number (overlays-current, overlays-switch-to).
On top of these, dynamic-extremal and dynamic-incremental (bound through dynamic-first, dynamic-last, dynamic-previous and dynamic-next) move to the first, last, previous or next state of the innermost dynamic tag; dynamic-operate-on-buffer and dynamic-traverse-buffer apply such an operation recursively to the whole document (or the current slide), which is how the presentation keys of
fold-kbd.scm
step through a talk. dynamic-make-slides converts a presentation into a sequence of slides, and the screens and slideshow routines (screens-switch-to, screens-show-all, …) implement the beamer style. At the end of the file, three of these entry points are redefined to call former and then move the cursor into the graphics of a graphical slide (gr-screen), so that slides made of pictures can be edited with the graphics editor.
dynamic/fold-markup.scm
contains the Scheme functions called from the rendering of screens (the slide index and the navigation links);
dynamic/fold-menu.scm
the insert menus and the presentation toolbars.
Sessions (session with input, output, errput, textput fields) and programs (program, a variant of sessions with the same kinds of fields) are edited by
dynamic/session-edit.scm
and the nearly identical
dynamic/program-edit.scm
. The editing side is:
context predicates for fields (field-context?, field-input-context?, field-folded-context?, …);
↩ in an input field evaluates it, or inserts a line break for multi-line input (session-multiline-input?, or ⇧↩); if the plug-in supports it, the plug-in is first asked whether the input is complete (input-done?);
the arrow keys, ↖/↘ and ⇞/⇟ move between fields (redefinitions of kbd-horizontal, … for field-context?); ⇥ asks the plug-in for completions;
structured insertion and removal of fields, folding of input/output pairs (alternate-toggle), splitting of sessions, and special cut and paste of whole fields.
The evaluation itself (session-evaluate and session-feed, the request queue and the callbacks which fill in the output) is described in the life of a session. Scheme sessions are evaluated directly by scheme-eval.
dynamic/scripts-edit.scm
evaluates expressions in place with the plug-in given by the prog-scripts environment variable: script-eval and script-approx replace a selection or formula by its value, script-apply applies a function, and the tags script-input/script-output keep the input together with the result (toggled with alternate-toggle). script-feed is the in-place analogue of session-feed. The same file implements plots (plot-curve, plot-surface, …, turned into Gnuplot commands by script-plot-command and evaluated through the plug-in) and converters (↩ in a converter-eval tag replaces it by its content converted from another format, such as LaTeX, with the snippet converters);
dynamic/scripts-plot.scm
the interactive plot editor.
Spreadsheets are tables whose cells may contain formulas (
dynamic/calc-table.scm
,
dynamic/calc-edit.scm
). Cells are named as in common spreadsheets (cell-name, cell-ref-encode); references to other cells and ranges in a formula are rewritten into calc-ref tags (cell-input-expand), and calc-now walks the document, collects the inputs which have to be recomputed, and sends them one by one to the scripting plug-in (calc-feed, which uses silent-feed*); each result is stored in the output field and in the table calc-output, and the next pending input is evaluated. calc schedules this after 250 ms of idle time. The keyboard of
calc-kbd.scm
is only active when a scripting plug-in is available (calc-ready?). The same machinery drives the generated exercises of the icourse style (calc-generate, calc-answer, calc-check).
dynamic/animate-edit.scm
inserts the animation tags (make-anim-constant, make-anim-translate-right, …), gives their parameters to the focus menu (customizable-parameters, parameter-choice-list), lets the geometry keys change their duration and speed (geometry-speed, geometry-horizontal), and controls time bending (accelerate-set-type, …) and playback (anim-play, reset-players). The rendering of the animations is done by the typesetter.