-- This file: -- https://anggtwu.net/LUA/DiagTeX1.lua.html -- https://anggtwu.net/LUA/DiagTeX1.lua -- (find-angg "LUA/DiagTeX1.lua") -- Author: Eduardo Ochs -- Version: 2026may24 -- Used by: -- -- A partial replacement for: -- (find-dn6 "diagtex.lua") -- (find-dn6 "diagtex.lua" "arrow_to_TeX") -- (find-dn6 "diagtex.lua" "DxyArrow" "arrow_to_TeX") -- (find-dn6 "diagforth.lua") -- This file overrides some functions from diagtex.lua and defines a -- new word in forths[]. -- New: diag_wrap = function (fmt,body) return format(fmt or "%s", body) end -- Overrides for functions from: -- (find-dn6 "diagtex.lua" "DxyArrow" "arrow_to_TeX") -- node_to_TeX = function (node) local tex = node.tex or node.tag local TeX = node.TeX or (tex and unabbrev(tex)) return (TeX and "{"..TeX.."}") or "" end arrow_to_TeX = function (arrow) local node1 = nodes[arrow.from] local node2 = nodes[arrow.to] local x1, y1 = realxy(node1.x, node1.y) local x2, y2 = realxy(node2.x, node2.y) local dx, dy = x2 - x1, y2 - y1 local N1 = node_to_TeX(node1) local N2 = node_to_TeX(node2) -- -- 2026may24: N1 = diag_wrap(arrow.wrap_from, N1) N2 = diag_wrap(arrow.wrap_to, N2) -- -- Calculate p, sh, L. -- In several complex cases the "placement" p and the "label" L -- are moved into the "shape" parameter sh; see: -- (find-es "diagxy" "shape") local p, sh, L = arrow_to_TeX_pshL(arrow) -- defined below local morphism = dformat("\\morphism(%d,%d)%s%s<%d,%d>[%s`%s;%s]", x1, y1, p, sh, dx, dy, N1, N2, L) return diag_wrap(arrow.wrap_morphism, morphism) end arrow_to_TeX_pshL = function (arrow) local Label = arrow.Label or (arrow.label and unabbrev(arrow.label)) local L = Label and "{"..Label.."}" or "" local p = arrow.placement and "|"..arrow.placement.."|" or "" local lplace = arrow.lplacement and arrow.lplacement.."{"..Label.."}" -- -- 2026may24: L = diag_wrap(arrow.wrap_label, L) -- local shape = arrow.shape or "->" local slide = arrow.slide and "@<"..arrow.slide..">" local curve = arrow.curve and "@/"..arrow.curve.."/" local modifier if slide or curve or lplace then modifier = (lplace or "")..(slide or "")..(curve or "") end if arrow.modifier then modifier = arrow.modifier end -- temp hack if modifier then sh = format("/{@{%s}%s}/", shape, modifier) else sh = "/"..shape.."/" end if lplace then p = "||"; L = "" end return p, sh, L end -- New, based on: -- (find-dn6 "diagforth.lua" "arrow-modifiers") forths = forths or {} -- for tests forths[".arrowColor="] = function () local Color = getword() or error() ds:pick(0).wrap_morphism = "\\Color"..Color.."{%s}%%" ds:pick(0).wrap_label = "\\ColorBlack{%s}" ds:pick(0).wrap_from = "\\ColorBlack{%s}" ds:pick(0).wrap_to = "\\ColorBlack{%s}" end --[[  (eepitch-lua51)  (eepitch-kill)  (eepitch-lua51) dofile "DiagTeX1.lua" --]] -- (defun e () (interactive) (find-angg "LUA/DiagTeX1.lua")) -- Local Variables: -- coding: utf-8-unix -- End: