Changes for version 2.08 - 2026-11-12
- Ornaments (the manual's new section "Ornaments"; provisional): lines, polygons, rectangles and ovals drawn over or under the text, whose coordinates are reference points computed from the places where characters are drawn (the anchors of the box of a character or of a range, their weighted means, offsets, the x of one point with the y of another, minima and maxima), computed anew at every redisplay; with marks in their indices they follow the text. Subcommand "ornament" (create, delete, names, configure, cget, points, coords, point). Test t/ornament.t. Private marks: an index of an ornament that names no mark and no tag becomes a mark of the ornament's own, invisible to the program (mark names/next/previous, dump, block list; names starting with \001 are reserved), so that the point stays on its character; the wrappers [leftward => INDEX] and [rightward => INDEX] make one of a given gravity. An ornament all of whose indices are private marks is deleted with its text (option -keep prevents it); undo does not bring it back. The stand-in of a position that is not displayed takes the x the position had when last displayed (else the middle of the text area, or with the new widget option -ornamentproportional the place proportional to its offset in its line): no line is laid out for it any more. New points [line => I1, I2, N, ANCHOR] (the piece of a range on its N-th display line) and [outline => I1, I2] (all the corners of a range's outline, in a line or a polygon); anchors mw, m, me (the mid line) and [FX, FY] (fractions of the box). Types arc (-start, -extent, -style as on a canvas) and text (-text, -font, -anchor); distances of an offset in em and ex of the font of its point (emmin, emmid, emmax, exmin, exmid, exmax for the fonts of a range); the point [yx => P1, P2]. "mark next" skipped a mark at the very start of the first leaf of a block; "mark previous" missed the marks in the leaves of a block before the index but the first, and those after the block on its line (BUGS 35). A layout callback may return ornaments of the block among its lists: [TYPE, X1, Y1, ..., -option => value, ...], in pixels from the top left corner of the block, with the options of "ornament create"; drawn with the block every time it is drawn, under its text (among the stolen lines, in the order returned) or over it; not leaves; their options are parsed once per layout and kept with it. A bad one is a background error, as other bad results. (Manual: "Layout callback", "Ornaments of blocks".) Templates on a block type: "block configure TYPE -ornaments LIST", ornaments drawn for every displayed block of the type, whose points are computed from the boxes of the block and of its leaves with the new points [leaf => K, ANCHOR] and [block => ANCHOR] (and mix, offset, xy, yx, min, max of them; no indices). A template naming a leaf that is missing or not shown is not drawn for that block. "block cget TYPE -ornaments" gives the list. Demo: the strokes are ornaments instead of stolen lines (block addline still works, for the LR delimiters and the backgrounds): the Radical's sign is a broken line its layout callback returns, that grows with the contents (a tick, a stroke down to the bottom, up to the top left of the contents, the bar over them) instead of a glyph with a vertical line added for tall contents; the Fraction's bar is a template (-ornaments of the type); the rules of Table and SpanTable and the lines of Std are black rectangles returned by their callbacks. The tests that looked at the stolen lines of layout results look at the ornaments. Demo: a menu "Ornaments": "Box under selection" (a light filled rectangle under the selected text), "Arrow from mark" (the first use remembers the start of the selection in the mark ornArrowFrom, the second draws an arched red arrow from there to the selection), "Brace under selection" (an underbrace, a smoothed line sized in em), "Remove all". Their indices are the selection's ends, private marks of the ornaments. Test t/demo-ornaments.t. A smoothed ornament that is straight on a half pixel no longer jitters between two rows of pixels (rounding).
Modules
a Tk text widget with nestable "blocks" (editable formulas)