![]() |
Widgets reference guide | ![]() |
This is a reference list of all the keywords which may be used inside menu-bind, tm-menu and tm-widget definitions. The authoritative list is the table gui-make-table in
progs/kernel/gui/menu-define.scm
: each keyword is translated by gui-make into one of the $-macros of
progs/kernel/gui/gui-markup.scm
, and the resulting menu items are turned into actual widgets by make-menu-widget in
progs/kernel/gui/menu-widget.scm
. How this works is explained in “The Scheme widget language and its interpreter”.
In what follows, items stands for any number of menu items (widgets), label for a menu label (see below) and cmd for arbitrary Scheme code which is executed when the widget is activated. For input widgets, the code cmd is wrapped into a function of one argument, so that the value entered by the user is available in cmd as the variable answer. Most other arguments (lists of values, default values, predicates) are re-evaluated each time the widget is built.
A list whose first element is a label (a string or one of the label constructs below) is a menu entry: when it is selected, the remaining elements are evaluated as a Scheme body. Inside a window, the entry is rendered as a flat (toolbar style) button, unless it is enclosed in explicit-buttons. When the command is a function with an :interactive property, dots are appended to the label; a :check-mark property yields a check-mark, a :balloon or :synopsis property yields a tooltip, and a keyboard shortcut for the command is displayed automatically.
Displays the (translated) string s.
A title for a group of entries inside a menu.
Uses the pixmap file (for instance "tm_new.xpm", looked up in $TEXMACS_PIXMAP_PATH) as the label of an entry, as in ((icon "tm_new.xpm") (new-document)).
(concat s1 … sn)
(verbatim s1 … sn)
Labels made of several translatable strings, labels which should not be translated, and labels s containing placeholders %1, …, %n which are replaced by the (translated) arguments, as in ((replace "Open %1" (verbatim "my-init-texmacs.scm")) …).
Attaches the tooltip tooltip to the entry with label label, as in ((balloon (icon "tm_save.xpm") "Save this buffer") (save-buffer)).
Displays the check-mark mark (usually "v" or "*") in front of the entry whenever the predicate pred holds.
Displays the keyboard shortcut keys next to the entry, instead of the automatically found one.
(symbol sym)
A button showing the TeXmacs symbol sym (like "<alpha>"). By default, pressing it inserts the symbol; otherwise cmd is executed.
Produces no widget at all; used internally by push-focus.
Whitespace of minimal size w\(\times\)h (in pixels), which may extend horizontally and/or vertically. See “Containers, glue, refresh and co.”.
Like glue, but filled with the color (or pattern) col. Colored glue is typically used as the label of color selection buttons.
--- is a horizontal separator line (between the items of a vertical menu), | and / are vertical separators. The other symbols are abbreviations for glue: === and ====== for vertical space of 5 resp. 15 pixels, // and /// for horizontal space of 5 resp. 15 pixels, >> and >>> for horizontally extensible space.
A one line text field. type is a string such as "string", "password", "file", "directory", "search" or "replace-what", proposals a list of strings whose first element is the initial value, and width a length such as "20em" or "1w". The widths of the widgets are given in four units only: px, em (14 pixels), and w or h, a multiple of the default width or height of the widget in Qt and Cocoa, but of the extents of the window in Vue and Widkit (a field of "2w" is then wider than its window: prefer em in dialogs). cmd is executed with answer set to the entered string when the user confirms the input (or to #f when the input is cancelled).
A check box with initial state on?; cmd is executed with answer set to the new state.
A combo box with the list of strings vals and the current value val. If the last element of vals is "", then the user may also type an arbitrary value. See “Displaying lists and trees”.
(choice cmd vals val)
A list of items allowing for the selection of one resp. several items. For choices, selected and answer are lists.
Like choice, but with a text field on top which filters the displayed items; answer holds the selected item and filter the current contents of the filter field.
Displays the TeXmacs tree data; see “Displaying lists and trees”. Contrary to the other input widgets, cmd must be a procedure.
A color picker, which also allows for the selection of patterns if background? holds.
(pick-color cmd)
Tiles of buttons for standard colors, resp. colors and background patterns; cmd is executed with answer set to the selected color or pattern. In Vue, the color menu also offers a Palette enumeration: typographic palettes, defined with define-typographic-palette or define-typographic-palette-from-colors, replace the standard colors (preference typographic palette set).
(texmacs-output doc style)
A read-only resp. editable TeXmacs document doc (a tree or Scheme tree), typeset with the given style, such as '(style "generic"). For texmacs-input, name is the URL of the auxiliary buffer which holds the document (or #f).
An area for drawing with the mouse or a pen; answer contains the recorded strokes.
(setting-toggle cmd description on?)
(setting-enum cmd description vals val width)
Variants of toggle and enum which display an additional description text, and a titled group of such controls, intended for preference panels.
(-> label items)
A button which opens the submenu made of items to the right (pullright) resp. below (pulldown). The submenu is only built when it is opened.
(horizontal items)
Horizontal resp. vertical menus, such as menu bars and toolbars resp. ordinary menus.
Arranges items in a table with columns columns, as in the palettes for mathematical symbols; columns must be an integer written in the menu (not an expression).
(minibar items)
Small toolbars inside menus resp. items which are rendered in a smaller size when pred holds. Both only have an effect when the preference "use minibars" is on; otherwise the items are displayed normally.
Includes the menu defined by (menu-bind menu …); the menu is looked up each time the widget is built.
(hlist items)
Arrange items horizontally resp. vertically.
(aligned (item left right) …)
A two column table, typically with labels on the left and input widgets on the right. meti is item with the two arguments in the reverse order (so that a toggle can be written before its label).
(tabs (tab label items) …)
A tab widget with one page for each tab resp. icon-tab. The variants responsive-tabs / responsive-tab and responsive-icon-tabs / responsive-icon-tab have the same syntax but adapt their layout to the available space.
Tabs made of ordinary buttons, implemented in the widget language itself using refreshable; the index of the active tab is stored under the given name and key (see section-tab-ref).
(hsplit left right)
Two widgets separated by a movable border.
Puts items (vertically) inside a scroll area.
Sets the size of items. Each of w and h is evaluated and is either a length string, like "200px", or a list of three strings (minimal, default and maximal size), optionally followed by the initial position of the scrolled contents ("left", "center" or "right", resp. "top", "center" or "bottom"; only honoured by Vue). Lists must be quoted, as in (resize '("100px" "200px" "400px") "50px" …).
(padded items)
(centered items)
Surround items by fixed glue, center them, resp. put them as explicit buttons in a horizontal bar below a separator. These are expanded into combinations of vlist, hlist and glue.
(division name items)
Vertical resp. horizontal groups of items to which the style sheet class name (like "title", "plain") is applied; used for the side tools and dialogs when a style sheet is active.
Extends the size of widget to the maximum of the sizes of the items (the items themselves are not displayed). This is ignored by the Qt and Cocoa ports.
Render the entries of items as explicit buttons, as inactive (greyed out) widgets, in bold face, in grey, in a monospaced font, without translation of the labels; plain-style keeps the style as it is (it is meant to reset it, but its implementation, a style of 0 in make-menu-style, changes nothing).
(if pred items)
(when pred items)
if only shows items when pred holds, and when greys them out when it does not; in both cases, pred is re-evaluated each time the widget is built. assuming includes or omits the items once and for all when the menu is computed. Notice that there is no else branch.
(cond (pred items) …)
(let bindings items) (let* bindings items)
The usual Scheme (and TeXmacs) constructs, whose bodies are lists of widgets.
(for (x l) items)
Repeat items for each element x of the list l. For for, the list is re-evaluated each time the widget is built; for loop, only when the menu is computed.
Evaluates expr, which usually is a call of a function defined with tm-menu or tm-widget, and includes the resulting items. This is the standard way to reuse a widget with arguments inside another one, as in (dynamic (my-widget cmd)).
Evaluates expr, which should return a label or a menu item. For instance, (-> (eval (car p)) …) uses a computed label for a submenu.
Evaluates expr each time the widget is built; the result must be a menu item.
Inside a redefinition of a menu with menu-bind or tm-menu, includes the items of the previous definition. See contextual overloading.
Builds items with the variables pushed-tree and pushed-focus bound to t and its fingerprint; used by the focus menus and toolbars.
(refreshable kind items)
(refresh widget kind)
(refresh widget)
A refreshable group of items is rebuilt each time (refresh-now kind) is called, where kind is (an expression evaluating to) a string. refresh includes the menu or widget widget (the name of a menu-bind or of a tm-widget without arguments, not evaluated) in the same way; here kind is written as a symbol, as in (refresh my-widget auto); without kind, the kind is the name of the widget. Widgets of kind "auto" are also refreshed automatically after each user command, and widgets of kind "any" by any call of refresh-now. A cached group is rebuilt at a refresh-now of its kind only if valid? does not hold or after (invalidate-now kind). A refresh makes the widgets again from the items computed when the enclosing widget was built: texts, labels and dynamic keep their value, while conditions, for lists and promises are evaluated again. See “Containers, glue, refresh and co.”.
(form name items)
(form-input field type proposals width)
(form-enum field vals val width)
(form-choice field vals val)
(form-choices field vals selected)
Named input fields whose values are stored under the name of the enclosing form; see “Forms”.