summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--context/data/scite/lexers/data/scite-context-data-context.lua4
-rw-r--r--context/data/scite/lexers/data/scite-context-data-metapost.lua2
-rw-r--r--metapost/context/base/metafun.mpiv26
-rw-r--r--metapost/context/base/mp-butt.mp108
-rw-r--r--metapost/context/base/mp-char.mp21
-rw-r--r--metapost/context/base/mp-flow.mpiv1020
-rw-r--r--metapost/context/base/mp-shap.mp471
-rw-r--r--scripts/context/lua/mtxrun.lua4
-rw-r--r--scripts/context/stubs/mswin/mtxrun.lua4
-rw-r--r--scripts/context/stubs/unix/mtxrun4
-rw-r--r--tex/context/base/back-ini.lua9
-rw-r--r--tex/context/base/back-pdf.mkiv34
-rw-r--r--tex/context/base/chem-str.lua4
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4095 -> 4097 bytes
-rw-r--r--tex/context/base/context-version.pngbin105125 -> 105431 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/core-env.mkiv20
-rw-r--r--tex/context/base/file-job.mkvi3
-rw-r--r--tex/context/base/font-def.lua2
-rw-r--r--tex/context/base/font-otf.lua22
-rw-r--r--tex/context/base/font-ott.lua65
-rw-r--r--tex/context/base/lpdf-ano.lua4
-rw-r--r--tex/context/base/lxml-tex.lua74
-rw-r--r--tex/context/base/m-chart.mkiv1358
-rw-r--r--tex/context/base/m-chart.tex18
-rw-r--r--tex/context/base/m-flow.lua631
-rw-r--r--tex/context/base/m-flow.mkvi482
-rw-r--r--tex/context/base/mlib-pdf.lua40
-rw-r--r--tex/context/base/mlib-pps.lua10
-rw-r--r--tex/context/base/mlib-pps.mkiv13
-rw-r--r--tex/context/base/mult-low.lua5
-rw-r--r--tex/context/base/mult-mps.lua1
-rw-r--r--tex/context/base/pack-rul.mkiv42
-rw-r--r--tex/context/base/page-one.mkiv2
-rw-r--r--tex/context/base/s-art-01.mkiv36
-rw-r--r--tex/context/base/status-files.pdfbin23920 -> 23951 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin162873 -> 163152 bytes
-rw-r--r--tex/context/base/strc-ini.lua11
-rw-r--r--tex/context/base/strc-ref.mkvi2
-rw-r--r--tex/context/base/trac-set.lua4
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua26
44 files changed, 2799 insertions, 1791 deletions
diff --git a/context/data/scite/lexers/data/scite-context-data-context.lua b/context/data/scite/lexers/data/scite-context-data-context.lua
index 4142d2a29..edb3087f3 100644
--- a/context/data/scite/lexers/data/scite-context-data-context.lua
+++ b/context/data/scite/lexers/data/scite-context-data-context.lua
@@ -1,4 +1,4 @@
return {
- ["constants"]={ "zerocount", "minusone", "minustwo", "plusone", "plustwo", "plusthree", "plusfour", "plusfive", "plussix", "plusseven", "pluseight", "plusnine", "plusten", "plussixteen", "plushundred", "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "zeropoint", "onepoint", "onebasepoint", "maxdimen", "scaledpoint", "thousandpoint", "points", "zeroskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "endoflinetoken", "outputnewlinechar", "emptytoks", "empty", "undefined", "voidbox", "emptybox", "emptyvbox", "emptyhbox", "bigskipamount", "medskipamount", "smallskipamount", "fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "luatexengine", "pdftexengine", "xetexengine", "unknownengine", "etexversion", "pdftexversion", "xetexversion", "xetexrevision", "activecatcode", "bgroup", "egroup", "endline", "attributeunsetvalue", "uprotationangle", "rightrotatioangle", "downrotatioangle", "leftrotatioangle", "startmode", "stopmode", "startnotmode", "stopnotmode", "doifmode", "doifmodeelse", "doifnotmode", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", "starttext", "stoptext" },
- ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "htdp", "unvoidbox", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "scratchwidth", "scratchheight", "scratchdepth", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextparenthesiselse", "doiffastoptionalcheckelse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "tracingall", "tracingnone", "loggingall", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "endgraf", "empty", "null", "space", "obeyspaces", "obeylines", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "wait", "writestatus", "define", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "measure", "getvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse" },
+ ["constants"]={ "zerocount", "minusone", "minustwo", "plusone", "plustwo", "plusthree", "plusfour", "plusfive", "plussix", "plusseven", "pluseight", "plusnine", "plusten", "plussixteen", "plushundred", "plusthousand", "plustenthousand", "plustwentythousand", "medcard", "maxcard", "zeropoint", "onepoint", "onebasepoint", "maxdimen", "scaledpoint", "thousandpoint", "points", "zeroskip", "pluscxxvii", "pluscxxviii", "pluscclv", "pluscclvi", "endoflinetoken", "outputnewlinechar", "emptytoks", "empty", "undefined", "voidbox", "emptybox", "emptyvbox", "emptyhbox", "bigskipamount", "medskipamount", "smallskipamount", "fmtname", "fmtversion", "texengine", "texenginename", "texengineversion", "luatexengine", "pdftexengine", "xetexengine", "unknownengine", "etexversion", "pdftexversion", "xetexversion", "xetexrevision", "activecatcode", "bgroup", "egroup", "endline", "attributeunsetvalue", "uprotationangle", "rightrotatioangle", "downrotatioangle", "leftrotatioangle", "startmode", "stopmode", "startnotmode", "stopnotmode", "doifmode", "doifmodeelse", "doifnotmode", "startenvironment", "stopenvironment", "environment", "startcomponent", "stopcomponent", "component", "startproduct", "stopproduct", "product", "startproject", "stopproject", "project", "starttext", "stoptext", "startmodule", "stopmodule", "usemodule" },
+ ["helpers"]={ "startsetups", "stopsetups", "startxmlsetups", "stopxmlsetups", "starttexdefinition", "stoptexdefinition", "starttexcode", "stoptexcode", "newcount", "newdimen", "newskip", "newmuskip", "newbox", "newtoks", "newread", "newwrite", "newmarks", "newinsert", "newattribute", "newif", "newlanguage", "newfamily", "newfam", "newhelp", "htdp", "unvoidbox", "scratchcounter", "globalscratchcounter", "scratchdimen", "globalscratchdimen", "scratchskip", "globalscratchskip", "scratchmuskip", "globalscratchmuskip", "scratchtoks", "globalscratchtoks", "scratchbox", "globalscratchbox", "scratchwidth", "scratchheight", "scratchdepth", "scratchcounterone", "scratchcountertwo", "scratchcounterthree", "scratchdimenone", "scratchdimentwo", "scratchdimenthree", "scratchskipone", "scratchskiptwo", "scratchskipthree", "scratchmuskipone", "scratchmuskiptwo", "scratchmuskipthree", "scratchtoksone", "scratchtokstwo", "scratchtoksthree", "scratchboxone", "scratchboxtwo", "scratchboxthree", "doif", "doifnot", "doifelse", "doifinset", "doifnotinset", "doifinsetelse", "doifnextcharelse", "doifnextoptionalelse", "doifnextparenthesiselse", "doiffastoptionalcheckelse", "doifundefinedelse", "doifdefinedelse", "doifundefined", "doifdefined", "doifelsevalue", "doifvalue", "doifnotvalue", "doifnothing", "doifsomething", "doifelsenothing", "doifsomethingelse", "doifvaluenothing", "doifvaluesomething", "doifelsevaluenothing", "doifdimensionelse", "doifnumberelse", "doifcommonelse", "doifcommon", "doifnotcommon", "doifinstring", "doifnotinstring", "doifinstringelse", "tracingall", "tracingnone", "loggingall", "appendtoks", "prependtoks", "appendtotoks", "prependtotoks", "to", "endgraf", "empty", "null", "space", "obeyspaces", "obeylines", "normalspace", "executeifdefined", "singleexpandafter", "doubleexpandafter", "tripleexpandafter", "dontleavehmode", "wait", "writestatus", "define", "redefine", "setmeasure", "setemeasure", "setgmeasure", "setxmeasure", "definemeasure", "measure", "getvalue", "setvalue", "setevalue", "setgvalue", "setxvalue", "letvalue", "letgvalue", "resetvalue", "undefinevalue", "ignorevalue", "setuvalue", "setuevalue", "setugvalue", "setuxvalue", "globallet", "glet", "getparameters", "geteparameters", "getgparameters", "getxparameters", "forgetparameters", "processcommalist", "processcommacommand", "quitcommalist", "quitprevcommalist", "processaction", "processallactions", "processfirstactioninset", "processallactionsinset", "unexpanded", "expanded", "startexpanded", "stopexpanded", "protected", "protect", "unprotect", "firstofoneargument", "firstoftwoarguments", "secondoftwoarguments", "firstofthreearguments", "secondofthreearguments", "thirdofthreearguments", "firstoffourarguments", "secondoffourarguments", "thirdoffourarguments", "fourthoffourarguments", "firstoffivearguments", "secondoffivearguments", "thirdoffivearguments", "fourthoffivearguments", "fifthoffivearguments", "firstofsixarguments", "secondofsixarguments", "thirdofsixarguments", "fourthofsixarguments", "fifthofsixarguments", "sixthofsixarguments", "gobbleoneargument", "gobbletwoarguments", "gobblethreearguments", "gobblefourarguments", "gobblefivearguments", "gobblesixarguments", "gobblesevenarguments", "gobbleeightarguments", "gobbleninearguments", "gobbletenarguments", "gobbleoneoptional", "gobbletwooptionals", "gobblethreeoptionals", "gobblefouroptionals", "gobblefiveoptionals", "dorecurse", "doloop", "exitloop", "dostepwiserecurse", "recurselevel", "recursedepth", "newconstant", "setnewconstant", "newconditional", "settrue", "setfalse", "dosingleempty", "dodoubleempty", "dotripleempty", "doquadrupleempty", "doquintupleempty", "dosixtupleempty", "doseventupleempty", "dosinglegroupempty", "dodoublegroupempty", "dotriplegroupempty", "doquadruplegroupempty", "doquintuplegroupempty", "nopdfcompression", "maximumpdfcompression", "normalpdfcompression", "modulonumber", "dividenumber", "getfirstcharacter", "doiffirstcharelse", "startnointerference", "stopnointerference" },
} \ No newline at end of file
diff --git a/context/data/scite/lexers/data/scite-context-data-metapost.lua b/context/data/scite/lexers/data/scite-context-data-metapost.lua
index bf1bc645d..ebbe22c98 100644
--- a/context/data/scite/lexers/data/scite-context-data-metapost.lua
+++ b/context/data/scite/lexers/data/scite-context-data-metapost.lua
@@ -1,5 +1,5 @@
return {
["plain"]={ "ahangle", "ahlength", "bboxmargin", "defaultpen", "defaultscale", "labeloffset", "background", "currentpen", "currentpicture", "cuttings", "defaultfont", "extra_beginfig", "extra_endfig", "beveled", "black", "blue", "bp", "butt", "cc", "cm", "dd", "ditto", "down", "epsilon", "evenly", "fullcircle", "green", "halfcircle", "identity", "in", "infinity", "left", "mitered", "mm", "origin", "pensquare", "pt", "quartercircle", "red", "right", "rounded", "squared", "unitsquare", "up", "white", "withdots", "abs", "bbox", "ceiling", "center", "cutafter", "cutbefore", "dir", "directionpoint", "div", "dotprod", "intersectionpoint", "inverse", "mod", "lft", "round", "rt", "unitvector", "whatever", "cutdraw", "draw", "drawarrow", "drawdblarrow", "fill", "filldraw", "drawdot", "loggingall", "pickup", "tracingall", "tracingnone", "undraw", "unfill", "unfilldraw", "buildcycle", "dashpattern", "decr", "dotlabel", "dotlabels", "drawoptions", "incr", "label", "labels", "max", "min", "thelabel", "z", "beginchar", "blacker", "capsule_end", "change_width", "define_blacker_pixels", "define_corrected_pixels", "define_good_x_pixels", "define_good_y_pixels", "define_horizontal_corrected_pixels", "define_pixels", "define_whole_blacker_pixels", "define_whole_pixels", "define_whole_vertical_blacker_pixels", "define_whole_vertical_pixels", "endchar", "extra_beginchar", "extra_endchar", "extra_setup", "font_coding_scheme", "clearxy", "font_extra_space" },
- ["primitives"]={ "charcode", "day", "linecap", "linejoin", "miterlimit", "month", "pausing", "prologues", "showstopping", "time", "tracingcapsules", "tracingchoices", "mpprocset", "tracingcommands", "tracingequations", "tracinglostchars", "tracingmacros", "tracingonline", "tracingoutput", "tracingrestores", "tracingspecs", "tracingstats", "tracingtitles", "truecorners", "warningcheck", "year", "false", "nullpicture", "pencircle", "true", "and", "angle", "arclength", "arctime", "ASCII", "bluepart", "boolean", "bot", "char", "color", "cosd", "cycle", "decimal", "directiontime", "floor", "fontsize", "greenpart", "hex", "infont", "intersectiontimes", "known", "length", "llcorner", "lrcorner", "makepath", "makepen", "mexp", "mlog", "normaldeviate", "not", "numeric", "oct", "odd", "or", "path", "pair", "pen", "penoffset", "picture", "point", "postcontrol", "precontrol", "redpart", "reverse", "rotated", "scaled", "shifted", "sind", "slanted", "sqrt", "str", "string", "subpath", "substring", "transform", "transformed", "ulcorner", "uniformdeviate", "unknown", "urcorner", "xpart", "xscaled", "xxpart", "xypart", "ypart", "yscaled", "yxpart", "yypart", "zscaled", "addto", "clip", "input", "interim", "let", "newinternal", "save", "setbounds", "shipout", "show", "showdependencies", "showtoken", "showvariable", "special", "rgbcolor", "cmykcolor", "graycolor", "begingroup", "endgroup", "of", "curl", "tension", "and", "controls", "reflectedabout", "rotatedaround", "interpath", "on", "off", "beginfig", "endfig", "def", "vardef", "enddef", "expr", "suffix", "text", "primary", "secondary", "tertiary", "primarydef", "secondarydef", "tertiarydef", "top", "bottom", "ulft", "urt", "llft", "lrt", "randomseed", "also", "contour", "doublepath", "withcolor", "withpen", "dashed", "if", "else", "elseif", "fi", "for", "endfor", "forever", "exitif", "forsuffixes", "downto", "upto", "step", "until", "charlist", "extensible", "fontdimen", "headerbyte", "kern", "ligtable", "boundarychar", "chardp", "charext", "charht", "charic", "charwd", "designsize", "fontmaking", "charexists", "cullit", "currenttransform", "gfcorners", "grayfont", "hround", "imagerules", "lowres_fix", "nodisplays", "notransforms", "openit", "displaying", "currentwindow", "screen_rows", "screen_cols", "pixels_per_inch", "cull", "display", "openwindow", "numspecial", "totalweight", "autorounding", "fillin", "proofing", "tracingpens", "xoffset", "chardx", "granularity", "smoothing", "turningcheck", "yoffset", "chardy", "hppp", "tracingedges", "vppp", "extra_beginfig", "extra_endfig", "mpxbreak" },
+ ["primitives"]={ "charcode", "day", "linecap", "linejoin", "miterlimit", "month", "pausing", "prologues", "showstopping", "time", "tracingcapsules", "tracingchoices", "mpprocset", "tracingcommands", "tracingequations", "tracinglostchars", "tracingmacros", "tracingonline", "tracingoutput", "tracingrestores", "tracingspecs", "tracingstats", "tracingtitles", "truecorners", "warningcheck", "year", "false", "nullpicture", "pencircle", "true", "and", "angle", "arclength", "arctime", "ASCII", "bluepart", "boolean", "bot", "char", "color", "cosd", "cycle", "decimal", "directiontime", "floor", "fontsize", "greenpart", "hex", "infont", "intersectiontimes", "known", "length", "llcorner", "lrcorner", "makepath", "makepen", "mexp", "mlog", "normaldeviate", "not", "numeric", "oct", "odd", "or", "path", "pair", "pen", "penoffset", "picture", "point", "postcontrol", "precontrol", "redpart", "reverse", "rotated", "scaled", "shifted", "sind", "slanted", "sqrt", "str", "string", "subpath", "substring", "transform", "transformed", "ulcorner", "uniformdeviate", "unknown", "urcorner", "xpart", "xscaled", "xxpart", "xypart", "ypart", "yscaled", "yxpart", "yypart", "zscaled", "addto", "clip", "input", "interim", "let", "newinternal", "save", "setbounds", "shipout", "show", "showdependencies", "showtoken", "showvariable", "special", "rgbcolor", "cmykcolor", "graycolor", "begingroup", "endgroup", "of", "curl", "tension", "and", "controls", "reflectedabout", "rotatedaround", "interpath", "on", "off", "beginfig", "endfig", "def", "vardef", "enddef", "expr", "suffix", "text", "primary", "secondary", "tertiary", "primarydef", "secondarydef", "tertiarydef", "top", "bottom", "ulft", "urt", "llft", "lrt", "randomseed", "also", "contour", "doublepath", "withcolor", "withpen", "dashed", "if", "else", "elseif", "fi", "for", "endfor", "forever", "exitif", "forsuffixes", "downto", "upto", "step", "until", "charlist", "extensible", "fontdimen", "headerbyte", "kern", "ligtable", "boundarychar", "chardp", "charext", "charht", "charic", "charwd", "designsize", "fontmaking", "charexists", "cullit", "currenttransform", "gfcorners", "grayfont", "hround", "imagerules", "lowres_fix", "nodisplays", "notransforms", "openit", "displaying", "currentwindow", "screen_rows", "screen_cols", "pixels_per_inch", "cull", "display", "openwindow", "numspecial", "totalweight", "autorounding", "fillin", "proofing", "tracingpens", "xoffset", "chardx", "granularity", "smoothing", "turningcheck", "yoffset", "chardy", "hppp", "tracingedges", "vppp", "extra_beginfig", "extra_endfig", "mpxbreak", "endinput" },
["tex"]={ "btex", "etex", "verbatimtex" },
} \ No newline at end of file
diff --git a/metapost/context/base/metafun.mpiv b/metapost/context/base/metafun.mpiv
index 89a7c3935..c58d5dc15 100644
--- a/metapost/context/base/metafun.mpiv
+++ b/metapost/context/base/metafun.mpiv
@@ -17,21 +17,21 @@
%D copy.
input mp-base.mpiv ;
-input mp-tool.mp ;
+input mp-tool.mp ;
input mp-core.mpiv ;
-input mp-page.mp ;
-input mp-text.mp ;
-input mp-txts.mp ;
-input mp-shap.mp ;
-input mp-butt.mp ;
-input mp-char.mp ;
-input mp-step.mp ;
-input mp-grph.mp ;
-input mp-figs.mp ;
+input mp-page.mp ;
+input mp-text.mp ;
+input mp-txts.mp ;
+input mp-butt.mp ;
+% mp-shap.mp ; % there no need to always load this
+% mp-char.mp ; % there no need to always load this
+input mp-step.mp ; % there no need to always load this (todo)
+input mp-grph.mp ;
+input mp-figs.mp ;
input mp-mlib.mpiv ;
-input mp-chem.mpiv ;
-input mp-grid.mp ;
-input mp-func.mp ;
+input mp-chem.mpiv ; % there no need to always load this (todo)
+input mp-grid.mp ;
+input mp-func.mp ;
string metafunversion ;
diff --git a/metapost/context/base/mp-butt.mp b/metapost/context/base/mp-butt.mp
index cf580211e..3ae3dc983 100644
--- a/metapost/context/base/mp-butt.mp
+++ b/metapost/context/base/mp-butt.mp
@@ -1,6 +1,6 @@
%D \module
%D [ file=mp-butt.mp,
-%D version=2000.05.31,
+%D version=2000.05.31,
%D title=\CONTEXT\ \METAPOST\ graphics,
%D subtitle=buttons,
%D author=Hans Hagen,
@@ -8,68 +8,64 @@
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
-%C details.
+%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
+%C details.
-if unknown context_tool : input mp-tool ; fi ;
-if known context_butt : endinput ; fi ;
+if unknown context_tool : input mp-tool ; fi ;
+if known context_butt : endinput ; fi ;
-boolean context_butt ; context_butt := true ;
+boolean context_butt ; context_butt := true ;
-def some_button (expr button_type ,
- button_size ,
- button_linecolor ,
- button_fillcolor ) =
+def some_button (expr button_type, button_size, button_linecolor, button_fillcolor) =
- numeric button_linewidth ; button_linewidth := button_size/10 ;
+ numeric button_linewidth ; button_linewidth := button_size/10 ;
- drawoptions (withpen pencircle scaled button_linewidth
- withcolor button_linecolor) ;
+ drawoptions (withpen pencircle scaled button_linewidth withcolor button_linecolor) ;
- path p ; p := unitsquare scaled button_size ;
- numeric d ; d := button_size ;
- numeric l ; l := button_linewidth ;
+ path p ; p := unitsquare scaled button_size ;
+ numeric d ; d := button_size ;
+ numeric l ; l := button_linewidth ;
- fill p withcolor button_fillcolor ; draw p ;
+ fill p withcolor button_fillcolor ; draw p ;
- if button_type=101 :
- draw (d-2l,2l)--(2l,.5d)--(d-2l,d-2l)--cycle ;
- elseif button_type=102 :
- draw (2l,2l)--(d-2l,.5d)--(2l,d-2l)--cycle ;
- elseif button_type=103 :
- for i=2l step 2l until d-2l :
- draw (2l,i)--(2l ,i) ;
- draw (4l,i)--(d-2l,i) ;
- endfor ;
- elseif button_type=104 :
- for i=2l step 2l until d-2l :
- draw (2l ,i)--(d/2-l,i) ;
- draw (d/2+l,i)--(d-2l ,i) ;
- endfor ;
- elseif button_type=105 :
- fill fullcircle scaled (.2d) shifted (.5d,.7d) ;
- fill fullcircle xscaled (.6d) yscaled d shifted (.5d,0) ;
- clip currentpicture to p ;
- draw p ;
- elseif button_type=106 :
- draw (2l,2l)--(d-2l,d-2l) ;
- draw (d-2l,2l)--(2l,d-2l) ;
- elseif button_type=107 :
- p := (3l,d-2l)--(d-3l,d-2l)--(.5d,4l)--cycle ;
- fill p ; draw p ;
- draw (.5d,2l) ;
- elseif button_type=108 :
- draw (.5d,2l)--(d-2l,d-2l)--(2l,d-2l)--cycle ;
- elseif button_type=109 :
- draw (.5d,d-2l)--(d-2l,2l)--(2l,2l)--cycle ;
- elseif button_type=110 :
- button_linewidth := button_linewidth/2 ;
- draw p enlarged (-2l,-l) ;
- for i=2l step l until d-2l :
- draw (3l,i)--(d-3l,i) ;
- endfor ;
- fi ;
+ if button_type = 101 :
+ draw (d-2l,2l)--(2l,.5d)--(d-2l,d-2l)--cycle ;
+ elseif button_type = 102 :
+ draw (2l,2l)--(d-2l,.5d)--(2l,d-2l)--cycle ;
+ elseif button_type = 103 :
+ for i=2l step 2l until d-2l :
+ draw (2l,i)--(2l ,i) ;
+ draw (4l,i)--(d-2l,i) ;
+ endfor ;
+ elseif button_type = 104 :
+ for i=2l step 2l until d-2l :
+ draw (2l ,i)--(d/2-l,i) ;
+ draw (d/2+l,i)--(d-2l ,i) ;
+ endfor ;
+ elseif button_type = 105 :
+ fill fullcircle scaled (.2d) shifted (.5d,.7d) ;
+ fill fullcircle xscaled (.6d) yscaled d shifted (.5d,0) ;
+ clip currentpicture to p ;
+ draw p ;
+ elseif button_type = 106 :
+ draw (2l,2l)--(d-2l,d-2l) ;
+ draw (d-2l,2l)--(2l,d-2l) ;
+ elseif button_type = 107 :
+ p := (3l,d-2l)--(d-3l,d-2l)--(.5d,4l)--cycle ;
+ fill p ; draw p ;
+ draw (.5d,2l) ;
+ elseif button_type = 108 :
+ draw (.5d,2l)--(d-2l,d-2l)--(2l,d-2l)--cycle ;
+ elseif button_type = 109 :
+ draw (.5d,d-2l)--(d-2l,2l)--(2l,2l)--cycle ;
+ elseif button_type = 110 :
+ button_linewidth := button_linewidth/2 ;
+ draw p enlarged (-2l,-l) ;
+ for i=2l step l until d-2l :
+ draw (3l,i)--(d-3l,i) ;
+ endfor ;
+ fi ;
-enddef ;
+enddef ;
-endinput ;
+endinput ;
diff --git a/metapost/context/base/mp-char.mp b/metapost/context/base/mp-char.mp
index fd9e33848..3a7a1d939 100644
--- a/metapost/context/base/mp-char.mp
+++ b/metapost/context/base/mp-char.mp
@@ -111,6 +111,7 @@ def new_chart =
color xydraw [][] ;
numeric xyline [][] ;
boolean xypeep [][] ;
+ picture xypicture[][] ;
numeric cpath ; cpath := 0 ;
path cpaths [] ;
@@ -233,6 +234,15 @@ def flush_shapes =
endfor ;
enddef ;
+def flush_pictures =
+ for x=1 upto max_x :
+ for y=1 upto max_y :
+ flush_picture (x, y) ;
+ endfor ;
+ endfor ;
+enddef ;
+
+
def draw_connection_point (expr x, y, z) =
pickup pencircle scaled if (z=0): 2 fi xyline[x][y] ;
drawdot xy_bottom(x,y,z,false) scaled_to_grid withcolor (1,0,0) ;
@@ -450,6 +460,16 @@ def draw_midpoint (expr n) =
endgroup ;
enddef ;
+def flush_picture(expr x, y) =
+ if known xypicture[x][y]:
+ draw xypicture[x][y] shifted xy_offset((x+0.5)*grid_width,(max_y-y+1.5)*grid_height) ;
+ fi ;
+enddef ;
+
+def chart_draw_picture(expr x, y, p) =
+ xypicture[x][y] := p ;
+enddef ;
+
boolean reverse_connection ; reverse_connection := false ;
vardef up_on_grid (expr n) =
@@ -911,6 +931,7 @@ enddef ;
def end_chart =
flush_shapes ;
flush_connections ;
+ flush_pictures ;
cmin_x := cmin_x ;
cmax_x := cmin_x+cmax_x ;
cmin_y := cmin_y-1 ;
diff --git a/metapost/context/base/mp-flow.mpiv b/metapost/context/base/mp-flow.mpiv
new file mode 100644
index 000000000..c134f28d8
--- /dev/null
+++ b/metapost/context/base/mp-flow.mpiv
@@ -0,0 +1,1020 @@
+%D \module
+%D [ file=mp-char.mp,
+%D version=2011.10.1, % 1998.10.10,
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=charts,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
+%C details.
+
+%D This is ancient code .. but I see no need to rewrite it.
+
+if unknown context_tool : input mp-tool ; fi ;
+if unknown context_shap : input mp-shap ; fi ;
+if known context_flow : endinput ; fi ;
+
+boolean context_flow ; context_flow := true ;
+
+%D settings
+
+numeric flow_grid_width ; flow_grid_width := 60pt ;
+numeric flow_shape_width ; flow_shape_width := 45pt ;
+numeric flow_grid_height ; flow_grid_height := 40pt ;
+numeric flow_shape_height ; flow_shape_height := 30pt ;
+numeric flow_chart_offset ; flow_chart_offset := 2pt ;
+color flow_chart_background_color ; flow_chart_background_color := white ;
+boolean flow_show_mid_points ; flow_show_mid_points := false ;
+boolean flow_show_con_points ; flow_show_con_points := false ;
+boolean flow_show_all_points ; flow_show_all_points := false ;
+numeric flow_shape_line_width ; flow_shape_line_width := 2pt ;
+color flow_shape_line_color ; flow_shape_line_color := .5white ;
+color flow_shape_fill_color ; flow_shape_fill_color := .9white ;
+color flow_connection_line_color ; flow_connection_line_color := .2white ;
+
+numeric flow_connection_line_width ; flow_connection_line_width := flow_shape_line_width ;
+
+numeric flow_connection_smooth_size ; flow_connection_smooth_size := 5pt ;
+numeric flow_connection_arrow_size ; flow_connection_arrow_size := 4pt ;
+numeric flow_connection_dash_size ; flow_connection_dash_size := 3pt ;
+
+numeric flow_max_x ; flow_max_x := 6 ;
+numeric flow_max_y ; flow_max_y := 4 ;
+
+boolean flow_smooth ; flow_smooth := true ;
+boolean flow_peepshape ; flow_peepshape := false ;
+boolean flow_arrowtip ; flow_arrowtip := true ;
+boolean flow_dashline ; flow_dashline := false ;
+boolean flow_forcevalid ; flow_forcevalid := false ;
+boolean flow_touchshape ; flow_touchshape := false ;
+boolean flow_showcrossing ; flow_showcrossing := false ;
+boolean flow_reverse_y ; flow_reverse_y := true ;
+
+picture flow_dash_pattern ; flow_dash_pattern := nullpicture ;
+
+numeric flow_shape_node ; flow_shape_node := 0 ;
+numeric flow_shape_action ; flow_shape_action := 24 ;
+numeric flow_shape_procedure ; flow_shape_procedure := 5 ;
+numeric flow_shape_product ; flow_shape_product := 12 ;
+numeric flow_shape_decision ; flow_shape_decision := 14 ;
+numeric flow_shape_archive ; flow_shape_archive := 19 ;
+numeric flow_shape_loop ; flow_shape_loop := 35 ;
+numeric flow_shape_wait ; flow_shape_wait := 6 ;
+numeric flow_shape_subprocedure ; flow_shape_subprocedure := 20 ;
+numeric flow_shape_singledocument ; flow_shape_singledocument := 32 ;
+numeric flow_shape_multidocument ; flow_shape_multidocument := 33 ;
+numeric flow_shape_right ; flow_shape_right := 66 ;
+numeric flow_shape_left ; flow_shape_left := 67 ;
+numeric flow_shape_up ; flow_shape_up := 68 ;
+numeric flow_shape_down ; flow_shape_down := 69 ;
+
+% vardef some_shape_path (expr type) == imported from mp-shap
+
+def flow_show_shapes(expr n) =
+ flow_begin_chart(n,8,10) ;
+ flow_show_con_points := true ;
+ for i=0 upto 7 :
+ for j=0 upto 9 :
+ flow_new_shape(i+1,j+1,i*10+j);
+ endfor ;
+ endfor ;
+ flow_end_chart ;
+enddef ;
+
+%D connections
+
+def flow_new_chart =
+
+ flow_grid_width := 60pt ;
+ flow_shape_width := 45pt ;
+ flow_grid_height := 40pt ;
+ flow_shape_height := 30pt ;
+ flow_chart_offset := 2pt ;
+ flow_chart_background_color := white ;
+ flow_show_mid_points := false ;
+ flow_show_con_points := false ;
+ flow_show_all_points := false ;
+ flow_shape_line_width := 2pt ;
+ flow_shape_line_color := .5white ;
+ flow_shape_fill_color := .9white ;
+ flow_connection_line_color := .2white ;
+ flow_connection_line_width := flow_shape_line_width ;
+ flow_connection_smooth_size := 5pt ;
+ flow_connection_arrow_size := 4pt ;
+ flow_connection_dash_size := 3pt ;
+
+ flow_max_x := 6 ;
+ flow_max_y := 4 ;
+
+ flow_smooth := true ;
+ flow_peepshape := false ;
+ flow_arrowtip := true ;
+ flow_dashline := false ;
+ flow_forcevalid := false ;
+ flow_touchshape := false ;
+ flow_showcrossing := false ;
+ flow_reverse_y := true ;
+
+ flow_dash_pattern := nullpicture ;
+
+ numeric flow_xypoint ; flow_xypoint := 0 ;
+ numeric flow_cpath ; flow_cpath := 0 ;
+
+ pair flow_xypoints [] ;
+ boolean flow_xyfree [][] ;
+ path flow_xypath [][] ;
+ numeric flow_xysx [][] ;
+ numeric flow_xysy [][] ;
+ color flow_xyfill [][] ;
+ color flow_xydraw [][] ;
+ numeric flow_xyline [][] ;
+ boolean flow_xypeep [][] ;
+ picture flow_xytext [][] ;
+ picture flow_xylabel_l[][] ;
+ picture flow_xylabel_r[][] ;
+ picture flow_xylabel_t[][] ;
+ picture flow_xylabel_b[][] ;
+ picture flow_xyexit_l [][] ;
+ picture flow_xyexit_r [][] ;
+ picture flow_xyexit_t [][] ;
+ picture flow_xyexit_b [][] ;
+ path flow_cpaths [] ;
+ numeric flow_cline [] ;
+ color flow_ccolor [] ;
+ boolean flow_carrow [] ;
+ boolean flow_cdash [] ;
+ boolean flow_ccross [] ;
+
+ picture flow_tpicture[][] ;
+ picture flow_bpicture[][] ;
+ picture flow_lpicture[][] ;
+ picture flow_rpicture[][] ;
+
+ predefined_shapes[61] := (fullcircle scaled (1.5*predefined_shapes_yradius) xscaled (flow_grid_height/flow_grid_width)) ;
+ predefined_shapes[62] := (fullcircle scaled (2.0*predefined_shapes_yradius) xscaled (flow_grid_height/flow_grid_width)) ;
+
+enddef ;
+
+flow_new_chart ;
+
+def flow_y_pos(expr y) =
+ if flow_reverse_y :
+ flow_max_y + 1 - y
+ else :
+ y
+ fi
+enddef ;
+
+def flow_initialize_grid(expr maxx, maxy) =
+ flow_max_x := maxx ;
+ flow_max_y := maxy ;
+ flow_dsp_x := 0 ;
+ flow_dsp_y := 0 ;
+ for x=1 upto flow_max_x :
+ for y=1 upto flow_max_y :
+ flow_xyfree[x][y] := true ;
+ flow_xyfill[x][y] := flow_shape_fill_color ;
+ flow_xydraw[x][y] := flow_shape_line_color ;
+ flow_xyline[x][y] := flow_shape_line_width ;
+ endfor ;
+ endfor ;
+enddef ;
+
+def flow_scaled_to_grid =
+ xscaled flow_grid_width yscaled flow_grid_height
+enddef ;
+
+def flow_xy_offset(expr x, y) =
+ (x+.5,y+.5)
+enddef ;
+
+def flow_draw_shape(expr x, yy, p, sx, sy) =
+ begingroup ;
+ save y ; numeric y ;
+ y := flow_y_pos(yy) ;
+ flow_xypath [x][y] := (p xscaled sx yscaled sy) shifted flow_xy_offset(x,y) ;
+ flow_xyfree [x][y] := false ;
+ flow_xysx [x][y] := sx ;
+ flow_xysy [x][y] := sy ;
+ flow_xyfill [x][y] := flow_shape_fill_color ;
+ flow_xydraw [x][y] := flow_shape_line_color ;
+ flow_xyline [x][y] := flow_shape_line_width ;
+ flow_xypeep [x][y] := flow_peepshape ;
+ endgroup ;
+enddef ;
+
+vardef flow_i_point (expr x, y, p, t) =
+ begingroup ;
+ save q, ok ; pair q ; boolean ok ;
+ q := flow_xypath[x][y] intersection_point ((p) shifted flow_xy_offset(x,y)) ;
+ ok := true ;
+ if not ok :
+ message (t & " of shape (" & decimal x & "," & decimal y & ") limited") ;
+ fi ;
+ q
+ endgroup
+enddef ;
+
+vardef flow_trimmed (expr x, y, z, t) =
+ if flow_touchshape and t :
+ flow_xyline[x][y]/z
+ else :
+ epsilon
+ fi
+enddef ;
+
+numeric flow_zfactor ; flow_zfactor := 1/3 ;
+
+vardef flow_xy_bottom (expr x, y, z, t) =
+ flow_i_point(x, y, ((0,0)--(0,-2)) shifted (flow_zfactor*z*flow_xysx[x][y],0), "bottom")
+ shifted(0,-flow_trimmed(x,y,flow_grid_height,t))
+enddef ;
+
+vardef flow_xy_top (expr x, y, z, t) =
+ flow_i_point (x, y, ((0,0)--(0,2)) shifted (flow_zfactor*z*flow_xysx[x][y],0), "top")
+ shifted(0,flow_trimmed(x,y,flow_grid_height,t))
+enddef ;
+
+vardef flow_xy_left (expr x, y, z, t) =
+ flow_i_point (x, y, ((0,0)--(-2,0)) shifted (0,flow_zfactor*z*flow_xysy[x][y]), "left")
+ shifted(-flow_trimmed(x,y,flow_grid_width,t),0)
+enddef ;
+
+vardef flow_xy_right (expr x, y, z, t) =
+ flow_i_point (x, y, ((0,0)--(2,0)) shifted (0,flow_zfactor*z*flow_xysy[x][y]), "right")
+ shifted(flow_trimmed(x,y,flow_grid_width,t),0)
+enddef ;
+
+def flow_flush_shapes =
+ for x=1 upto flow_max_x :
+ for y=1 upto flow_max_y :
+ flow_flush_shape(x, y) ;
+ endfor ;
+ endfor ;
+enddef ;
+
+def flow_flush_pictures =
+ for x=1 upto flow_max_x :
+ for y=1 upto flow_max_y :
+ flow_flush_picture(x, y) ;
+ endfor ;
+ endfor ;
+enddef ;
+
+def flow_draw_connection_point(expr x, y, z) =
+ pickup pencircle scaled if (z=0): 2 fi flow_xyline[x][y] ;
+ drawdot flow_xy_bottom(x,y,z,false) flow_scaled_to_grid withcolor (1,0,0) ;
+ drawdot flow_xy_top (x,y,z,false) flow_scaled_to_grid withcolor (0,1,0) ;
+ drawdot flow_xy_left (x,y,z,false) flow_scaled_to_grid withcolor (0,0,1) ;
+ drawdot flow_xy_right (x,y,z,false) flow_scaled_to_grid withcolor (1,1,0) ;
+enddef ;
+
+def flow_flush_shape(expr x, yy) =
+ begingroup ;
+ save y ; numeric y ;
+ y := flow_y_pos(yy) ;
+ if not flow_xyfree[x][y] :
+ pickup pencircle scaled flow_xyline[x][y] ;
+ if flow_xypeep[x][y] :
+ fill (flow_xypath[x][y] peepholed (unitsquare shifted (x,y)))
+ flow_scaled_to_grid withpen pencircle scaled 0
+ withcolor flow_chart_background_color ;
+ else :
+ fill flow_xypath[x][y] flow_scaled_to_grid withcolor flow_xyfill[x][y] ;
+ fi ;
+ draw flow_xypath[x][y] flow_scaled_to_grid withcolor flow_xydraw[x][y] ;
+ if flow_show_con_points or flow_show_all_points :
+ flow_draw_connection_point(x, y, 0) ;
+ fi ;
+ if flow_show_all_points :
+ for i=-1 upto 1 :
+ flow_draw_connection_point(x, y, i) ;
+ endfor ;
+ fi ;
+ fi ;
+ endgroup ;
+enddef ;
+
+vardef flow_points_initialized(expr xfrom, yfrom, xto, yto, n) =
+ if not flow_xyfree[xfrom][yfrom] and not flow_xyfree[xto][yto] :
+ flow_xypoint := n ; true
+ else :
+ flow_xypoint := 0 ; false
+ fi
+enddef ;
+
+def flow_collapse_points = % this is now an mp-tool macro
+ begingroup ;
+ % remove redundant points
+ save n ; numeric n ;
+ n := 1 ;
+ for i=2 upto flow_xypoint :
+ if not (flow_xypoints[i] = flow_xypoints[n]) :
+ n := n + 1 ;
+ flow_xypoints[n] := flow_xypoints[i]
+ fi ;
+ endfor ;
+ flow_xypoint := n ;
+ % make straight lines
+ if flow_xypoints[2] = flow_xypoints[flow_xypoint-1] :
+ flow_xypoints[3] := flow_xypoints[flow_xypoint] ;
+ flow_xypoint := 3 ;
+ fi ;
+ endgroup ;
+enddef ;
+
+vardef flow_smooth_connection(expr a,b) =
+ if ypart a = ypart b :
+ a shifted ( if xpart a >= xpart b : - fi (flow_connection_smooth_size/flow_grid_width ),0)
+ else :
+ a shifted (0,if ypart a >= ypart b : - fi (flow_connection_smooth_size/flow_grid_height) )
+ fi
+enddef ;
+
+vardef flow_trim_points =
+ begingroup
+ save p, a, b, d, i ; numeric a, b ; path p ; pair d ;
+ p := for i=1 upto flow_xypoint-1 : flow_xypoints[i]-- endfor flow_xypoints[flow_xypoint] ;
+ if flow_touchshape :
+ a := flow_shape_line_width/flow_grid_width ;
+ b := flow_shape_line_width/flow_grid_height ;
+ else :
+ a := epsilon ;
+ b := epsilon ;
+ fi ;
+ d := direction infinity of p ;
+ flow_xypoints[flow_xypoint] := flow_xypoints[flow_xypoint] shifted
+ if xpart d < 0 : (+a,0) ;
+ elseif xpart d > 0 : (-a,0) ;
+ elseif ypart d < 0 : (0,+b) ;
+ elseif ypart d > 0 : (0,-b) ;
+ else : origin ;
+ fi ;
+ d := direction 0 of p ;
+ flow_xypoints[1] := flow_xypoints[1] shifted
+ if xpart d < 0 : (-a,0) ;
+ elseif xpart d > 0 : (+a,0) ;
+ elseif ypart d < 0 : (0,-b) ;
+ elseif ypart d > 0 : (0,+b) ;
+ else : origin ;
+ fi ;
+ endgroup
+enddef ;
+
+vardef flow_trim_points = enddef ;
+
+vardef flow_connection_path =
+ if flow_reverse_connection : reverse fi (flow_xypoints[1] --
+ for i=2 upto flow_xypoint-1 :
+ if flow_smooth :
+ flow_smooth_connection(flow_xypoints[i],flow_xypoints[i-1]) ..
+ controls flow_xypoints[i] and flow_xypoints[i] ..
+ flow_smooth_connection(flow_xypoints[i],flow_xypoints[i+1]) --
+ else :
+ flow_xypoints[i] --
+ fi
+ endfor
+ flow_xypoints[flow_xypoint])
+enddef ;
+
+def flow_draw_connection =
+ if flow_xypoint > 0 :
+ flow_collapse_points ;
+ flow_trim_points ;
+ flow_cpath := flow_cpath + 1 ;
+ flow_cpaths[flow_cpath] := flow_connection_path flow_scaled_to_grid ;
+ flow_cline[flow_cpath] := flow_connection_line_width ;
+ flow_ccolor[flow_cpath] := flow_connection_line_color ;
+ flow_carrow[flow_cpath] := flow_arrowtip ;
+ flow_cdash[flow_cpath] := flow_dashline ;
+ flow_ccross[flow_cpath] := flow_showcrossing ;
+ else :
+ message("no connection defined") ;
+ fi ;
+ flow_reverse_connection := false ;
+enddef ;
+
+def flow_flush_connections = % protect locals
+ begingroup ;
+ save ip, crossing, cp ; numeric ip ; boolean crossing ; path cp ;
+ ahlength := flow_connection_arrow_size ;
+ flow_dash_pattern := dashpattern(on flow_connection_dash_size off flow_connection_dash_size) ;
+ for i=1 upto flow_cpath :
+ if flow_ccross[i] :
+ crossing := false ;
+ for j=1 upto i :
+ if not (point infinity of flow_cpaths[i] = point infinity of flow_cpaths[j]) :
+ ip := flow_cpaths[i] intersection_point flow_cpaths[j] ;
+ if intersection_found : crossing := true fi ;
+ fi ;
+ endfor ;
+ if crossing :
+ pickup pencircle scaled 2flow_cline[i] ;
+ cp := flow_cpaths[i] ;
+ cp := cp cutbefore point .05 length cp of cp ;
+ cp := cp cutafter point .95 length cp of cp ;
+ draw cp withcolor flow_chart_background_color ;
+ fi ;
+ fi ;
+ pickup pencircle scaled flow_cline[i] ;
+ if flow_carrow[i] :
+ if flow_cdash[i] :
+ drawarrow flow_cpaths[i] withcolor flow_ccolor[i] dashed flow_dash_pattern ;
+ else :
+ drawarrow flow_cpaths[i] withcolor flow_ccolor[i] ;
+ fi ;
+ else :
+ if flow_cdash[i] :
+ draw flow_cpaths[i] withcolor flow_ccolor[i] dashed flow_dash_pattern ;
+ else :
+ draw flow_cpaths[i] withcolor flow_ccolor[i] ;
+ fi ;
+ fi ;
+ flow_draw_midpoint(i) ;
+ endfor ;
+ endgroup ;
+enddef ;
+
+def flow_draw_midpoint (expr n) =
+ begingroup
+ save p ; pair p ;
+ p := point .5*length(flow_cpaths[n]) of flow_cpaths[n];
+ pickup pencircle scaled 2flow_cline[n] ;
+ if flow_show_mid_points :
+ drawdot p withcolor .7white ;
+ fi ;
+ endgroup ;
+enddef ;
+
+def flow_flush_picture(expr x, yy) =
+ begingroup ; save y ; numeric y ;
+ y := flow_y_pos(yy) ;
+ if known flow_xytext[x][y] :
+ begingroup ;
+ % flow_xypath[x][y]
+ save p, offset ; path p ; pair offset ;
+ offset := flow_xy_offset((x+0.5)*flow_grid_width,(flow_max_y-y+1.5)*flow_grid_height) ;
+ offset := offset shifted (-flow_xyline[x][y]/4,-flow_xyline[x][y]/4) ; % terrible hack (some compensation)
+ p := fullsquare
+ xscaled flow_grid_width
+ yscaled flow_grid_height
+ shifted offset ;
+ if known flow_xytext[x][y]:
+ draw flow_xytext[x][y] shifted offset ;
+ fi ;
+ if known flow_xylabel_t[x][y] :
+ label.urt(flow_xylabel_t[x][y],0.5[ulcorner p,urcorner p]) ;
+ fi ;
+ if known flow_xylabel_b[x][y] :
+ label.lrt(flow_xylabel_b[x][y],0.5[llcorner p,lrcorner p]) ;
+ fi ;
+ if known flow_xylabel_l[x][y] :
+ label.ulft(flow_xylabel_l[x][y],0.5[ulcorner p,llcorner p]) ;
+ fi ;
+ if known flow_xylabel_r[x][y] :
+ label.urt (flow_xylabel_r[x][y],0.5[urcorner p,lrcorner p]) ;
+ fi ;
+ if known flow_xyexit_t[x][y] :
+ label.top(flow_xyexit_t[x][y],0.5[ulcorner p,urcorner p] shifted (0, flow_grid_height/2)) ;
+ fi ;
+ if known flow_xyexit_b[x][y] :
+ label.bot(flow_xyexit_b[x][y],0.5[llcorner p,lrcorner p] shifted (0,-flow_grid_height/2)) ;
+ fi ;
+ if known flow_xyexit_l[x][y] :
+ label.lft(flow_xyexit_l[x][y],0.5[ulcorner p,llcorner p] shifted (-flow_grid_width/2,0)) ;
+ fi ;
+ if known flow_xyexit_r[x][y] :
+ label.rt (flow_xyexit_r[x][y],0.5[urcorner p,lrcorner p] shifted ( flow_grid_width/2,0)) ;
+ fi ;
+ endgroup ;
+ fi ;
+ endgroup ;
+enddef ;
+
+def flow_chart_draw_text(expr x, y, p) =
+ flow_xytext[x][y] := p ;
+enddef ;
+
+def flow_chart_draw_label_t(expr x, y, p) = flow_xylabel_t[x][y] := p ; enddef ;
+def flow_chart_draw_label_b(expr x, y, p) = flow_xylabel_b[x][y] := p ; enddef ;
+def flow_chart_draw_label_l(expr x, y, p) = flow_xylabel_l[x][y] := p ; enddef ;
+def flow_chart_draw_label_r(expr x, y, p) = flow_xylabel_r[x][y] := p ; enddef ;
+
+def flow_chart_draw_exit_t (expr x, y, p) = flow_xyexit_t [x][y] := p ; enddef ;
+def flow_chart_draw_exit_b (expr x, y, p) = flow_xyexit_b [x][y] := p ; enddef ;
+def flow_chart_draw_exit_l (expr x, y, p) = flow_xyexit_l [x][y] := p ; enddef ;
+def flow_chart_draw_exit_r (expr x, y, p) = flow_xyexit_r [x][y] := p ; enddef ;
+
+boolean flow_reverse_connection ; flow_reverse_connection := false ;
+
+vardef flow_up_on_grid (expr n) =
+ (xpart flow_xypoints[n],(ypart flow_xypoints[n]+1) div 1)
+enddef ;
+
+vardef flow_down_on_grid (expr n) =
+ (xpart flow_xypoints[n],(ypart flow_xypoints[n]) div 1)
+enddef ;
+
+vardef flow_left_on_grid (expr n) =
+ ((xpart flow_xypoints[n]) div 1, ypart flow_xypoints[n])
+enddef ;
+
+vardef flow_right_on_grid (expr n) =
+ ((xpart flow_xypoints[n]+1) div 1, ypart flow_xypoints[n])
+enddef ;
+
+vardef flow_x_on_grid (expr n, xfrom, xto, zfrom) =
+ if (xfrom = xto) and not (zfrom = 0) :
+ if (zfrom=1) : flow_right_on_grid(2) else : flow_left_on_grid(2) fi
+ elseif xpart flow_xypoints[1] < xpart flow_xypoints[6] :
+ flow_right_on_grid(n)
+ else :
+ flow_left_on_grid(n)
+ fi
+enddef ;
+
+vardef y_on_grid (expr n, yfrom, yto, zfrom) =
+ if (yfrom = yto) and not (zfrom = 0) :
+ if (zfrom = 1) : flow_up_on_grid(2) else : flow_down_on_grid(2) fi
+ elseif ypart flow_xypoints[1] < ypart flow_xypoints[6] :
+ flow_up_on_grid(n)
+ else :
+ flow_down_on_grid(n)
+ fi
+enddef ;
+
+vardef flow_xy_on_grid (expr n, m) =
+ (xpart flow_xypoints[n], ypart flow_xypoints[m])
+enddef ;
+
+vardef flow_down_to_grid (expr a,b) =
+ (xpart flow_xypoints[a], ypart flow_xypoints[if ypart flow_xypoints[a]<ypart flow_xypoints[b] : a else : b fi])
+enddef ;
+
+vardef flow_up_to_grid (expr a,b) =
+ (xpart flow_xypoints[a], ypart flow_xypoints[if ypart flow_xypoints[a]>ypart flow_xypoints[b] : a else : b fi])
+enddef ;
+
+vardef flow_left_to_grid (expr a,b) =
+ (xpart flow_xypoints[if xpart flow_xypoints[a]<xpart flow_xypoints[b] : a else : b fi], ypart flow_xypoints[a])
+enddef ;
+
+vardef flow_right_to_grid (expr a,b) =
+ (xpart flow_xypoints[if xpart flow_xypoints[a]>xpart flow_xypoints[b] : a else : b fi], ypart flow_xypoints[a])
+enddef ;
+
+vardef flow_valid_connection (expr xfrom, yfrom, xto, yto) =
+ begingroup ;
+ save ok, vc, pp ; boolean ok ; pair vc ; path pp ;
+ save flow_xyfirst, flow_xylast ; pair flow_xyfirst, flow_xylast ;
+ % check for slanted lines
+ ok := true ;
+ for i=1 upto flow_xypoint-1 :
+ if not ((xpart flow_xypoints[i]=xpart flow_xypoints[i+1]) or (ypart flow_xypoints[i]=ypart flow_xypoints[i+1])) :
+ ok := false ;
+ fi ;
+ endfor ;
+ if not ok :
+ % message("slanted");
+ false
+ elseif flow_forcevalid :
+ % message("force");
+ true
+ elseif (xfrom=xto) and (yfrom=yto) :
+ % message("self");
+ false
+ else :
+ % check for crossing shapes
+ flow_xyfirst := flow_xypoints[1] ;
+ flow_xylast := flow_xypoints[flow_xypoint] ;
+ flow_trim_points ;
+ pp := for i=1 upto flow_xypoint-1 : flow_xypoints[i]-- endfor flow_xypoints[flow_xypoint] ;
+ flow_xypoints[1] := flow_xyfirst ;
+ flow_xypoints[flow_xypoint] := flow_xylast ;
+ for i=1 upto flow_max_x :
+ for j=1 upto flow_max_y : % was bug: xfrom,yto
+ if not ( ( (i,j)=(xfrom,yfrom) ) or ( (i,j)=(xto,yto) ) ) :
+ if not flow_xyfree[i][j] :
+ vc := pp intersection_point flow_xypath[i][j] ;
+ if intersection_found :
+ ok := false
+ fi ;
+ fi ;
+ fi ;
+ endfor ;
+ endfor ;
+ % if not ok: message("crossing") ; fi ;
+ ok
+ fi
+ endgroup
+enddef ;
+
+def flow_connect_top_bottom (expr xfrom, yyfrom, zfrom) (expr xto, yyto, zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
+ flow_xypoints[1] := flow_xy_top(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[6] := flow_xy_bottom(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_up_on_grid(1) ;
+ flow_xypoints[5] := flow_down_on_grid(6) ;
+ flow_xypoints[3] := flow_up_to_grid(2,5) ;
+ flow_xypoints[4] := flow_up_to_grid(2,5) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_x_on_grid(2,xfrom,xto,zfrom) ;
+ flow_xypoints[4] := flow_xy_on_grid(3,5) ;
+ fi ;
+ %%%% begin experiment
+ flow_xypoints[3] := flow_xypoints[3] shifted (flow_dsp_x,0) ;
+ flow_xypoints[4] := flow_xypoints[4] shifted (flow_dsp_x,0) ;
+ if flow_dsp_y>0 :
+ flow_xypoints[2] := flow_xypoints[2] shifted (0,flow_dsp_y) ;
+ flow_xypoints[3] := flow_xypoints[3] shifted (0,flow_dsp_y) ;
+ elseif flow_dsp_y<0 :
+ flow_xypoints[4] := flow_xypoints[4] shifted (0,flow_dsp_y) ;
+ flow_xypoints[5] := flow_xypoints[5] shifted (0,flow_dsp_y) ;
+ fi
+ %%%% end experiment
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_left_right (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
+ flow_xypoints[1] := flow_xy_left(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[6] := flow_xy_right(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_left_on_grid(1) ;
+ flow_xypoints[5] := flow_right_on_grid(6) ;
+ flow_xypoints[3] := flow_left_to_grid(2,5) ;
+ flow_xypoints[4] := flow_left_to_grid(2,5) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_y_on_grid(2,yfrom,yto,zfrom) ;
+ flow_xypoints[4] := flow_xy_on_grid(5,3) ;
+ fi ;
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_left_top (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,5) :
+ flow_xypoints[1] := flow_xy_left(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[5] := flow_xy_top(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_left_on_grid(1) ;
+ flow_xypoints[4] := flow_up_on_grid(5) ;
+ flow_xypoints[3] := flow_left_to_grid(2,5) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_xy_on_grid(2,4) ;
+ fi ;
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_left_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,5) :
+ flow_xypoints[1] := flow_xy_left(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[5] := flow_xy_bottom(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_left_on_grid(1) ;
+ flow_xypoints[4] := flow_down_on_grid(5) ;
+ flow_xypoints[3] := flow_left_to_grid(2,5) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_xy_on_grid(2,4) ;
+ fi ;
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_right_top (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,5) :
+ flow_xypoints[1] := flow_xy_right(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[5] := flow_xy_top(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_right_on_grid(1) ;
+ flow_xypoints[4] := flow_up_on_grid(5) ;
+ flow_xypoints[3] := flow_right_to_grid(2,5) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_xy_on_grid(2,4) ;
+ fi ;
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_right_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,5) :
+ flow_xypoints[1] := flow_xy_right(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[5] := flow_xy_bottom(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_right_on_grid(1) ;
+ flow_xypoints[4] := flow_down_on_grid(5) ;
+ flow_xypoints[3] := flow_right_to_grid(2,5) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_xy_on_grid(2,4) ;
+ fi ;
+ %%%% begin experiment
+ flow_xypoints[2] := flow_xypoints[2] shifted (flow_dsp_x,0) ;
+ flow_xypoints[3] := flow_xypoints[3] shifted (flow_dsp_x,0) ;
+ if flow_dsp_y>0 :
+ flow_xypoints[3] := flow_xypoints[3] shifted (0,-flow_dsp_y) ;
+ flow_xypoints[4] := flow_xypoints[4] shifted (0,-flow_dsp_y) ;
+ elseif flow_dsp_y<0 :
+ flow_xypoints[3] := flow_xypoints[3] shifted (0,flow_dsp_y) ;
+ flow_xypoints[4] := flow_xypoints[4] shifted (0,flow_dsp_y) ;
+ fi
+ %%%% end experiment
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_left_left (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
+ flow_xypoints[1] := flow_xy_left(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[6] := flow_xy_left(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_left_on_grid(1) ;
+ flow_xypoints[5] := flow_left_on_grid(6) ;
+ flow_xypoints[3] := flow_left_to_grid(2,5) ;
+ flow_xypoints[4] := flow_left_to_grid(5,2) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_y_on_grid(2,yfrom,yto,zfrom) ;
+ flow_xypoints[4] := flow_xy_on_grid(5,3) ;
+ fi ;
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_right_right (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
+ flow_xypoints[1] := flow_xy_right(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[6] := flow_xy_right(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_right_on_grid(1) ;
+ flow_xypoints[5] := flow_right_on_grid(6) ;
+ flow_xypoints[3] := flow_right_to_grid(2,5) ;
+ flow_xypoints[4] := flow_right_to_grid(5,2) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_y_on_grid(2,yfrom,yto,zfrom) ;
+ flow_xypoints[4] := flow_xy_on_grid(5,3) ;
+ fi ;
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_top_top (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
+ flow_xypoints[1] := flow_xy_top(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[6] := flow_xy_top(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_up_on_grid(1) ;
+ flow_xypoints[5] := flow_up_on_grid(6) ;
+ flow_xypoints[3] := flow_up_to_grid(2,5) ;
+ flow_xypoints[4] := flow_up_to_grid(5,2) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_x_on_grid(2,xfrom,xto,zfrom) ;
+ flow_xypoints[4] := flow_xy_on_grid(3,5) ;
+ fi ;
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_bottom_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
+ yfrom := flow_y_pos(yyfrom) ;
+ yto := flow_y_pos(yyto) ;
+ if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
+ flow_xypoints[1] := flow_xy_bottom(xfrom,yfrom,zfrom,true) ;
+ flow_xypoints[6] := flow_xy_bottom(xto,yto,zto,true) ;
+ flow_xypoints[2] := flow_down_on_grid(1) ;
+ flow_xypoints[5] := flow_down_on_grid(6) ;
+ flow_xypoints[3] := flow_down_to_grid(2,5) ;
+ flow_xypoints[4] := flow_down_to_grid(5,2) ;
+ if not flow_valid_connection(xfrom,yfrom,xto,yto) :
+ flow_xypoints[3] := flow_x_on_grid(2,xfrom,xto,zfrom) ;
+ flow_xypoints[4] := flow_xy_on_grid(3,5) ;
+ fi ;
+ %%%% begin experiment
+ flow_xypoints[3] := flow_xypoints[3] shifted (flow_dsp_x,0) ;
+ flow_xypoints[4] := flow_xypoints[4] shifted (flow_dsp_x,0) ;
+ if flow_dsp_y<0 :
+ flow_xypoints[2] := flow_xypoints[2] shifted (0,-flow_dsp_y) ;
+ flow_xypoints[3] := flow_xypoints[3] shifted (0,-flow_dsp_y) ;
+ elseif flow_dsp_y>0 :
+ flow_xypoints[4] := flow_xypoints[4] shifted (0,flow_dsp_y) ;
+ flow_xypoints[5] := flow_xypoints[5] shifted (0,flow_dsp_y) ;
+ fi
+ %%%% end experiment
+ flow_draw_connection ;
+ fi ;
+enddef ;
+
+def flow_connect_bottom_top (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
+ flow_reverse_connection := true ;
+ flow_connect_top_bottom (xto,yto,zto) (xfrom,yfrom,zfrom) ;
+enddef ;
+
+def flow_connect_right_left (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
+ flow_reverse_connection := true ;
+ flow_connect_left_right (xto,yto,zto) (xfrom,yfrom,zfrom) ;
+enddef ;
+
+def flow_connect_top_left (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
+ flow_reverse_connection := true ;
+ flow_connect_left_top(xto,yto,zto) (xfrom,yfrom,zfrom) ;
+enddef ;
+
+def flow_connect_bottom_left (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
+ flow_reverse_connection := true ;
+ flow_connect_left_bottom (xto,yto,zto) (xfrom,yfrom,zfrom) ;
+enddef ;
+
+def flow_connect_top_right (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
+ flow_reverse_connection := true ;
+ flow_connect_right_top (xto,yto,zto) (xfrom,yfrom,zfrom) ;
+enddef ;
+
+def flow_connect_bottom_right (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
+ flow_reverse_connection := true ;
+ flow_connect_right_bottom (xto,yto,zto) (xfrom,yfrom,zfrom) ;
+enddef ;
+
+def flow_draw_test_shape(expr x, y) =
+ flow_draw_shape(x,y,fullcircle, .7, .7) ;
+enddef ;
+
+def flow_draw_test_shapes =
+ for i=1 upto flow_max_x :
+ for j=1 upto flow_max_y :
+ flow_draw_test_shape(i,j) ;
+ endfor ;
+ endfor ;
+enddef;
+
+def flow_draw_test_area =
+ pickup pencircle scaled .5flow_shape_line_width ;
+ draw (unitsquare xscaled flow_max_x yscaled flow_max_y shifted (1,1)) flow_scaled_to_grid withcolor blue ;
+enddef ;
+
+def flow_show_connection(expr n, m) =
+
+ flow_begin_chart(100+n,6,6) ;
+
+ flow_draw_test_area ;
+
+ flow_smooth := true ;
+ flow_arrowtip := true ;
+ flow_dashline := true ;
+
+ flow_draw_test_shape(2,2) ; flow_draw_test_shape(4,5) ;
+ flow_draw_test_shape(3,3) ; flow_draw_test_shape(5,1) ;
+ flow_draw_test_shape(2,5) ; flow_draw_test_shape(1,3) ;
+ flow_draw_test_shape(6,2) ; flow_draw_test_shape(4,6) ;
+
+ if (m=1) :
+ flow_connect_top_bottom (2,2,0) (4,5,0) ;
+ flow_connect_top_bottom (3,3,0) (5,1,0) ;
+ flow_connect_top_bottom (2,5,0) (1,3,0) ;
+ flow_connect_top_bottom (6,2,0) (4,6,0) ;
+ elseif (m=2) :
+ flow_connect_top_top (2,2,0) (4,5,0) ;
+ flow_connect_top_top (3,3,0) (5,1,0) ;
+ flow_connect_top_top (2,5,0) (1,3,0) ;
+ flow_connect_top_top (6,2,0) (4,6,0) ;
+ elseif (m=3) :
+ flow_connect_bottom_bottom (2,2,0) (4,5,0) ;
+ flow_connect_bottom_bottom (3,3,0) (5,1,0) ;
+ flow_connect_bottom_bottom (2,5,0) (1,3,0) ;
+ flow_connect_bottom_bottom (6,2,0) (4,6,0) ;
+ elseif (m=4) :
+ flow_connect_left_right (2,2,0) (4,5,0) ;
+ flow_connect_left_right (3,3,0) (5,1,0) ;
+ flow_connect_left_right (2,5,0) (1,3,0) ;
+ flow_connect_left_right (6,2,0) (4,6,0) ;
+ elseif (m=5) :
+ flow_connect_left_left (2,2,0) (4,5,0) ;
+ flow_connect_left_left (3,3,0) (5,1,0) ;
+ flow_connect_left_left (2,5,0) (1,3,0) ;
+ flow_connect_left_left (6,2,0) (4,6,0) ;
+ elseif (m=6) :
+ flow_connect_right_right (2,2,0) (4,5,0) ;
+ flow_connect_right_right (3,3,0) (5,1,0) ;
+ flow_connect_right_right (2,5,0) (1,3,0) ;
+ flow_connect_right_right (6,2,0) (4,6,0) ;
+ elseif (m=7) :
+ flow_connect_left_top (2,2,0) (4,5,0) ;
+ flow_connect_left_top (3,3,0) (5,1,0) ;
+ flow_connect_left_top (2,5,0) (1,3,0) ;
+ flow_connect_left_top (6,2,0) (4,6,0) ;
+ elseif (m=8) :
+ flow_connect_left_bottom (2,2,0) (4,5,0) ;
+ flow_connect_left_bottom (3,3,0) (5,1,0) ;
+ flow_connect_left_bottom (2,5,0) (1,3,0) ;
+ flow_connect_left_bottom (6,2,0) (4,6,0) ;
+ elseif (m=9) :
+ flow_connect_right_top (2,2,0) (4,5,0) ;
+ flow_connect_right_top (3,3,0) (5,1,0) ;
+ flow_connect_right_top (2,5,0) (1,3,0) ;
+ flow_connect_right_top (6,2,0) (4,6,0) ;
+ else :
+ flow_connect_right_bottom (2,2,0) (4,5,0) ;
+ flow_connect_right_bottom (3,3,0) (5,1,0) ;
+ flow_connect_right_bottom (2,5,0) (1,3,0) ;
+ flow_connect_right_bottom (6,2,0) (4,6,0) ;
+ fi ;
+
+ flow_end_chart ;
+
+enddef ;
+
+def flow_show_connections =
+ for f=1 upto 10 :
+ flow_show_connection(f,f) ;
+ endfor ;
+enddef ;
+
+%D charts
+
+def flow_clip_chart(expr minx, miny, maxx, maxy) =
+ flow_cmin_x := minx ;
+ flow_cmax_x := maxx ;
+ flow_cmin_y := miny ;
+ flow_cmax_y := maxy ;
+enddef ;
+
+def flow_begin_chart(expr n, maxx, maxy) =
+ flow_new_chart ;
+ flow_chart_figure := n ;
+ flow_chart_scale := 1 ;
+ if flow_chart_figure>0:
+ beginfig(flow_chart_figure) ;
+ fi ;
+ flow_initialize_grid (maxx, maxy) ;
+ bboxmargin := 0 ;
+ flow_cmin_x := 1 ;
+ flow_cmax_x := maxx ;
+ flow_cmin_y := 1 ;
+ flow_cmax_y := maxy ;
+enddef ;
+
+def flow_end_chart =
+ begingroup ;
+ save p ; path p ;
+ flow_flush_shapes ;
+ flow_flush_connections ;
+ flow_flush_pictures ;
+ flow_cmin_x := flow_cmin_x ;
+ flow_cmax_x := flow_cmin_x+flow_cmax_x ;
+ flow_cmin_y := flow_cmin_y-1 ;
+ flow_cmax_y := flow_cmin_y+flow_cmax_y ;
+ if flow_reverse_y :
+ flow_cmin_y := flow_y_pos(flow_cmin_y) ;
+ flow_cmax_y := flow_y_pos(flow_cmax_y) ;
+ fi ;
+ p := (((flow_cmin_x,flow_cmin_y)--(flow_cmax_x,flow_cmin_y)--
+ (flow_cmax_x,flow_cmax_y)--(flow_cmin_x,flow_cmax_y)--cycle))
+ flow_scaled_to_grid ;
+ %draw p withcolor red ;
+ p := p enlarged flow_chart_offset ;
+ clip currentpicture to p ;
+ setbounds currentpicture to p ;
+ endgroup ;
+ currentpicture := currentpicture scaled flow_chart_scale ;
+ if flow_chart_figure>0:
+ endfig ;
+ fi ;
+enddef ;
+
+def flow_new_shape(expr x, y, n) =
+ if known n :
+ if (x>0) and (x<=flow_max_x) and (y>0) and (y<=flow_max_y) :
+ flow_draw_shape(x,y,some_shape_path(n), flow_shape_width/flow_grid_width, flow_shape_height/flow_grid_height) ;
+ else :
+ message ("shape outside grid ignored") ;
+ fi ;
+ else :
+ message ("shape not known" ) ;
+ fi ;
+enddef ;
+
+def flow_begin_sub_chart =
+ begingroup ;
+ save flow_shape_line_width, flow_connection_line_width ;
+ save flow_shape_line_color, flow_shape_fill_color, flow_connection_line_color ;
+ color flow_shape_line_color, flow_shape_fill_color, flow_connection_line_color ;
+ save flow_smooth, flow_arrowtip, flow_dashline, flow_peepshape ;
+ boolean flow_smooth, flow_arrowtip, flow_dashline, flow_peepshape ;
+enddef ;
+
+def flow_end_sub_chart =
+ endgroup ;
+enddef ;
+
diff --git a/metapost/context/base/mp-shap.mp b/metapost/context/base/mp-shap.mp
index 0f5fe431d..785231278 100644
--- a/metapost/context/base/mp-shap.mp
+++ b/metapost/context/base/mp-shap.mp
@@ -1,6 +1,6 @@
%D \module
%D [ file=mp-shap.mp,
-%D version=2000.05.31,
+%D version=2000.05.31,
%D title=\CONTEXT\ \METAPOST\ graphics,
%D subtitle=shapes,
%D author=Hans Hagen,
@@ -8,300 +8,199 @@
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
-%C details.
-
-if unknown context_tool : input mp-tool ; fi ;
-if known context_shap : endinput ; fi ;
-
-boolean context_shap ; context_shap := true ;
+%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
+%C details.
+
+if unknown context_tool : input mp-tool ; fi ;
+if known context_shap : endinput ; fi ;
+
+boolean context_shap ; context_shap := true ;
+
+path predefined_shapes[] ;
+
+begingroup ;
+
+save xradius, yradius, xxradius, yyradius ;
+save ll, lr, ur, ul, llx, lly, lrx, lry, urx, ury, ulx, uly, llxx, llyy, lrxx, lryy, urxx, uryy, ulxx, ulyy, lc, rc, tc, bc ;
+
+numeric xradius, yradius, xxradius, yyradius ;
+pair ll, lr, ur, ul, llx, lly, lrx, lry, urx, ury, ulx, uly, llxx, llyy, lrxx, lryy, urxx, uryy, ulxx, ulyy, lc, rc, tc, bc ;
+
+xradius := .15 ;
+yradius := .15 ;
+xxradius := .10 ;
+yyradius := .10 ;
+
+ll := llcorner (unitsquare shifted (-.5,-.5)) ;
+lr := lrcorner (unitsquare shifted (-.5,-.5)) ;
+ur := urcorner (unitsquare shifted (-.5,-.5)) ;
+ul := ulcorner (unitsquare shifted (-.5,-.5)) ;
+
+llx := ll shifted (xradius,0) ;
+lly := ll shifted (0,yradius) ;
+
+lrx := lr shifted (-xradius,0) ;
+lry := lr shifted (0,yradius) ;
+
+urx := ur shifted (-xradius,0) ;
+ury := ur shifted (0,-yradius) ;
+
+ulx := ul shifted (xradius,0) ;
+uly := ul shifted (0,-yradius) ;
+
+llxx := ll shifted (xxradius,0) ;
+llyy := ll shifted (0,yyradius) ;
+
+lrxx := lr shifted (-xxradius,0) ;
+lryy := lr shifted (0,yyradius) ;
+
+urxx := ur shifted (-xxradius,0) ;
+uryy := ur shifted (0,-yyradius) ;
+
+ulxx := ul shifted (xxradius,0) ;
+ulyy := ul shifted (0,-yyradius) ;
+
+lc := ll shifted (0,.5) ;
+rc := lr shifted (0,.5) ;
+tc := ul shifted (.5,0) ;
+bc := ll shifted (.5,0) ;
+
+predefined_shapes[ 0] := (origin--cycle) ;
+predefined_shapes[ 5] := (llx--lrx{right}...rc...{left}urx--ulx{left}...lc...{right}cycle) ;
+predefined_shapes[ 6] := (ll--lrx{right}...rc...{left}urx--ul--cycle) ;
+predefined_shapes[ 7] := (ll--lrx{right}...rc...{left}urx--ul--cycle) rotatedaround(origin,180) ;
+predefined_shapes[ 8] := (lr--ury{up}...tc...{down}uly--ll--cycle) ;
+predefined_shapes[ 9] := (lr--ury{up}...tc...{down}uly--ll--cycle) rotatedaround(origin,180) ;
+predefined_shapes[10] := (ll--lr--ur--ul--ll--ur--ul--ll--cycle) ;
+predefined_shapes[11] := (ll--lr--ur--ul--ll--lr--ul--ll--cycle) ;
+predefined_shapes[12] := (ll--lrx--ur--ulx--cycle) ;
+predefined_shapes[13] := (llx--lr--urx--ul--cycle) ;
+predefined_shapes[14] := (lly--bc--lry--ury--tc--uly--cycle) ;
+predefined_shapes[15] := (llx--lrx--rc--urx--ulx--lc--cycle) ;
+predefined_shapes[16] := (ll--lrx--rc--urx--ul--cycle) ;
+predefined_shapes[17] := (ll--lrx--rc--urx--ul--cycle) rotatedaround(origin,180) ;
+predefined_shapes[18] := (lr--ury--tc--uly--ll--cycle) ;
+predefined_shapes[19] := (lr--ury--tc--uly--ll--cycle) rotatedaround(origin,180) ;
+predefined_shapes[20] := (ll--lr--ur--ul--ll--llxx--ulxx--ul--ll--lr--ur--urxx--lrxx--cycle) ;
+predefined_shapes[21] := (ul--ll--lr--ur--ul--ulyy--uryy--ur--ul--ll--lr--lryy--llyy--cycle) ;
+predefined_shapes[22] := (ll--lrx--lry--ur--ulx--uly--cycle) ;
+predefined_shapes[23] := (llx--lr--ury--urx--ul--lly--cycle) ;
+predefined_shapes[24] := (ll--lr--ur--ul--cycle) ;
+predefined_shapes[25] := (llx--lrx--lry--ury--urx--ulx--uly--lly--cycle) ;
+predefined_shapes[26] := (ll--lrx--lry--ur--ul--cycle) ;
+predefined_shapes[27] := (ll--lr--ury--urx--ul--cycle) rotatedaround(origin,180) ;
+predefined_shapes[28] := (ll--lr--ury--urx--ul--cycle) ;
+predefined_shapes[29] := (ll--lrx--lry--ur--ul--cycle) rotatedaround(origin,180) ;
+predefined_shapes[30] := (bc{right}...{up}rc...tc{left}...{down}lc...{right}bc & bc--tc & tc{left}..{down}lc & lc--rc & rc{up}..tc{left}...{down}lc...{right}bc & cycle) rotated 45;
+predefined_shapes[31] := (bc{right}...{up}rc...tc{left}...{down}lc...{right}bc & bc--tc & tc{left}..{down}lc & lc--rc & rc{up}..tc{left}...{down}lc...{right}bc & cycle) ;
+predefined_shapes[32] := (ll{right}...{right}lry--ur--ul--ll--cycle) ;
+predefined_shapes[33] := (ll{right}...{right}lry--ur--ul--ll--cycle--ul--ulx--ulx shifted(0,yyradius)--ur shifted(yyradius,yyradius)--lry shifted(yyradius,yyradius)--lry shifted(0,yyradius)--ur--ul--cycle ) ;
+predefined_shapes[34] := (uly..tc..ury & ury..tc shifted (0,-2yradius)..uly & uly--lly & lly..bc..lry & lry--ury & ury..tc shifted (0,-2yradius)..uly & cycle ) ;
+predefined_shapes[35] := (bc{right}...rc{up}...tc{left}...lc{down}...cycle) ;
+predefined_shapes[36] := (ul--tc{right}..rc{down}..{left}bc--ll & ll..(xpart llx, ypart lc)..ul & cycle) ;
+predefined_shapes[37] := (ul--tc{right}..rc{down}..{left}bc--ll & ll..(xpart llx, ypart lc)..ul & cycle) rotatedaround(origin,180) ;
+predefined_shapes[38] := (ll--lc{up}..tc{right}..{down}rc--lr & lr..(xpart bc, ypart lly)..ll & cycle) ;
+predefined_shapes[39] := (ll--lc{up}..tc{right}..{down}rc--lr & lr..(xpart bc, ypart lly)..ll & cycle) rotatedaround(origin,180) ;
+predefined_shapes[40] := (ll--lr--ur--ul--ll--ur--ul--ll--lr--ul--ll--cycle) ;
+predefined_shapes[41] := (ll--lr--ur--ul--ll--lr--rc--lc--ll--bc--tc--ul--ll & cycle) ;
+predefined_shapes[42] := (ll--lr--origin shifted (+epsilon,0)--ur--ul--origin shifted (-epsilon,0)--cycle) ;
+predefined_shapes[43] := (ll--ul--origin shifted (0,+epsilon)--ur--lr--origin shifted (0,-epsilon)--cycle) ;
+predefined_shapes[45] := (bc--rc--tc--lc--cycle) ;
+predefined_shapes[46] := (ll--ul--rc--cycle) ;
+predefined_shapes[47] := (ll--ul--rc--cycle) rotatedaround(origin,180) ;
+predefined_shapes[48] := (ul--ur--bc--cycle) rotatedaround(origin,180) ;
+predefined_shapes[49] := (ul--ur--bc--cycle) ;
+predefined_shapes[56] := (ll--lry--ury--ul--cycle) ;
+predefined_shapes[57] := (ll--lry--ury--ul--cycle) rotatedaround(origin,180) ;
+predefined_shapes[58] := (ll--ulx--urx--lr--cycle) ;
+predefined_shapes[59] := (ll--ulx--urx--lr--cycle) rotatedaround(origin,180);
+predefined_shapes[66] := (rc--origin shifted ( epsilon,0) --cycle & rc--origin--cycle ) ;
+predefined_shapes[67] := (lc--origin shifted (-epsilon,0) --cycle & lc--origin--cycle ) ;
+predefined_shapes[68] := (tc--origin shifted (0, epsilon) --cycle & tc--origin--cycle ) ;
+predefined_shapes[69] := (bc--origin shifted (0,-epsilon) --cycle & bc--origin--cycle ) ;
+predefined_shapes[75] := (lly--lry--ury--uly--cycle) rotatedaround(origin,180) ;
+predefined_shapes[76] := (ll--lr--ur--uly--cycle) rotatedaround(origin,180) ;
+predefined_shapes[77] := (ll--lr--ury--ul--cycle) rotatedaround(origin,180) ;
+predefined_shapes[78] := (lly--lr--ur--ul--cycle) rotatedaround(origin,180) ;
+predefined_shapes[79] := (ll--lry--ur--ul--cycle) rotatedaround(origin,180) ;
+
+numeric predefined_shapes_xradius ; predefined_shapes_xradius := xradius ;
+numeric predefined_shapes_yradius ; predefined_shapes_yradius := yradius ;
+numeric predefined_shapes_xxradius ; predefined_shapes_xxradius := xxradius ;
+numeric predefined_shapes_yyradius ; predefined_shapes_yyradius := yyradius ;
+
+endgroup ;
vardef some_shape_path (expr type) =
+ if known predefined_shapes[type] : predefined_shapes[type] else : predefined_shapes[0] fi
+enddef ;
+def some_shape (expr shape_type, shape_width, shape_height, shape_linewidth, shape_linecolor, shape_fillcolor) =
begingroup ;
-
- save border, xradius, yradius,
- normal, mirror, rotate,
- lc, rc, tc, bc, ll, lr, ur, ul,
- llx, lrx, urx, ulx, lly, lry, ury, uly ;
-
- path border ;
-
- xradius := .15 ; xxradius := .10 ;
- yradius := .15 ; yyradius := .10 ;
-
- pair ll ; ll := llcorner (unitsquare shifted (-.5,-.5)) ;
- pair lr ; lr := lrcorner (unitsquare shifted (-.5,-.5)) ;
- pair ur ; ur := urcorner (unitsquare shifted (-.5,-.5)) ;
- pair ul ; ul := ulcorner (unitsquare shifted (-.5,-.5)) ;
-
- pair llx ; llx := ll shifted (xradius,0) ;
- pair lly ; lly := ll shifted (0,yradius) ;
-
- pair lrx ; lrx := lr shifted (-xradius,0) ;
- pair lry ; lry := lr shifted (0,yradius) ;
-
- pair urx ; urx := ur shifted (-xradius,0) ;
- pair ury ; ury := ur shifted (0,-yradius) ;
-
- pair ulx ; ulx := ul shifted (xradius,0) ;
- pair uly ; uly := ul shifted (0,-yradius) ;
-
- pair llxx ; llxx := ll shifted (xxradius,0) ;
- pair llyy ; llyy := ll shifted (0,yyradius) ;
-
- pair lrxx ; lrxx := lr shifted (-xxradius,0) ;
- pair lryy ; lryy := lr shifted (0,yyradius) ;
-
- pair urxx ; urxx := ur shifted (-xxradius,0) ;
- pair uryy ; uryy := ur shifted (0,-yyradius) ;
-
- pair ulxx ; ulxx := ul shifted (xxradius,0) ;
- pair ulyy ; ulyy := ul shifted (0,-yyradius) ;
-
- pair lc ; lc := ll shifted (0,.5) ;
- pair rc ; rc := lr shifted (0,.5) ;
- pair tc ; tc := ul shifted (.5,0) ;
- pair bc ; bc := ll shifted (.5,0) ;
-
- def mirror (expr p) =
- p rotatedaround(origin,180)
- enddef ;
-
- def normal (expr p ) =
- p
- enddef ;
-
- def rotate (expr p) =
- p rotated 45
- enddef ;
-
- if type= 0 :
- border := normal (origin--cycle) ;
-
- elseif type= 5 :
- border := normal (llx--lrx{right}...rc...{left}urx--ulx{left}...lc...{right}cycle) ;
- elseif type= 6 :
- border := normal (ll--lrx{right}...rc...{left}urx--ul--cycle) ;
- elseif type= 7 :
- border := mirror (ll--lrx{right}...rc...{left}urx--ul--cycle) ;
- elseif type= 8 :
- border := normal (lr--ury{up}...tc...{down}uly--ll--cycle) ;
- elseif type= 9 :
- border := mirror (lr--ury{up}...tc...{down}uly--ll--cycle) ;
- elseif type=10 :
- border := normal (ll--lr--ur--ul--ll--ur--ul--ll--cycle) ;
- elseif type=11 :
- border := normal (ll--lr--ur--ul--ll--lr--ul--ll--cycle) ;
- elseif type=12 :
- border := normal (ll--lrx--ur--ulx--cycle) ;
- elseif type=13 :
- border := normal (llx--lr--urx--ul--cycle) ;
- elseif type=14 :
- border := normal (lly--bc--lry--ury--tc--uly--cycle) ;
- elseif type=15 :
- border := normal (llx--lrx--rc--urx--ulx--lc--cycle) ;
- elseif type=16 :
- border := normal (ll--lrx--rc--urx--ul--cycle) ;
- elseif type=17 :
- border := mirror (ll--lrx--rc--urx--ul--cycle) ;
- elseif type=18 :
- border := normal (lr--ury--tc--uly--ll--cycle) ;
- elseif type=19 :
- border := mirror (lr--ury--tc--uly--ll--cycle) ;
- elseif type=20 :
- border := normal (ll--lr--ur--ul--ll--llxx--ulxx--ul--ll--
- lr--ur--urxx--lrxx--cycle) ;
- elseif type=21 :
- border := normal (ul--ll--lr--ur--ul--ulyy--uryy--ur--ul--
- ll--lr--lryy--llyy--cycle) ;
- elseif type=22 :
- border := normal (ll--lrx--lry--ur--ulx--uly--cycle) ;
- elseif type=23 :
- border := normal (llx--lr--ury--urx--ul--lly--cycle) ;
- elseif type=24 :
- border := normal (ll--lr--ur--ul--cycle) ;
- elseif type=25 :
- border := normal (llx--lrx--lry--ury--urx--ulx--uly--lly--cycle) ;
- elseif type=26 :
- border := normal (ll--lrx--lry--ur--ul--cycle) ;
- elseif type=27 :
- border := mirror (ll--lr--ury--urx--ul--cycle) ;
- elseif type=28 :
- border := normal (ll--lr--ury--urx--ul--cycle) ;
- elseif type=29 :
- border := mirror (ll--lrx--lry--ur--ul--cycle) ;
- elseif type=30 :
- border := rotate (bc{right}...{up}rc...tc{left}...{down}lc...{right}bc &
- bc--tc & tc{left}..{down}lc & lc--rc &
- rc{up}..tc{left}...{down}lc...{right}bc & cycle) ;
- elseif type=31 :
- border := normal (bc{right}...{up}rc...tc{left}...{down}lc...{right}bc &
- bc--tc & tc{left}..{down}lc & lc--rc &
- rc{up}..tc{left}...{down}lc...{right}bc & cycle) ;
- elseif type=32 :
- border := normal (ll{right}...{right}lry--ur--ul--ll--cycle) ;
- elseif type=33 :
- border := normal (ll{right}...{right}lry--ur--ul--ll--cycle
- --ul--ulx--ulx shifted(0,yyradius)
- --ur shifted(yyradius,yyradius)
- --lry shifted(yyradius,yyradius)
- --lry shifted(0,yyradius)
- --ur--ul--cycle ) ;
- elseif type=34 :
- border := normal (uly..tc..ury &
- ury..tc shifted (0,-2yradius)..uly &
- uly--lly &
- lly..bc..lry &
- lry--ury &
- ury..tc shifted (0,-2yradius)..uly & cycle ) ;
- elseif type=35 :
- border := normal (bc{right}...rc{up}...tc{left}...lc{down}...cycle) ;
- elseif type=36 :
- border := normal (ul--tc{right}..rc{down}..{left}bc--ll &
- ll..(xpart llx, ypart lc)..ul & cycle) ;
- elseif type=37 :
- border := mirror (ul--tc{right}..rc{down}..{left}bc--ll &
- ll..(xpart llx, ypart lc)..ul & cycle) ;
- elseif type=38 :
- border := normal (ll--lc{up}..tc{right}..{down}rc--lr &
- lr..(xpart bc, ypart lly)..ll & cycle) ;
- elseif type=39 :
- border := mirror (ll--lc{up}..tc{right}..{down}rc--lr &
- lr..(xpart bc, ypart lly)..ll & cycle) ;
- elseif type=40 :
- border := normal (ll--lr--ur--ul--ll--ur--ul--ll--lr--ul--ll--cycle) ;
- elseif type=41 :
- border := normal (ll--lr--ur--ul--ll--lr--rc--lc--ll--bc--tc--ul--ll & cycle) ;
- elseif type=42 :
- border := normal (ll--lr--origin shifted (+epsilon,0)--
- ur--ul--origin shifted (-epsilon,0)--cycle) ;
- elseif type=43 :
- border := normal (ll--ul--origin shifted (0,+epsilon)--
- ur--lr--origin shifted (0,-epsilon)--cycle) ;
- elseif type=45 :
- border := normal (bc--rc--tc--lc--cycle) ;
- elseif type=46 :
- border := normal (ll--ul--rc--cycle) ;
- elseif type=47 :
- border := mirror (ll--ul--rc--cycle) ;
- elseif type=48 :
- border := mirror (ul--ur--bc--cycle) ;
- elseif type=49 :
- border := normal (ul--ur--bc--cycle) ;
-
- elseif type=56 :
- border := normal (ll--lry--ury--ul--cycle) ;
- elseif type=57 :
- border := mirror (ll--lry--ury--ul--cycle) ;
- elseif type=58 :
- border := normal (ll--ulx--urx--lr--cycle) ;
- elseif type=59 :
- border := mirror (ll--ulx--urx--lr--cycle) ;
-
- elseif type=61 :
- border := normal (fullcircle scaled (1.5*yradius) xscaled (grid_height/grid_width)) ;
- elseif type=62 :
- border := normal (fullcircle scaled (2.0*yradius) xscaled (grid_height/grid_width)) ;
-
- elseif type=66 :
- border := normal (rc--origin shifted ( epsilon,0) --cycle &
- rc--origin --cycle ) ;
- elseif type=67 :
- border := normal (lc--origin shifted (-epsilon,0) --cycle &
- lc--origin --cycle ) ;
- elseif type=68 :
- border := normal (tc--origin shifted (0, epsilon) --cycle &
- tc--origin --cycle ) ;
- elseif type=69 :
- border := normal (bc--origin shifted (0,-epsilon) --cycle &
- bc--origin --cycle ) ;
-
- elseif type=75 :
- border := mirror (lly--lry--ury--uly--cycle) ;
- elseif type=76 :
- border := mirror (ll--lr--ur--uly--cycle) ;
- elseif type=77 :
- border := mirror (ll--lr--ury--ul--cycle) ;
- elseif type=78 :
- border := mirror (lly--lr--ur--ul--cycle) ;
- elseif type=79 :
- border := mirror (ll--lry--ur--ul--cycle) ;
-
- else :
- border := normal (origin--cycle) ;
- %border := normal (ll--lr--ur--ul--cycle) ;
- fi ;
-
- border
-
- endgroup
-
-enddef;
-
-def some_shape ( expr shape_type ,
- shape_width ,
- shape_height ,
- shape_linewidth ,
- shape_linecolor ,
- shape_fillcolor ) =
-
- path p ; p :=
- some_shape_path (shape_type)
- xscaled shape_width
- yscaled shape_height ;
-
- pickup pencircle scaled shape_linewidth ;
-
- fill p withcolor shape_fillcolor ;
- draw p withcolor shape_linecolor ;
-
-enddef ;
+ save p ; path p ;
+ p := some_shape_path (shape_type) xscaled shape_width yscaled shape_height ;
+ pickup pencircle scaled shape_linewidth ;
+ fill p withcolor shape_fillcolor ;
+ draw p withcolor shape_linecolor ;
+ endgroup ;
+enddef ;
vardef drawshape (expr t, p, lw, lc, fc) =
- save pp ;
- if t>1 : % normal shape
- path pp ;
- pp := some_shape_path(t) xyscaled(bbwidth(p), bbheight(p)) shifted center p ;
- fill pp withcolor fc ;
- draw pp withpen pencircle scaled lw withcolor lc ;
- elseif t=1 : % background only
- path pp ;
- pp := fullsquare xyscaled(bbwidth(p), bbheight(p)) shifted center p ;
- fill pp withcolor fc ;
- else : % dimensions only
- picture pp ; pp := nullpicture ;
- setbounds pp to fullsquare xyscaled(bbwidth(p), bbheight(p)) shifted center p ;
- draw pp ;
- fi ;
+ save pp ;
+ if t>1 : % normal shape
+ path pp ;
+ pp := some_shape_path(t) xyscaled(bbwidth(p), bbheight(p)) shifted center p ;
+ fill pp withcolor fc ;
+ draw pp withpen pencircle scaled lw withcolor lc ;
+ elseif t=1 : % background only
+ path pp ;
+ pp := fullsquare xyscaled(bbwidth(p), bbheight(p)) shifted center p ;
+ fill pp withcolor fc ;
+ else : % dimensions only
+ picture pp ; pp := nullpicture ;
+ setbounds pp to fullsquare xyscaled(bbwidth(p), bbheight(p)) shifted center p ;
+ draw pp ;
+ fi ;
enddef ;
vardef drawline (expr t, p, lw, lc) =
- if (t>0) and (length(p)>1) :
- saveoptions ;
- drawoptions(withpen pencircle scaled lw withcolor lc) ;
- draw p ;
- if t = 1 :
- draw arrowheadonpath(p,1) ;
- elseif t = 2 :
- draw arrowheadonpath(reverse p,1) ;
- elseif t = 3 :
- for $ = p,reverse p : draw arrowheadonpath($,1) ; endfor ;
- elseif t = 11 :
- draw arrowheadonpath(p,1/2) ;
- elseif t = 12 :
- draw arrowheadonpath(reverse p,1/2) ;
- elseif t = 13 :
- for $=p,reverse p : draw arrowheadonpath($,1) ; endfor ;
- for $=p,reverse p : draw arrowheadonpath($,3/4) ; endfor ;
- elseif t = 21 :
- for $=1/5,1/2,4/5 : draw arrowheadonpath(p,$) ; endfor ;
- elseif t = 22 :
- for $=1/5,1/2,4/5 : draw arrowheadonpath(reverse p,$) ; endfor ;
- elseif t = 23 :
- for $=p,reverse p : draw arrowheadonpath($,1/4) ; endfor ;
+ if (t>0) and (length(p)>1) :
+ saveoptions ;
+ drawoptions(withpen pencircle scaled lw withcolor lc) ;
+ draw p ;
+ if t = 1 :
+ draw arrowheadonpath(p,1) ;
+ elseif t = 2 :
+ draw arrowheadonpath(reverse p,1) ;
+ elseif t = 3 :
+ for $ = p,reverse p :
+ draw arrowheadonpath($,1) ;
+ endfor ;
+ elseif t = 11 :
+ draw arrowheadonpath(p,1/2) ;
+ elseif t = 12 :
+ draw arrowheadonpath(reverse p,1/2) ;
+ elseif t = 13 :
+ for $=p,reverse p :
+ draw arrowheadonpath($,1) ;
+ endfor ;
+ for $=p,reverse p :
+ draw arrowheadonpath($,3/4) ;
+ endfor ;
+ elseif t = 21 :
+ for $=1/5,1/2,4/5 :
+ draw arrowheadonpath(p,$) ;
+ endfor ;
+ elseif t = 22 :
+ for $=1/5,1/2,4/5 :
+ draw arrowheadonpath(reverse p,$) ;
+ endfor ;
+ elseif t = 23 :
+ for $=p,reverse p :
+ draw arrowheadonpath($,1/4) ;
+ endfor ;
+ fi ;
fi ;
- fi ;
enddef ;
-endinput ;
+endinput ;
diff --git a/scripts/context/lua/mtxrun.lua b/scripts/context/lua/mtxrun.lua
index a4731ad06..bf6b8ea26 100644
--- a/scripts/context/lua/mtxrun.lua
+++ b/scripts/context/lua/mtxrun.lua
@@ -5244,6 +5244,10 @@ local function set(t,what,newvalue)
if type(what) ~= "table" then
return
end
+ if not done then -- catch ... why not set?
+ done = { }
+ t.done = done
+ end
for w, value in next, what do
if value == "" then
value = newvalue
diff --git a/scripts/context/stubs/mswin/mtxrun.lua b/scripts/context/stubs/mswin/mtxrun.lua
index a4731ad06..bf6b8ea26 100644
--- a/scripts/context/stubs/mswin/mtxrun.lua
+++ b/scripts/context/stubs/mswin/mtxrun.lua
@@ -5244,6 +5244,10 @@ local function set(t,what,newvalue)
if type(what) ~= "table" then
return
end
+ if not done then -- catch ... why not set?
+ done = { }
+ t.done = done
+ end
for w, value in next, what do
if value == "" then
value = newvalue
diff --git a/scripts/context/stubs/unix/mtxrun b/scripts/context/stubs/unix/mtxrun
index a4731ad06..bf6b8ea26 100644
--- a/scripts/context/stubs/unix/mtxrun
+++ b/scripts/context/stubs/unix/mtxrun
@@ -5244,6 +5244,10 @@ local function set(t,what,newvalue)
if type(what) ~= "table" then
return
end
+ if not done then -- catch ... why not set?
+ done = { }
+ t.done = done
+ end
for w, value in next, what do
if value == "" then
value = newvalue
diff --git a/tex/context/base/back-ini.lua b/tex/context/base/back-ini.lua
index 10d10c253..0c02e201a 100644
--- a/tex/context/base/back-ini.lua
+++ b/tex/context/base/back-ini.lua
@@ -8,6 +8,7 @@ if not modules then modules = { } end modules ['back-ini'] = {
local next, type = next, type
local format = string.format
+local sind, cosd = math.sind, math.cosd
backends = backends or { }
local backends = backends
@@ -91,3 +92,11 @@ tables.vfspecials = allocate {
startslant = comment,
stopslant = comment,
}
+
+-- -- experimental code --
+
+function commands.pdfrotation(a)
+ local s, c = sind(a), cosd(a)
+ context("%s %s %s %s",c,s,-s,c)
+end
+
diff --git a/tex/context/base/back-pdf.mkiv b/tex/context/base/back-pdf.mkiv
index 0bd256241..db42a85dd 100644
--- a/tex/context/base/back-pdf.mkiv
+++ b/tex/context/base/back-pdf.mkiv
@@ -124,20 +124,44 @@
%D Transformations. Some day we will use primitives (once they're fixed).
+% \def\dostartscaling#1#2% the test is needed because acrobat is bugged!
+% {\forcecolorhack % maybe use signal instead
+% \pdfliteral{q \ifdim#1\points=\zeropoint.0001\else#1\fi\space 0 0
+% \ifdim#2\points=\zeropoint.0001\else#2\fi\space 0 0 cm}}
+%
+% \def\dostopscaling
+% {\pdfliteral{Q}}
+%
+% \def\dostartrotation#1% grouped
+% {\forcecolorhack % maybe use signal instead
+% \pdfliteral{q \cldcontext{lpdf.rotationcm(#1)}}}
+%
+% \def\dostoprotation
+% {\pdfliteral{Q}}
+
+% function lpdf.rotationcm(a)
+% local s, c = sind(a), cosd(a)
+% return format("%s %s %s %s 0 0 cm",c,s,-s,c)
+% end
+
+% todo: inject at the lua end
+
\def\dostartrotation#1% grouped
{\forcecolorhack % maybe use signal instead
- \pdfliteral{q \cldcontext{lpdf.rotationcm(#1)}}}
+ \pdfsave \pdfsetmatrix
+ {\ctxcommand{pdfrotation(#1)}}}
\def\dostoprotation
- {\pdfliteral{Q}}
+ {\pdfrestore}
\def\dostartscaling#1#2% the test is needed because acrobat is bugged!
{\forcecolorhack % maybe use signal instead
- \pdfliteral{q \ifdim#1\points=\zeropoint.0001\else#1\fi\space 0 0
- \ifdim#2\points=\zeropoint.0001\else#2\fi\space 0 0 cm}}
+ \pdfsave \pdfsetmatrix
+ {\ifdim#1\points=\zeropoint.0001\else#1\fi\space 0 0
+ \ifdim#2\points=\zeropoint.0001\else#2\fi\space}}% 0 0
\def\dostopscaling
- {\pdfliteral{Q}}
+ {\pdfrestore}
\def\dostartmirroring{\pdfliteral{-1 0 0 1 0 0 cm}}
\def\dostopmirroring {\pdfliteral{-1 0 0 1 0 0 cm}}
diff --git a/tex/context/base/chem-str.lua b/tex/context/base/chem-str.lua
index 043cff039..7a63c2efb 100644
--- a/tex/context/base/chem-str.lua
+++ b/tex/context/base/chem-str.lua
@@ -230,9 +230,9 @@ local function process(spec,text,n,rulethickness,rulecolor,offset)
m = m + 1 ; metacode[m] = syntax.pb.direct
if keys[special] == "text" and index then
if keys["c"..special] == "text" then -- can be option: auto ...
- metacode[#metacode+1] = format('chem_c%s(%s,%s,"");',special,bonds,index)
+ m = m + 1 ; metacode[m] = format('chem_c%s(%s,%s,"");',special,bonds,index)
else
- metacode[#metacode+1] = format('chem_%s(%s,%s,"");',special,bonds,index)
+ m = m + 1 ; metacode[m] = format('chem_%s(%s,%s,"");',special,bonds,index)
end
end
elseif operation == "save" then
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index b3a6e6616..6179404f5 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.10.03 12:59}
+\newcontextversion{2011.10.05 23:32}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index 5e78ffb75..4619a0afa 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.10.03 12:59}
+\newcontextversion{2011.10.05 23:32}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index ab813a18b..2356199fe 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 259d4f188..db19cead5 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index ca149be97..94db10b61 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.10.03 12:59}
+\edef\contextversion{2011.10.05 23:32}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index d2d91489b..65b828324 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.10.03 12:59}
+\edef\contextversion{2011.10.05 23:32}
%D For those who want to use this:
diff --git a/tex/context/base/core-env.mkiv b/tex/context/base/core-env.mkiv
index dbf2b5944..5b23ec121 100644
--- a/tex/context/base/core-env.mkiv
+++ b/tex/context/base/core-env.mkiv
@@ -414,15 +414,15 @@
\def\??vars{@@vars}
-\def\setvariables {\dotripleargument\dosetvariables[\getrawparameters ]}
-\def\setevariables{\dotripleargument\dosetvariables[\getraweparameters]}
-\def\setgvariables{\dotripleargument\dosetvariables[\getrawgparameters]}
-\def\setxvariables{\dotripleargument\dosetvariables[\getrawxparameters]}
+\unexpanded\def\setvariables {\dotripleargument\dosetvariables[\getrawparameters ]}
+\unexpanded\def\setevariables{\dotripleargument\dosetvariables[\getraweparameters]}
+\unexpanded\def\setgvariables{\dotripleargument\dosetvariables[\getrawgparameters]}
+\unexpanded\def\setxvariables{\dotripleargument\dosetvariables[\getrawxparameters]}
-\def\globalsetvariables % obsolete
+\unexpanded\def\globalsetvariables % obsolete
{\dotripleargument\dosetvariables[\globalgetrawparameters]}
-\long\def\dosetvariables[#1][#2][#3]% tricky, test on s-pre-60
+\def\dosetvariables[#1][#2][#3]% tricky, test on s-pre-60
{\errorisfataltrue
\doifelse{#2}\currentvariableclass
{#1[\??vars:#2:][#3]}%
@@ -434,10 +434,10 @@
\popmacro\currentvariableclass}%
\errorisfatalfalse}
-\long\def\setvariable #1#2#3{\long\expandafter\def \csname\??vars:#1:#2\endcsname{#3}}
-\long\def\setevariable#1#2#3{\long\expandafter\edef\csname\??vars:#1:#2\endcsname{#3}}
-\long\def\setgvariable#1#2#3{\long\expandafter\gdef\csname\??vars:#1:#2\endcsname{#3}}
-\long\def\setxvariable#1#2#3{\long\expandafter\xdef\csname\??vars:#1:#2\endcsname{#3}}
+\unexpanded\def\setvariable #1#2#3{\long\expandafter\def \csname\??vars:#1:#2\endcsname{#3}}
+\unexpanded\def\setevariable#1#2#3{\long\expandafter\edef\csname\??vars:#1:#2\endcsname{#3}}
+\unexpanded\def\setgvariable#1#2#3{\long\expandafter\gdef\csname\??vars:#1:#2\endcsname{#3}}
+\unexpanded\def\setxvariable#1#2#3{\long\expandafter\xdef\csname\??vars:#1:#2\endcsname{#3}}
\def\getvariable#1#2%
{\csname
diff --git a/tex/context/base/file-job.mkvi b/tex/context/base/file-job.mkvi
index 0213ff910..3270d9511 100644
--- a/tex/context/base/file-job.mkvi
+++ b/tex/context/base/file-job.mkvi
@@ -175,7 +175,8 @@
%D Handy for modules that have a test/demo appended.
-\def\continueifinputfile#1{\doifnot\inputfilename{#1}{\endinput}}
+\def\continueifinputfile#name{\doifnot\inputfilename{#name}\endinput}
+%def\processifinputfile #name{\doif \inputfilename{#name}}
% \startproject test
% 1: \startmode[*project] project \stopmode \endgraf
diff --git a/tex/context/base/font-def.lua b/tex/context/base/font-def.lua
index 533d1ec3c..e3f564f24 100644
--- a/tex/context/base/font-def.lua
+++ b/tex/context/base/font-def.lua
@@ -299,7 +299,7 @@ function definers.loadfont(specification)
local embedding
if directive_embedall then
embedding = "full"
- elseif properties.filename and constructors.dontembed[properties.filename] then
+ elseif properties and properties.filename and constructors.dontembed[properties.filename] then
embedding = "no"
else
embedding = "subset"
diff --git a/tex/context/base/font-otf.lua b/tex/context/base/font-otf.lua
index 319cae65b..83b961e28 100644
--- a/tex/context/base/font-otf.lua
+++ b/tex/context/base/font-otf.lua
@@ -114,15 +114,21 @@ local function showfeatureorder(rawdata,filename)
if features then
for feature, scripts in next, features do
local tt = { }
- for script, languages in next, scripts do
- local ttt = { }
- for language, _ in next, languages do
- ttt[#ttt+1] = language
+ if type(scripts) == "table" then
+ for script, languages in next, scripts do
+ local ttt = { }
+ for language, _ in next, languages do
+ ttt[#ttt+1] = language
+ end
+ tt[#tt+1] = format("[%s: %s]",script,concat(ttt," "))
+ end
+ if trace_loading then
+ report_otf(" %s: %s",feature,concat(tt," "))
+ end
+ else
+ if trace_loading then
+ report_otf(" %s: %s",feature,tostring(scripts))
end
- tt[#tt+1] = format("[%s: %s]",script,concat(ttt," "))
- end
- if trace_loading then
- report_otf(" %s: %s",feature,concat(tt," "))
end
end
end
diff --git a/tex/context/base/font-ott.lua b/tex/context/base/font-ott.lua
index 800fd3c65..c13a20246 100644
--- a/tex/context/base/font-ott.lua
+++ b/tex/context/base/font-ott.lua
@@ -6,7 +6,7 @@ if not modules then modules = { } end modules ['font-otf'] = {
license = "see context related readme files"
}
-local type, next, tonumber, tostring, rawget = type, next, tonumber, tostring, rawget
+local type, next, tonumber, tostring, rawget, rawset = type, next, tonumber, tostring, rawget, rawset
local gsub, lower, format, match = string.gsub, string.lower, string.format, string.match
local is_boolean = string.is_boolean
@@ -635,11 +635,18 @@ local baselines = allocate {
['romn'] = 'roman baseline'
}
+local acceptscripts = true directives.register("otf.acceptscripts", function(v) acceptscripts = v end)
+local acceptlanguages = true directives.register("otf.acceptlanguages", function(v) acceptlanguages = v end)
+
+local report_checks = logs.reporter("fonts","checks")
+
tables.scripts = scripts
tables.languages = languages
tables.features = features
tables.baselines = baselines
+-- hm, we overload the metatables
+
if otffeatures.features then
for k, v in next, otffeatures.features do
features[k] = v
@@ -670,7 +677,6 @@ local function resolve(t,k)
return v
end
end
- return "dflt"
end
setmetatableindex(verbosescripts, resolve)
@@ -678,20 +684,51 @@ setmetatableindex(verboselanguages, resolve)
setmetatableindex(verbosefeatures, resolve)
setmetatableindex(verbosebaselines, resolve)
-local function resolve(t,k)
+setmetatableindex(scripts, function(t,k)
if k then
k = lower(k)
- local v = rawget(t,k) or rawget(t,gsub(k," ",""))
+ if k == "dflt" then
+ return k
+ end
+ local v = rawget(t,k)
if v then
return v
end
+ k = gsub(k," ","")
+ v = rawget(t,v)
+ if v then
+ return v
+ elseif acceptscripts then
+ report_checks("registering extra script: %s",k)
+ rawset(t,k,k)
+ return k
+ end
end
return "dflt"
-end
+end)
-setmetatableindex(scripts, resolve)
-setmetatableindex(scripts, resolve)
-setmetatableindex(languages, resolve)
+setmetatableindex(languages, function(t,k)
+ if k then
+ k = lower(k)
+ if k == "dflt" then
+ return k
+ end
+ local v = rawget(t,k)
+ if v then
+ return v
+ end
+ k = gsub(k," ","")
+ v = rawget(t,v)
+ if v then
+ return v
+ elseif acceptlanguages then
+ report_checks("registering extra languages: %s",k)
+ rawset(t,k,k)
+ return k
+ end
+ end
+ return "dflt"
+end)
setmetatablenewindex(languages, "ignore")
setmetatablenewindex(baselines, "ignore")
@@ -745,18 +782,10 @@ function otf.features.normalize(features) -- no longer 'lang'
k = lower(k)
if k == "language" then
v = gsub(lower(v),"[^a-z0-9]","")
- if rawget(languages,v) then
- h.language = v
- else
- h.language = rawget(verboselanguages,v) or "dflt"
- end
+ h.language = rawget(verboselanguages,v) or languages[v] or "dflt" -- auto adds
elseif k == "script" then
v = gsub(lower(v),"[^a-z0-9]","")
- if rawget(scripts,v) then
- h.script = v
- else
- h.script = rawget(verbosescripts,v) or "dflt"
- end
+ h.script = rawget(verbosescripts,v) or scripts[v] or "dflt" -- auto adds
else
if type(v) == "string" then
local b = is_boolean(v)
diff --git a/tex/context/base/lpdf-ano.lua b/tex/context/base/lpdf-ano.lua
index eb85c3dea..fe48613a9 100644
--- a/tex/context/base/lpdf-ano.lua
+++ b/tex/context/base/lpdf-ano.lua
@@ -6,6 +6,8 @@ if not modules then modules = { } end modules ['lpdf-ano'] = {
license = "see context related readme files"
}
+-- when using rotation: \disabledirectives[refences.sharelinks] (maybe flag links)
+
local next, tostring = next, tostring
local rep, format = string.rep, string.format
local texcount = tex.count
@@ -254,7 +256,7 @@ local function use_shared_annotations()
local h, v = pdf.h, pdf.v
local llx, lly = h*factor, (v - depth)*factor
local urx, ury = (h + width)*factor, (v + height)*factor
- local annot = format("<< /Type /Annot %s /Rect [%0.2f %0.2f %0.2f %0.2f] >>",prerolled,llx,lly,urx,ury)
+ local annot = format("<< /Type /Annot %s /Rect [%0.3f %0.3f %0.3f %0.3f] >>",prerolled,llx,lly,urx,ury)
local n = hashed[annot]
if not n then
n = pdfdelayedobject(annot)
diff --git a/tex/context/base/lxml-tex.lua b/tex/context/base/lxml-tex.lua
index 8c6cbbb06..0dd85a808 100644
--- a/tex/context/base/lxml-tex.lua
+++ b/tex/context/base/lxml-tex.lua
@@ -48,6 +48,8 @@ local trace_comments = false trackers.register("lxml.comments", function(v) tra
local report_lxml = logs.reporter("xml","tex")
+local forceraw, rawroot = false, nil
+
-- tex entities
--
-- todo: unprivatize attributes
@@ -70,36 +72,40 @@ function lxml.registerentity(key,value)
end
function lxml.resolvedentity(str)
- local e = texentities[str]
- if e then
- local te = type(e)
- if te == "function" then
- e(str)
- elseif e then
- context(e)
- end
- return
- end
- local e = xmlentities[str]
- if e then
- local te = type(e)
- if te == "function" then
- e = e(str)
+ if forceraw then
+ context("&%s;",str)
+ else
+ local e = texentities[str]
+ if e then
+ local te = type(e)
+ if te == "function" then
+ e(str)
+ elseif e then
+ context(e)
+ end
+ return
end
+ local e = xmlentities[str]
if e then
- contextsprint(notcatcodes,e)
+ local te = type(e)
+ if te == "function" then
+ e = e(str)
+ end
+ if e then
+ contextsprint(notcatcodes,e)
+ end
+ return
+ end
+ -- resolve hex and dec, todo: escape # & etc for ctxcatcodes
+ -- normally this is already solved while loading the file
+ local chr, err = lpegmatch(parsedentity,str)
+ if chr then
+ context(chr)
+ elseif err then
+ context(err)
+ else
+ context.xmle(str,utfupper(str)) -- we need to use our own upper
end
- return
- end
- -- resolve hex and dec, todo: escape # & etc for ctxcatcodes
- -- normally this is already solved while loading the file
- local chr, err = lpegmatch(parsedentity,str)
- if chr then
- context(chr)
- elseif err then
- context(err)
- else
- context.xmle(str,utfupper(str)) -- we need to use our own upper
end
end
@@ -153,8 +159,6 @@ lxml.toverbatim = context.newverbosehandler {
-- raw flushing
-local forceraw, rawroot = false, nil
-
function lxml.startraw()
forceraw = true
end
@@ -575,17 +579,19 @@ function lxml.setaction(id,pattern,action)
end
end
-local function sprint(root)
+local function sprint(root) -- check rawroot usage
if root then
local tr = type(root)
if tr == "string" then -- can also be result of lpath
- -- rawroot = false
+ -- rawroot = false -- ?
root = xmlunprivatized(root)
lpegmatch(xmltextcapture,root)
elseif tr == "table" then
if forceraw then
rawroot = root
- contextsprint(ctxcatcodes,xmltostring(root))
+ -- contextsprint(ctxcatcodes,xmltostring(root)) -- goe wrong with % etc
+ root = xmlunprivatized(xmltostring(root))
+ lpegmatch(xmltextcapture,root) -- goes to toc
else
xmlserialize(root,xmltexhandler)
end
@@ -622,7 +628,9 @@ local function cprint(root) -- content
local rootdt = root.dt
if forceraw then
rawroot = root
- contextsprint(ctxcatcodes,xmltostring(rootdt or root))
+ -- contextsprint(ctxcatcodes,xmltostring(rootdt or root))
+ root = xmlunprivatized(xmltostring(root))
+ lpegmatch(xmltextcapture,root) -- goes to toc
else
xmlserialize(rootdt or root,xmltexhandler)
end
diff --git a/tex/context/base/m-chart.mkiv b/tex/context/base/m-chart.mkiv
index 3850adf32..165cb1720 100644
--- a/tex/context/base/m-chart.mkiv
+++ b/tex/context/base/m-chart.mkiv
@@ -14,1278 +14,6 @@
%D This module will be reimplemented as it can be done much more
%D simple now in mkiv,.
-
-% todo: \localpushmacro/\localpopmacro (dohandleflowchart etc)
-% todo: make mkiv variant
-% todo: use dimexpr/numspr
-
-% will be redone with layers and dimexpr or even better, by just using
-% textext .. a nice example of old code
-
-%D This is an experimental module. Pieces of code will be moved
-%D to other modules. More features are possible but will be
-%D interfaces later.
-%D
-%D When finished this module will be documented. The main macro
-%D is still a rather big one and there is some redundant and
-%D slow code that needs a clean up.
-
-% arrow, dash
-% crossing
-% \goto -> \normalgoto
-% class -> class:name (ref prefix)
-% c, automatisch geen overlap zoeken
-% eind eerder chart connecties
-% relateren aan korps
-% check op bestaan naam, bestaan shape
-% auto als extern figuur
-% subchart
-% pijlen
-% focus
-% ook nog \MPmessage
-% areapath -> krappe vlak
-% clippath -> gehele vlak
-%
-% offset : clip offset
-% breedte : breedte cel
-% hoogte : hoogte cel
-% dx : halve afstand in breedte (grid breedte = breedte + 2dx)
-% dy : halve afstand in hoogte (grid hoogte = hoogte + 2dy)
-% x : x offset (clipping)
-% y : y offset (clipping)
-% nx : minimaal aantal cellen horizontaal
-% ny : minimaal aantal cellen vertikaal
-%
-% shape none en geen equivalent maken
-%
-% kaderkleur achtergrondkleur
-% lijnkleur lijndikte
-% focus focuskaderkleur focusachtergrondkleur
-% richting
-%
-% focus koppelen aan kleur
-
-\unprotect
-
-\definesorting [flowchart] [flowcharts] [\v!none] % no access
-\setupsorting [flowchart] [\c!state=\v!stop] % off by default
-
-\def\@FLOW@{@FLOW@}
-\def\@FLOC@{@FLOC@}
-\def\@FLOX@{@FLOX@}
-
-\def\@@FLOW{@@FLOW}
-\def\@@FLOL{@@FLOL}
-\def\@@FLOS{@@FLOS}
-\def\@@FLOF{@@FLOF}
-\def\@@FLOT{@@FLOT}
-\def\@@FLOX{@@FLOX}
-
-\def\@@MPx {@@MPx}
-\def\@@MPy {@@MPy}
-
-\def\FLOWbufferprefix{flw-}
-
-\def\processFLOWbuffer#1{\getbuffer[\FLOWbufferprefix#1]}
-\def\typeFLOWbuffer #1{\typebuffer[\FLOWbufferprefix#1]}
-
-\def\setFLOWname#1#2% funny hack that makes sure that we get
- {\bgroup % names that are acceptable for METAPOST
- \lccode`0=`a\lccode`1=`b\lccode`2=`c\lccode`3=`d\lccode`4=`e%
- \lccode`5=`f\lccode`6=`g\lccode`7=`h\lccode`8=`i\lccode`9=`j%
- \lccode` =`\_\lccode`-=`\_\lccode`_=`\_%
- \lowercase{\gdef#1{#2}}% todo: make a ctxlua call of this
- \egroup}
-
-% een gobble als default is sneller, en dan alleen setten als
-% nodig
-
-\def\resetFLOWcell
- {% variables
- \global\let\FLOWname \empty
- \global\let\FLOWalign \empty
- \global\let\FLOWshape \empty
- \global\let\FLOWlocation \empty
- \global\let\FLOWtext \empty
- \global\let\FLOWhelp \empty
- \global\let\FLOWdestination\empty
- \global\let\FLOWoverlay \empty
- \global\let\FLOWfocus \empty
- \global\let\tFLOWlabel \empty
- \global\let\bFLOWlabel \empty
- \global\let\lFLOWlabel \empty
- \global\let\rFLOWlabel \empty
- \global\let\bcFLOWlabel \empty
- \global\let\tcFLOWlabel \empty
- \global\let\lcFLOWlabel \empty
- \global\let\rcFLOWlabel \empty
- \global\let\tFLOWexit \empty
- \global\let\bFLOWexit \empty
- \global\let\lFLOWexit \empty
- \global\let\rFLOWexit \empty
- % commands
- \let\name \doFLOWname
- \let\shape \doFLOWshape
- \let\destination\doFLOWdestination
- \let\location \doFLOWlocation
- \let\focus \doFLOWfocus
- \let\overlay \doFLOWoverlay
- \let\figure \doFLOWfigure
- \let\text \doFLOWtext
- \let\comment \doFLOWcomment
- \let\label \doFLOWlabel
- \let\help \doFLOWhelp
- \let\connection \doFLOWconnection
- \let\exit \doFLOWexit
- % convenience commands
- \let\locate \doFLOWlocate
- \let\connect \doFLOWconnect}
-
-\let\FLOWcell \s!unknown
-\let\FLOWshape \s!unknown
-\let\FLOWdestination\s!unknown
-\let\FLOWfocus \s!unknown
-\let\FLOWoverlay \empty
-\let\FLOWtext \empty
-
-\def\doFLOWname#1%
- {\def\FLOWcell{#1}\setFLOWname\FLOWname{name_#1}\ignorespaces}
-
-\def\doFLOWshape#1%
- {\gdef\FLOWshape{#1}\ignorespaces}
-
-\def\doFLOWdestination#1%
- {\gdef\FLOWdestination{#1}\ignorespaces}
-
-\def\doFLOWlocation#1%
- {\setFLOWlocation#1\end\ignorespaces}
-
-\def\doFLOWfocus#1%
- {\gdef\FLOWfocus{#1}\ignorespaces}
-
-\def\doFLOWoverlay#1%
- {\gdef\FLOWoverlay{#1}\ignorespaces}
-
-\def\doFLOWfigure#1%
- {\defineoverlay[\s!dummy][\overlayfigure{#1}]%
- \overlay\s!dummy}
-
-\def\doFLOWtext
- {\dosingleempty\dodoFLOWtext}
-
-\def\dodoFLOWtext[#1]% % #2%
- {\gdef\FLOWalign{#1}\gdef\FLOWtext}% {#2}}
-
-\def\doFLOWcomment[#1]#2%
- {\ignorespaces\dogobblesingleempty}
-
-\def\doFLOWlabel[#1]#2% wordt dit gebruikt ?
- {\setgvalue{#1FLOWlabel}{#2}\ignorespaces}
-
-\def\doFLOWhelp#1%
- {\gdef\FLOWhelp{#1}\ignorespaces}
-
-\def\doFLOWconnection
- {\dodoubleempty\dodoFLOWconnection}
-
-\def\dodoFLOWconnection[#1][#2]#3%
- {\ignorespaces}
-
-\def\doFLOWconnect
- {\connection}
-
-\def\doFLOWlocate
- {\location}
-
-\def\doFLOWexit[#1]#2%
- {\setgvalue{#1FLOWexit}{#2}\ignorespaces}
-
-\def\startFLOWchart
- {\bgroup
- \let\stopFLOWchart\egroup
- \obeylines % lelijk, buffers nog eens fatsoeneren
- \dodoubleempty\dostartFLOWchart}
-
-\def\dostartFLOWchart[#1][#2]%
- {\preparenextFLOWchart{#1}{#2}%
- \dostartbuffer[\FLOWbufferprefix\nofFLOWcharts][startFLOWchart][stopFLOWchart]}
-
-\def\defineFLOWchart%
- {\dodoubleempty\dodefineFLOWchart}
-
-\long\def\dodefineFLOWchart[#1][#2]#3%
- {\preparenextFLOWchart{#1}{#2}%
- \setbuffer[\FLOWbufferprefix\nofFLOWcharts]#3\endbuffer}
-
-\def\preparenextFLOWchart#1#2%
- {\doglobal\increment\nofFLOWcharts
- \flowchart{#1}%
- \setxvalue{\@FLOW@-#1}{\noexpand\dohandleflowchart[\nofFLOWcharts][#2]}}
-
-\def\setupFLOWcharts{\dodoubleargument\getparameters[\@@FLOW]}
-\def\setupFLOWlines {\dodoubleargument\getparameters[\@@FLOL]}
-\def\setupFLOWshapes{\dodoubleargument\getparameters[\@@FLOS]}
-\def\setupFLOWfocus {\dodoubleargument\getparameters[\@@FLOF]}
-\def\setupFLOWsets {\dodoubleargument\getparameters[\@@FLOX]}
-
-\setupFLOWcharts
- [\c!option=,
- \c!bodyfont=,
- \c!dot=, % private option
- \c!width=12\bodyfontsize,
- \c!height=7\bodyfontsize,
- \c!maxwidth=,
- \c!maxheight=,
- \c!offset=\v!standard, % == auto offset
- \c!dx=2\bodyfontsize,
- \c!dy=2\bodyfontsize,
- \c!nx=0, % 1,
- \c!ny=0, % 1,
- \c!x=1,
- \c!y=1,
- \c!autofocus=,
- \c!focus=,
- \c!background=, % \v!color,
- \c!backgroundcolor=\s!white,
- \c!rulethickness=\linewidth,
- \c!frame=\v!off,
- \c!framecolor=]
-
-\setupFLOWlines
- [\c!corner=\v!round,
- \c!arrow=\v!yes,
- \c!dash=\v!no,
- \c!radius=.375\bodyfontsize, % 2.5\c!rulethickness
- \c!color=FLOWlinecolor,
- \c!rulethickness=.15\bodyfontsize, % 2pt,
- \c!offset=\v!none]
-
-\setupFLOWshapes
- [\c!default=action,
- \c!framecolor=FLOWframecolor,
- \c!background=\v!color,
- \c!backgroundcolor=FLOWbackgroundcolor,
- \c!backgroundscreen=\@@rsscreen,
- \c!rulethickness=.15\bodyfontsize, % 2pt,
- \c!offset=.5\bodyfontsize]
-
-\setupFLOWfocus
- [\c!framecolor=FLOWfocuscolor,
- \c!background=\@@FLOSbackground,
- \c!backgroundcolor=\@@FLOSbackgroundcolor,
- \c!backgroundscreen=\@@FLOSbackgroundscreen,
- \c!rulethickness=\@@FLOSrulethickness,
- \c!offset=\@@FLOSoffset]
-
-\definecolor [FLOWfocuscolor] [s=.2]
-\definecolor [FLOWlinecolor] [s=.5]
-\definecolor [FLOWframecolor] [s=.7]
-\definecolor [FLOWbackgroundcolor] [s=.9]
-
-\newcounter\includeFLOWx
-\newcounter\includeFLOWy
-
-\def\includeFLOWchart
- {\dodoubleempty\doincludeFLOWchart}
-
-\def\doincludeFLOWchart[#1][#2]%
- {\pushmacro\includeFLOWx
- \pushmacro\includeFLOWy
- \getparameters[FLOWi][x=1,y=1,#2]%
- \increment(\includeFLOWx,0\FLOWix)\decrement\includeFLOWx
- \increment(\includeFLOWy,0\FLOWiy)\decrement\includeFLOWy
- \def\dodoincludeFLOWchart##1%
- {\doifdefined{\@FLOW@-##1}
- {\globalpushmacro\dohandleflowchart % was local
- \gdef\dohandleflowchart[####1][####2]%
- {\globalpopmacro\dohandleflowchart % was local
- \resetFLOWlocation
- \processFLOWbuffer{####1}}%
- \getvalue{\@FLOW@-##1}}}%
- \processcommalist[#1]\dodoincludeFLOWchart
- \popmacro\includeFLOWx
- \popmacro\includeFLOWy}
-
-\def\resetFLOWlocation
- {\globallet\lastFLOWx\!!zerocount
- \globallet\lastFLOWy\!!zerocount}
-
-\def\dosetFLOWlocation[#1#2]#3#4%
- {\processaction
- [#1#2]
- [ +=>\scratchcounter\numexpr#4+ 1+#3\relax,
- -=>\scratchcounter\numexpr#4- 1+#3\relax,
- +#2=>\scratchcounter\numexpr#4+#2+#3\relax,
- -#2=>\scratchcounter\numexpr#4-#2+#3\relax,
- \s!default=>\scratchcounter\numexpr#4 +#3\relax,
- \s!unknown=>\scratchcounter\numexpr0#1#2+#3\relax]%
- \xdef#4{\the\scratchcounter}}
-
-\def\setFLOWlocation#1,#2\end
- {\dosetFLOWlocation[#1\empty]\includeFLOWx\lastFLOWx
- \dosetFLOWlocation[#2\empty]\includeFLOWy\lastFLOWy
- \xdef\FLOWlocation{\lastFLOWx,\lastFLOWy}}
-
-\def\FLOWshapes
- {node, action, procedure, product, decision, archive,
- loop, wait, subprocedure, singledocument, multidocument,
- sub procedure, single document, multi document, up, down,
- left, right}
-
-\def\FLOWlines
- {up, down, left, right}
-
-\def\FLOWsetconnect#1%
- {\donefalse
- \let\cFLOWfrom\empty
- \let\cFLOWto\empty
- \let\zFLOWfrom\!!zerocount
- \let\zFLOWto\!!zerocount
- \handletokens#1\with\doFLOWsetconnect
- \ifx\cFLOWto\empty\let\cFLOWfrom\empty\fi}
-
-\def\doFLOWsetconnect#1%
- {\ifx #1p%
- \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
- \else\ifx#1+%
- \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
- \else\ifx#1n%
- \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
- \else\ifx#1-%
- \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
- \else\ifdone
- \edef\cFLOWto{\FLOWconnector#1}%
- \else
- \edef\cFLOWfrom{\FLOWconnector#1}%
- \donetrue
- \fi\fi\fi\fi\fi}
-
-\def\FLOWconnector#1%
- {\if#1bbottom\else\if#1ttop\else\if#1lleft\else\if#1rright\fi\fi\fi\fi}
-
-\newif\ifFLOWscaling \FLOWscalingtrue
-
-\def\@@FLOW@@offset{\@@FLOWoffset}
-
-\def\getFLOWchart
- {\dodoubleempty\dogetFLOWchart}
-
-\def\dogetFLOWchart[#1][#2]%
- {\doifundefinedelse{\@FLOW@-#1}
- {\writestatus{FLOW}{unknown chart #1}%
- \framed
- [\c!width=12\bodyfontsize,\c!height=8\bodyfontsize]
- {\tttf [chart #1]}}
- {\dodogetFLOWchart[#1][#2]}}
-
-\def\dodogetFLOWchart[#1][#2]% to be split a bit more
- {\vbox\bgroup
- \insidefloattrue
- \forgetall
- \dontcomplain
- % \offinterlineskip % we now explicitly use \nointerlineskip later on
- \def\dohandleflowchart[##1][##2]%
- {\def\currentFLOWnumber{##1}%
- \getparameters[\@@FLOW][##2]}%
- \getvalue{\@FLOW@-#1}%
- \getparameters[\@@FLOW][#2]% dubbelop ?
- \doifsomething{\@@FLOWautofocus}
- {\checkFLOWautofocus}%
- %\message{AUTOSHAPE 3: (\@@FLOWx,\@@FLOWy)->(\@@FLOWnx,\@@FLOWny)}\wait
- \global\let\FLOWwidth \@@FLOWnx
- \global\let\FLOWheight\@@FLOWny
- \let\startFLOWcell\startFLOWcellA
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- \ifcase\@@FLOWnx\relax \let\@@FLOWnx\FLOWwidth \fi
- \ifcase\@@FLOWny\relax \let\@@FLOWny\FLOWheight \fi
- \doifnothing{\@@FLOWmaxwidth\@@FLOWmaxheight}{\FLOWscalingfalse}%
- \ifFLOWscaling
- \doifnothing{\@@FLOWmaxwidth }{\let\@@FLOWmaxwidth \maxdimen}%
- \doifnothing{\@@FLOWmaxheight}{\let\@@FLOWmaxheight\maxdimen}%
- \scratchcounter\bodyfontpoints
- \doloop % NOG FONTSWITCH OM EX EN EM TE LATEN WERKEN
- {\ifnum\scratchcounter>1 % NU DIMENSIONS IN TERMS OF BODYFONTSIZE
- \bodyfontsize=\the\scratchcounter pt
- \dimen0=\@@FLOWmaxwidth
- \dimen2=\@@FLOWwidth
- \dimen4=\@@FLOWdx
- \advance\dimen2 2\dimen4
- \dimen2=\@@FLOWnx\dimen2
- \advance\dimen2 2\dimen4
- \ifdim\dimen2>\dimen0
- \advance\scratchcounter \minusone
- \else
- \dimen0=\@@FLOWmaxheight
- \dimen2=\@@FLOWheight
- \dimen4=\@@FLOWdy
- \advance\dimen2 2\dimen4
- \dimen2=\@@FLOWny\dimen2
- \advance\dimen2 2\dimen4
- \ifdim\dimen2>\dimen0
- \advance\scratchcounter \minusone
- \else
- \exitloop
- \fi
- \fi
- \else
- \exitloop
- \fi}%
- \expanded{\switchtobodyfont[\the\scratchcounter pt]}%
- \forgetall
- % \offinterlineskip % needed ?
- \else\ifx\@@FLOWbodyfont\empty\else
- \expanded{\switchtobodyfont[\@@FLOWbodyfont]}% \expanded ?
- \fi\fi
- \global\let\FLOWcells\empty
- \dimen0=\@@FLOWwidth
- \edef\FLOWshapewidth{\the\dimen0}%
- \dimen2=\@@FLOWdx
- \advance\dimen0 2\dimen2
- \edef\FLOWgridwidth{\the\dimen0}%
- \dimen0=\@@FLOWheight
- \edef\FLOWshapeheight{\the\dimen0}%
- \dimen2=\@@FLOWdy
- \advance\dimen0 2\dimen2
- \edef\FLOWgridheight{\the\dimen0}%
- \scratchdimen=\@@FLOSrulethickness
- \edef\@@FLOSrulethickness{\the\scratchdimen}%
- \scratchdimen=\@@FLOFrulethickness
- \edef\@@FLOFrulethickness{\the\scratchdimen}%
- \scratchdimen=\@@FLOLrulethickness
- \edef\@@FLOLrulethickness{\the\scratchdimen}%
- \ifdim\@@FLOLradius<2.5\scratchdimen
- \scratchdimen=2.5\scratchdimen
- \edef\@@FLOLradius{\the\scratchdimen}%
- \ifdim\@@FLOLradius>\@@FLOWdx
- \scratchdimen=\@@FLOWdx
- \edef\@@FLOLradius{\the\scratchdimen}%
- \fi
- \ifdim\@@FLOLradius>\@@FLOWdy
- \scratchdimen=\@@FLOWdy
- \edef\@@FLOLradius{\the\scratchdimen}%
- \fi
- \else
- \scratchdimen=\@@FLOLradius
- \edef\@@FLOLradius{\the\scratchdimen}%
- \fi
- \processaction % magic 2.5
- [\@@FLOWoffset]
- [ \v!none=>\scratchdimen=-2.5\scratchdimen,
- \v!overlay=>\scratchdimen=-2.5\scratchdimen,
- \v!standard=>\scratchdimen=\scratchdimen,
- \s!unknown=>\scratchdimen=\@@FLOWoffset,
- \s!default=>\scratchdimen=-2.5\scratchdimen]%
- \edef\@@FLOW@@offset{\the\scratchdimen}%
- \forgetall
- \offinterlineskip
- \resetMPdrawing
- \doglobal\newcounter\FLOWcomment
- \startMPdrawing
- if unknown context_char : input mp-char.mp ; fi ;
- grid_width := \FLOWgridwidth ;
- grid_height := \FLOWgridheight ;
- shape_width := \FLOWshapewidth ;
- shape_height := \FLOWshapeheight ;
- connection_line_width := \@@FLOLrulethickness ;
- connection_smooth_size := \@@FLOLradius ;
- connection_arrow_size := \@@FLOLradius ;
- connection_dash_size := \@@FLOLradius ;
- currentpicture := nullpicture ;
- begin_chart(0,\FLOWwidth,\FLOWheight);
- reverse_y := true ;
- chart_offset := \@@FLOW@@offset ;
- \stopMPdrawing
- \doifelsenothing\@@FLOWbackgroundcolor
- {\startMPdrawing
- chart_background_color := white ;
- \stopMPdrawing}
- {\startMPdrawing
- chart_background_color := \MPcolor{\@@FLOWbackgroundcolor} ;
- \stopMPdrawing}%
- \doif\@@FLOWoption\v!test
- {\startMPdrawing
- show_con_points := true ;
- show_mid_points := true ;
- show_all_points := true ;
- \stopMPdrawing}%
- \processaction % private
- [\@@FLOWdot]
- [ \v!yes=>\startMPdrawing
- show_con_points := true ;
- show_mid_points := true ;
- show_all_points := true ;
- \stopMPdrawing,
- \s!unknown=>\startMPdrawing
- show_\@@FLOWdot _points := true ;
- \stopMPdrawing]%
-\doglobal\newcounter\FLOWcomment
- \let\startFLOWcell\startFLOWcellB
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
-\doglobal\newcounter\FLOWcomment
- \let\startFLOWcell\startFLOWcellC
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- \startMPdrawing
- clip_chart(\@@FLOWx,\@@FLOWy,\@@FLOWnx,\@@FLOWny) ;
- end_chart ;
- \stopMPdrawing
- \MPdrawingdonetrue
- \setbox0\hbox
- {\MPstaticgraphictrue
- \MPshiftdrawingfalse
- \getMPdrawing}%
- \def\MPmessage##1%
- {\writestatus{MP charts}{##1}}%
- \def\MPposition##1##2##3%
- {\setvalue{\@@MPx##1}{##2}\setvalue{\@@MPy##1}{##3}}%
- \def\MPclippath##1##2##3##4%
- {\def\clipMPllx{##1bp}\def\clipMPlly{##2bp}%
- \def\clipMPurx{##3bp}\def\clipMPury{##4bp}}%
- \def\MPareapath##1##2##3##4%
- {\def\areaMPllx{##1bp}\def\areaMPlly{##2bp}%
- \def\areaMPurx{##3bp}\def\areaMPury{##4bp}}%
- \getMPdata
- \doglobal\newcounter\FLOWcomment
- \let\startFLOWcell\startFLOWcellD
- \setbox2\vbox to \ht0
- {\forgetall % \offinterlineskip
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber\vss}%
- \setbox2\hbox
- {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box2}%
- \wd2\wd0\ht2\ht0\dp2\dp0
- \let\startFLOWcell\startFLOWcellE
- \setbox4\vbox to \ht0
- {\forgetall % \offinterlineskip
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber\vss}%
- \setbox4\hbox
- {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box4}%
- \wd4\wd0\ht4\ht0\dp4\dp0
- \doifelse\@@FLOWoption\v!test
- {\setbox6\vbox
- {\forgetall
- \vskip\@@FLOW@@offset
- \hskip\@@FLOW@@offset
- \basegrid
- [\c!x=\@@FLOWx,\c!nx=\@@FLOWnx,\c!dx=\withoutpt\FLOWgridwidth,
- \c!y=\@@FLOWy,\c!ny=\@@FLOWny,\c!dy=\withoutpt\FLOWgridheight,
- \c!xstep=1,\c!ystep=1,
- \c!unit=pt,\c!location=\v!middle]}%
- \wd6\wd0\ht6\ht0\dp6\dp0
- \setbox8\vbox
- {\forgetall
- \offinterlineskip
- \vskip\@@FLOW@@offset
- \dostepwiserecurse\@@FLOWy\@@FLOWny\plusone
- {\vbox to \FLOWgridheight
- {\vfill
- \hskip\@@FLOW@@offset
- \hbox
- {\dostepwiserecurse\@@FLOWx\@@FLOWnx\plusone
- {\hbox to \FLOWgridwidth
- {\hfill
- \framed
- [\c!framecolor=red,
- \c!width=\FLOWshapewidth,
- \c!height=\FLOWshapeheight]
- {}%
- \hfill}}}
- \vfill}}}%
- \wd8\wd0\ht8\ht0\dp8\dp0
- \framed
- [\c!offset=\v!overlay,\c!framecolor=green]
- {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2\hskip-\wd6\box6\hskip-\wd8\box8}}}
- {\framed
- [\c!offset=\v!overlay,
- \c!frame=\@@FLOWframe,
- \c!rulethickness=\@@FLOWrulethickness,
- \c!framecolor=\@@FLOWframecolor,
- \c!background=\@@FLOWbackground,
- \c!backgroundcolor=\@@FLOWbackgroundcolor]
- {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2}}}%
- %\message{[\FLOWcells]}\wait
- \egroup}
-
-% Pass A
-
-\long\def\startFLOWcellA#1\stopFLOWcell%
- {\resetFLOWcell
- \ignorespaces#1\unskip
- \expandafter\getFLOWlocationA\FLOWlocation\end
- \ignorespaces}
-
-\def\getFLOWlocationA#1,#2\end
- {\ifnum0#1>\FLOWwidth \xdef\FLOWwidth {#1}\fi
- \ifnum0#2>\FLOWheight\xdef\FLOWheight{#2}\fi}
-
-% Pass B
-%
-% beware: the - after \@FLOC@ is needed since name can be
-% empty and we don't want to redefine \@FLOC@ itself by
-% mistake
-
-\long\def\startFLOWcellB#1\stopFLOWcell
- {\resetFLOWcell\ignorespaces#1\unskip
- \setxvalue{\@FLOC@-\FLOWname}{\FLOWlocation}% kost veel cs's
- \ifx\FLOWshape\empty
- \global\let\FLOWshape\@@FLOSdefault
- \fi
- \doifnot\FLOWshape{none} % {\v!none}
- {\doifinsetelse\FLOWshape\FLOWshapes
- {\edef\FLOWshapetag{shape_ \FLOWshape}% beter \expanded
- \@EA\setFLOWname\@EA\FLOWshapetag\@EA{\FLOWshapetag}}
- {\doifnumberelse\FLOWshape
- {\let\FLOWshapetag\FLOWshape}
- {\let\FLOWshapetag\empty}}%
- \ifx\FLOWshapetag\empty \else
- \doifinsetelse\FLOWshape\FLOWlines
- {\chardef\FLOWstate0 }
- {\doifcommonelse{\FLOWcell,\FLOWfocus}\@@FLOWfocus
- {\chardef\FLOWstate1 }
- {\chardef\FLOWstate2 }}%
- \startMPdrawing
- begin_sub_chart ;
- \ifcase\FLOWstate
- shape_line_color := \MPcolor{\@@FLOLcolor} ;
- shape_fill_color := \MPcolor{\@@FLOLcolor} ;
- shape_line_width := \@@FLOLrulethickness ;
- \or
- shape_line_color := \MPcolor{\@@FLOFframecolor} ;
- shape_fill_color := \MPcolor{\@@FLOFbackgroundcolor} ;
- shape_line_width := \@@FLOFrulethickness ;
- \or
- shape_line_color := \MPcolor{\@@FLOSframecolor} ;
- shape_fill_color := \MPcolor{\@@FLOSbackgroundcolor} ;
- shape_line_width := \@@FLOSrulethickness ;
- \fi
- %\ifx\FLOWoverlay\empty
- % peepshape := false ;
- %\else
- % peepshape := true ;
- %\fi
- peepshape := \ifx\FLOWoverlay\empty false \else true \fi ;
- new_shape(\FLOWlocation,\FLOWshapetag) ;
- end_sub_chart ;
- \stopMPdrawing
- \fi}%
- \ignorespaces}
-
-% Pass C
-
-\long\def\startFLOWcellC#1\stopFLOWcell%
- {\resetFLOWcell
-\pushmacro\lastFLOWx
-\pushmacro\lastFLOWy
- \ignorespaces#1\unskip % makes sure that vars are set
-\popmacro\lastFLOWy
-\popmacro\lastFLOWx
- \let\connection\doFLOWconnectionC
- \ignorespaces#1\unskip}
-
-\def\FLOWorigin{0,0}
-
-\def\doFLOWdisplace[#1,#2,#3]% experiment
- {dsp_x := #1 ; dsp_y := #2 ;}
-
-\def\doFLOWconnectionC
- {\dodoubleempty\dodoFLOWconnectionC}
-
-\def\dodoFLOWconnectionC[#1][#2]#3%
- {\doglobal\increment\FLOWcomment
- \setFLOWname\otherFLOWname{name_#3}%
- \doifdefinedelse{\@FLOC@-\FLOWname}
- {\edef\FLOWfrom{\getvalue{\@FLOC@-\FLOWname}}}
- {\let \FLOWfrom \FLOWorigin}%
- \ifx\FLOWfrom\FLOWorigin \else
- \doifdefinedelse{\@FLOC@-\otherFLOWname}
- {\edef\FLOWto {\getvalue{\@FLOC@-\otherFLOWname}}}
- {\let \FLOWto \FLOWorigin}%
- \ifx\FLOWto\FLOWorigin \else
- \FLOWsetconnect{#1}%
- \ifx\cFLOWfrom\empty \else
- \doifelse\@@FLOLcorner\v!round
- {\startMPdrawing smooth := true ; \stopMPdrawing}
- {\startMPdrawing smooth := false ; \stopMPdrawing}%
- \doifelse\@@FLOLdash\v!yes
- {\startMPdrawing dashline := true ; \stopMPdrawing}
- {\startMPdrawing dashline := false ; \stopMPdrawing}%
- \doifelse\@@FLOLarrow\v!yes
- {\startMPdrawing arrowtip := true ; \stopMPdrawing}
- {\startMPdrawing arrowtip := false ; \stopMPdrawing}%
- \doifelse\@@FLOLoffset\v!none
- {\startMPdrawing touchshape := true ; \stopMPdrawing}
- {\startMPdrawing touchshape := false ; \stopMPdrawing}%
-%\doifsomething{#2}
-% {\startMPdrawing
-% \doFLOWdisplace[0#2,0,0]%
-% \stopMPdrawing}%
- \startMPdrawing
-\doFLOWdisplace[0#2,0,0]%
- connection_line_color := \MPcolor{\@@FLOLcolor} ;
- connection_line_width := \@@FLOLrulethickness ;
- connect_\cFLOWfrom _\cFLOWto (\FLOWfrom,\zFLOWfrom) (\FLOWto,\zFLOWto) ;
-\doFLOWdisplace[0,0,0]%
- \stopMPdrawing
- \fi
- \fi
- \fi
- \ignorespaces}
-
-% Pass D
-
-\long\def\startFLOWcellD#1\stopFLOWcell
- {\resetFLOWcell
-\pushmacro\lastFLOWx
-\pushmacro\lastFLOWy
- \ignorespaces#1\unskip % presets vars
-\popmacro\lastFLOWy
-\popmacro\lastFLOWx
- \let\doprocessFLOWcell\doprocessFLOWcellD
- \expandafter\doprocessFLOWcellD\FLOWlocation\end
- \let\connection\doFLOWconnectionD
- \let\comment\doFLOWcommentD
- \ignorespaces#1\unskip\ignorespaces}
-
-\def\doFLOWconnectionD
- {\dodoubleempty\dodoFLOWconnectionD}
-
-\def\dodoFLOWconnectionD[#1][#2]#3%
- {\doglobal\increment\FLOWcomment
- \ignorespaces}
-
-\def\doFLOWcommentD[#1]#2%
- {\bgroup
- \let\FLOW \middlebox
- \let\FLOWb \bottombox
- \let\FLOWbl\bottomleftbox
- \let\FLOWbr\bottomrightbox
- \let\FLOWt \topbox
- \let\FLOWtl\topleftbox
- \let\FLOWtr\toprightbox
- \let\FLOWl \leftbox
- \let\FLOWlt\lefttopbox
- \let\FLOWlb\leftbottombox
- \let\FLOWr \rightbox
- \let\FLOWrt\righttopbox
- \let\FLOWrb\rightbottombox
- \let\FLOWc \middlebox
-%\ifdefined{FLOW#1}%
- \ifcase0\getvalue{\@@MPx\FLOWcomment}\getvalue{\@@MPy\FLOWcomment}\relax
- \else
- \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp<\areaMPllx\relax\else
- \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp>\areaMPurx\relax\else
- \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp<\areaMPlly\relax\else
- \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp>\areaMPury\relax\else
- \dimen0=\getvalue{\@@MPx\FLOWcomment}\s!bp
- \advance\dimen0 -\@@FLOW@@offset
- \advance\dimen0 -\clipMPllx
- \dimen2=\clipMPury
- \advance\dimen2 -\@@FLOW@@offset
- \advance\dimen2 -\getvalue{\@@MPy\FLOWcomment}\s!bp
- \setbox\scratchbox\hbox{\strut#2}%
- \boxoffset.5\bodyfontsize
- \setbox\scratchbox\hbox{\hskip\dimen0\lower\dimen2\getvalue{FLOW#1}{\box\scratchbox}}%
- \smashbox\scratchbox
- \box\scratchbox
- \boxoffset\zeropoint
- \nointerlineskip % really needed
- \fi
- \fi
- \fi
- \fi
- \fi
-%\fi
- \egroup
- \ignorespaces}
-
-% pass D
-
-\def\dophaseoneFLOWcellX#1#2%
- {\!!counta#1\relax
- \!!countb#2\relax
- \!!countc\@@FLOWx
- \!!countd\@@FLOWy
- \advance\!!countc \@@FLOWnx
- \advance\!!countd \@@FLOWny
- \advance\!!countc \minusone
- \advance\!!countd \minusone
- \ifnum\!!counta<\@@FLOWx\relax \donefalse
- \else\ifnum\!!counta>\!!countc \donefalse
- \else\ifnum\!!countb<\@@FLOWy\relax \donefalse
- \else\ifnum\!!countb>\!!countd \donefalse
- \else \donetrue
- \fi\fi\fi\fi}
-
-\def\dophasetwoFLOWcellX
- {\advance\!!counta -\@@FLOWx
- \advance\!!counta \plusone
- \advance\!!countb -\@@FLOWy
- \advance\!!countb \plusone
- \dimen0=\FLOWgridwidth
- \dimen0=\!!counta\dimen0
- \advance\dimen0 -\FLOWgridwidth
- \dimen4=\FLOWgridwidth
- \advance\dimen4 -\FLOWshapewidth
- \advance\dimen0 .5\dimen4
- \dimen2=\FLOWgridheight
- \dimen2=\!!countb\dimen2
- \dimen4=\FLOWgridheight
- \advance\dimen4 -\FLOWshapeheight
- \advance\dimen2 -.5\dimen4
- \edef\FLOWdx{\the\dimen0}%
- \edef\FLOWdy{\the\dimen2}}
-
-\def\positionFLOWzero% assumes \FLOWdx and \FLOWdy are set
- {\setbox0\hbox{\hskip\FLOWdx\lower\FLOWdy\box0}%
- \smashbox0\box0
- \nointerlineskip} % new, needed since we somehow reset that
-
-\def\doFLOWtlabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
- \setbox0\hbox{\hskip\dimen2\raise\scratchdimen
- \hbox{\raise\dimen4\hbox{#1{\strut#3}}}}%
- \positionFLOWzero}%
-
-\def\doFLOWblabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
- \setbox0\hbox{\hskip\dimen2\raise-\scratchdimen
- \hbox{#1{\strut#3}}}%
- \positionFLOWzero}%
-
-\def\doFLOWllabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
- \setbox0\hbox{\hskip-\scratchdimen\raise\dimen6
- \hbox{#1{\strut#3}}}%
- \positionFLOWzero}%
-
-\def\doFLOWrlabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
- \setbox0\hbox{\hskip\dimen0\hskip\scratchdimen
- \hbox{\raise\dimen6\hbox{#1{\strut#3}}}}%
- \positionFLOWzero}
-
-\def\doprocessFLOWcellD#1,#2\end
- {\dophaseoneFLOWcellX{#1}{#2}%
- \ifdone
- \dophasetwoFLOWcellX
- \doglobal\addtocommalist\FLOWcell\FLOWcells
- \def\FLOWx{#1}%
- \def\FLOWy{#2}%
- \directsetup{flowcell}%
- \setbox0\hbox
- {\ifx\FLOWalign\empty\else
- \setupframed
- [\c!align=\v!normal,\c!bottom=\vfill,\c!top=\vfill]%
- \@EA\processallactionsinset\@EA
- [\FLOWalign]
- [t=>{\setupframed[\c!bottom=\vfill,\c!top=]},
- b=>{\setupframed[\c!bottom=,\c!top=\vfill]},
- l=>{\setupframed[\c!align=\v!right]},
- r=>{\setupframed[\c!align=\v!left]},
- m=>{\setupframed[\c!align=\v!middle]},
- c=>{\setupframed[\c!align=\v!middle]}]%
- \fi
- \doifelse\FLOWshape{none} % {\v!none}
- {\setupframed[\c!offset=\v!overlay]}
- {\setupframed[\c!offset=\@@FLOSoffset]}%
- \framed
- [\c!frame=\v!off,\c!background=flowcell,
- \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
- {\FLOWtext}}%
- \showFLOWhelp0
- \ifx\FLOWdestination\empty\else
- \setbox0\hbox
- {\setupinteraction[\c!color=,\c!contrastcolor=]%
- \gotobox{\box0}[\FLOWdestination]}%
- \fi
- \positionFLOWzero
- \dimen0=\FLOWshapewidth \dimen2=.5\dimen0
- \dimen4=\FLOWshapeheight\dimen6=.5\dimen4
- \boxoffset.5\bodyfontsize
- \doFLOWtlabel \righttopbox0\tFLOWlabel
- \doFLOWblabel\rightbottombox0\bFLOWlabel
- \doFLOWllabel \lefttopbox0\lFLOWlabel
- \doFLOWrlabel \righttopbox0\rFLOWlabel
- \doFLOWtlabel \topbox0\tcFLOWlabel % for me only
- \doFLOWblabel \bottombox0\bcFLOWlabel % for me only
- \doFLOWllabel \leftbox0\lcFLOWlabel % for me only
- \doFLOWrlabel \rightbox0\rcFLOWlabel % for me only
- \ifnum#1=\@@FLOWx\relax \doFLOWllabel \leftbox1\lFLOWexit \fi
- \ifnum#1=\!!countc \doFLOWrlabel \rightbox1\rFLOWexit \fi
- \ifnum#2=\@@FLOWy\relax \doFLOWtlabel \topbox1\tFLOWexit \fi
- \ifnum#2=\!!countd \doFLOWblabel \bottombox1\bFLOWexit \fi
- \boxoffset\zeropoint
- \fi}
-
-% For Willy Egger:
-%
-% \startsetups flowcell
-% \definelayer
-% [flowcell]
-% [width=\FLOWshapewidth,
-% height=\FLOWshapeheight]
-% \setlayerframed
-% [flowcell]
-% [preset=rightbottom,offset=1ex]
-% [frame=off]
-% {\tx(\FLOWx,\FLOWy)}
-% \stopsetups
-
-% Pass E
-
-\long\def\startFLOWcellE#1\stopFLOWcell
- {\resetFLOWcell
- \ignorespaces#1\unskip
- \let\doprocessFLOWcell\doprocessFLOWcellE
- \expandafter\doprocessFLOWcell\FLOWlocation\end}
-
-\def\doprocessFLOWcellE#1,#2\end % redundant
- {\ifx\FLOWoverlay\empty \else
- \dophaseoneFLOWcellX{#1}{#2}%
- \ifdone
- \dophasetwoFLOWcellX
- \edef\FLOWdx{\the\dimen0}%
- \edef\FLOWdy{\the\dimen2}%
- \setbox0\hbox
- {\framed
- [%\c!frame=\v!off,
- \c!background={\@@FLOWbackground,\FLOWoverlay},
- \c!backgroundcolor=\@@FLOSbackgroundcolor,
- \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
- {}}%
- \positionFLOWzero
- \fi
- \fi}
-
-% Pass F
-
-\def\checkFLOWautofocus
- {\def\@@FLOWminx{100}\let\@@FLOWminy\@@FLOWminx
- \def\@@FLOWmaxx {0}\let\@@FLOWmaxy\@@FLOWmaxx
- \def\@@FLOWabsx {0}\let\@@FLOWabsy\@@FLOWabsx
- \let\startFLOWcell\startFLOWcellF
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- %\message{AUTOSHAPE 1: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
- \ifnum\@@FLOWabsx<\@@FLOWmaxx\let\@@FLOWmaxx\@@FLOWabsx\fi
- \ifnum\@@FLOWabsy<\@@FLOWmaxy\let\@@FLOWmaxy\@@FLOWabsy\fi
- %\message{AUTOSHAPE 2: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
- \donetrue
- \ifnum\@@FLOWminx=100 \donefalse\fi
- \ifnum\@@FLOWminy=100 \donefalse\fi
- \ifnum\@@FLOWmaxx=0 \donefalse\fi
- \ifnum\@@FLOWmaxy=0 \donefalse\fi
- \doFLOWcheckF\@@FLOWx\@@FLOWminx\@@FLOWmaxx\@@FLOWnx
- \doFLOWcheckF\@@FLOWy\@@FLOWminy\@@FLOWmaxy\@@FLOWny}
-
-\def\startFLOWcellF#1\stopFLOWcell%
- {\resetFLOWcell
- \ignorespaces#1\unskip
- \expandafter\doFLOWlocationF\FLOWlocation\end}%
-
-\def\doFLOWlocationF#1,#2\end%
- {\ifnum#1>\@@FLOWabsx\def\@@FLOWabsx{#1}\fi
- \ifnum#2>\@@FLOWabsy\def\@@FLOWabsy{#2}\fi
- \doifinset\FLOWcell\@@FLOWautofocus
- {\dodoFLOWlocationF{#1}<-\@@FLOWminx
- \dodoFLOWlocationF{#1}>+\@@FLOWmaxx
- \dodoFLOWlocationF{#2}<-\@@FLOWminy
- \dodoFLOWlocationF{#2}>+\@@FLOWmaxy}}
-
-\def\dodoFLOWlocationF#1#2#3#4%
- {\ifnum#1#2#4\relax
- \!!counta=#1\advance\!!counta #31\relax
- \edef#4{\ifnum\!!counta<1 1\else\the\!!counta\fi}%
- \fi}
-
-\def\doFLOWcheckF#1#2#3#4%
- {\ifdone
- \let#1=#2%
- \!!counta=#3%
- \advance\!!counta \plusone\advance\!!counta -#2\relax
- \ifnum\!!counta<1 \!!counta=1 \fi
- \edef#4{\the\!!counta}%
- \else
- \let#1\!!plusone
- \let#4\!!zerocount % no {1}
- \fi}
-
-% \useFLOWchart[name][parent][setting,setting][additional settings]
-% \useFLOWchart[name][parent][additional settings]
-
-\let\currentFLOWchart\empty
-
-\def\useFLOWchart
- {\doquadrupleempty\douseFLOWchart}
-
-\def\douseFLOWchart[#1][#2][#3][#4]% name parent sets mainsettings
- {\iffourthargument
- \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][#4,##1]}%
- \else
- \checkparameters[#3]%
- \ifparameters
- \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][][#3,##1]}%
- \else
- \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][##1]}%
- \fi
- \fi}
-
-\def\setgetFLOWchart[#1][#2][#3]%
- {\def\docommand##1{}% cell line focus ?
- \processcommalist[#2]\docommand
- \getFLOWchart[#1][#3]}
-
-\def\doFLOWchart[#1][#2]%
- {\hbox\bgroup\vbox\bgroup % vmode suppresses spaces
-\def\currentFLOWchart{#1}%
- \doifundefinedelse{\@FLOW@--#1}
- {\getFLOWchart[#1][#2]}
- {\getvalue{\@FLOW@--#1}[#2]}%
- \egroup\egroup}
-
-\def\FLOWchart%
- {\dodoubleempty\doFLOWchart}
-
-%D A hook into the help system.
-
-% \def\showFLOWhelp#1%
-% {\doifhelpinfo\FLOWhelp
-% {\setbox#1=\hbox
-% {\setbox\scratchbox=\hbox{\lower\@@FLOWdy\hbox
-% {\helpbutton
-% [\c!width=\wd0,\c!color=,\c!height=\@@FLOWdy,\c!frame=\v!no]%
-% [\FLOWhelp]}}%
-% \smashbox\scratchbox
-% \setbox#1=\vbox
-% {\forgetall\offinterlineskip\box#1\box\scratchbox}%
-% \box#1}}}
-
-\def\showFLOWhelp#1%
- {}
-
-%D The next section is dedicated to splitting up charts.
-
-\def\getFLOWsize[#1]%
- {\bgroup\let\dodogetFLOWchart\dogetFLOWsize\FLOWchart[#1]\egroup}
-
-\def\dogetFLOWsize[#1][#2]%
- {\setbox\scratchbox=\vbox
- {\globallet\FLOWmaxwidth \!!zerocount
- \globallet\FLOWmaxheight\!!zerocount
- \def\getFLOWlocation##1,##2\end
- {\ifnum0##1>\FLOWmaxwidth \xdef\FLOWmaxwidth {##1}\fi
- \ifnum0##2>\FLOWmaxheight\xdef\FLOWmaxheight{##2}\fi}%
- \resetFLOWcell
- \long\def\startFLOWcell##1\stopFLOWcell
- {{##1\expandafter\getFLOWlocation\FLOWlocation\end}}%
- \def\dohandleflowchart[##1][##2]%
- {\resetFLOWlocation
- \processFLOWbuffer{##1}}%
- \getvalue{\@FLOW@-#1}}}
-
-\def\setupFLOWsplit%
- {\dodoubleargument\getparameters[\@@FLOT]}
-
-\setupFLOWsplit%
- [\c!nx=3,\c!ny=3,
- \c!dx=1,\c!dy=1,
- \c!command=,
- \c!marking=\v!on,
- \c!before=,\c!after=]
-
-\def\FLOWsplitx {1}
-\def\FLOWsplity {1}
-\def\FLOWsplitnx{1}
-\def\FLOWsplitny{1}
-
-\def\FLOWcharts%
- {\dodoubleempty\doFLOWcharts}
-
-%D While splitting, the following variables are available:
-%D
-%D \starttyping
-%D \FLOWsplitnx \FLOWsplitny \FLOWsplitx \FLOWsplity
-%D \stoptyping
-
-\def\doFLOWcharts[#1][#2]%
- {\bgroup
- \getFLOWsize[#1]%
- \dodoFLOWcharts\relax
- \global\let\FLOWsplitnx\FLOWsplitx
- \global\let\FLOWsplitny\FLOWsplity
- \dodoFLOWcharts{\dododoFLOWcharts[#1][#2]}%
- \egroup}
-
-\def\dodoFLOWcharts#1%
- {\def\@@FLOTx{1}%
- \global\let\FLOWsplitx\@@FLOTx
- \doloop
- {\def\@@FLOTy{1}%
- \global\let\FLOWsplity\@@FLOTy
- \doloop
- {\bgroup
- \scratchcounter\FLOWmaxwidth
- \advance\scratchcounter -\@@FLOTx
- \advance\scratchcounter \plusone
- \ifnum\scratchcounter<\@@FLOTnx\edef\@@FLOTnx{\the\scratchcounter}\fi
- \scratchcounter\FLOWmaxheight
- \advance\scratchcounter -\@@FLOTy
- \advance\scratchcounter \plusone
- \ifnum\scratchcounter<\@@FLOTny\edef\@@FLOTny{\the\scratchcounter}\fi
- #1% does something with the float, or not
- \egroup
- \increment(\@@FLOTy,\@@FLOTny)%
- \ifnum\@@FLOTy>\FLOWmaxheight
- \exitloop
- \else
- \doglobal\increment\FLOWsplity
- \decrement(\@@FLOTy,\@@FLOTdy)%
- \fi}%
- \increment(\@@FLOTx,\@@FLOTnx)%
- \ifnum\@@FLOTx>\FLOWmaxwidth
- \exitloop
- \else
- \doglobal\increment\FLOWsplitx
- \decrement(\@@FLOTx,\@@FLOTdx)%
- \fi}}
-
-\def\dododoFLOWcharts[#1][#2]%
- {\bgroup
- \@@FLOTbefore
- \doifnot\@@FLOTmarking\v!on{\let\cuthbox\hbox}%
- \cuthbox
- {\@@FLOTcommand
- {\FLOWchart[#1][#2,
- \c!x=\@@FLOTx,\c!nx=\@@FLOTnx,
- \c!y=\@@FLOTy,\c!ny=\@@FLOTny]}}%
- \@@FLOTafter
- \egroup}
-
-%D An example of splitting is given below:
-%D
-%D \starttyping
-%D \setupFLOWsplit
-%D [nx=5,ny=10,
-%D dx=0,dy=0,
-%D before=,
-%D after=\page]
-%D
-%D \FLOWcharts[mybigflow]
-%D \stoptyping
-%D
-%D Or, one can say:
-%D
-%D \starttyping
-%D \splitfloat
-%D {\placefigure{What a big flowchart this is!}}
-%D {\FLOWcharts[mybigflow]}
-%D \stoptyping
-
-%D \macros
-%D {typeFLOWchart}
-%D
-%D For documentation purposes the following macro is
-%D provided. Watch the use of the first and last line hooks,
-%D which is needed because the start and stop commands are
-%D not part of the buffer.
-
-\def\typeFLOWchart[#1]%
- {\bgroup
- \def\dohandleflowchart[##1][##2]{\typeFLOWbuffer{##1}}%
- \defconvertedargument\firstverbatimfileline{\startFLOWchart[#1]}%
- \defconvertedargument\lastverbatimfileline {\stopFLOWchart}%
- \getvalue{\@FLOW@-#1}
- \egroup}
-
-%D New:
-%D
-%D \starttyping
-%D \setupFLOWcharts[command=\Whow]
-%D
-%D \startFLOWset[convert-en] % [tag][convert-en]
-%D \subFLOWchart[a][x=1,y=1,nx=3,ny=3]
-%D \subFLOWchart[b][x=1,y=2,nx=3,ny=3]
-%D \subFLOWchart[c][x=2,y=1,nx=3,ny=3]
-%D \stopFLOWset
-%D
-%D \def\Whow#1%
-%D {\ifnum\currentFLOWset=1 \framed{Some Chart}\fi}
-%D
-%D \FLOWset[convert-en] % [tag]
-%D
-%D \def\Whow#1%
-%D {\setuphead[state=high]
-%D \startstandardmakeup
-%D \centerbox{#1}
-%D \stopstandardmakeup}
-%D
-%D \FLOWset[convert-en] % [tag]
-%D \stoptyping
-
-\def\startFLOWset
- {\dodoubleempty\dostartFLOWset}
-
-\def\dostartFLOWset[#1][#2]#3\stopFLOWset % tag name data
- {\ifsecondargument
- \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#2}{#3}}%
- \else
- \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#1}{#3}}%
- \fi}
-
-\long\def\dohandleFLOWset#1#2#3% tag name data
- {\bgroup
- \def\subFLOWchart
- {\dodoubleempty\dosubFLOWchart}%
- \def\dosubFLOWchart[##1][##2]% subtag settings
- {\ifsecondargument
- \dodohandleFLOWset{#1}{##1}{#2}{##2}%
- \else
- \subFLOWchart[][##1]%
- \fi}%
- #3%
- \egroup}
-
-\def\dodohandleFLOWset#1#2#3#4% tag subtag name settings
- {\increment\currentFLOWset
- \bgroup
- \@@FLOXcommand
- {\ifnum\currentFLOWset=1 \pagereference[#1]\fi
- \doifsomething{#2}
- {\setupreferencing[\c!prefix=]%
- \pagereference[#1:#2]% -:#1:#2
- \setupreferencing[\c!prefix=#1:#2]}%
- \FLOWchart[#3][#4]}%
- \egroup}
-
-\def\FLOWset[#1]%
- {\newcounter\currentFLOWset
- \doifdefinedelse{\@FLOX@#1}
- {\getvalue{\@FLOX@#1}}
- {\dodohandleFLOWset{#1}{}{#1}{}}}
-
-\newcounter\currentFLOWset
-
-\setupFLOWsets
- [\c!command=]
-
-%D This will be an option:
-
-% \def\startFLOWchart%
-% {\dodoubleempty\dostartFLOWchart}
-%
-% \long\def\dostartFLOWchart[#1][#2]#3\stopFLOWchart
-% {\preparenextFLOWchart{#1}{#2}%
-% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
-%
-% \long\def\dodefineFLOWchart[#1][#2]#3%
-% {\preparenextFLOWchart{#1}{#2}%
-% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
-%
-% \def\processFLOWbuffer#1{\getvalue{\FLOWbufferprefix#1}}
-% \def\typeFLOWbuffer #1{[Sorry, no verbatim chart #1 available.]}
% todo: \localpushmacro/\localpopmacro (dohandleflowchart etc)
% todo: make mkiv variant
% todo: use dimexpr/numspr
@@ -1762,9 +490,9 @@
connection_smooth_size := \@@FLOLradius ;
connection_arrow_size := \@@FLOLradius ;
connection_dash_size := \@@FLOLradius ;
- currentpicture := nullpicture ;
+ currentpicture := nullpicture ;
begin_chart(0,\FLOWwidth,\FLOWheight);
- reverse_y := true ;
+ reverse_y := true ;
chart_offset := \@@FLOW@@offset ;
\stopMPdrawing
\doifelsenothing\@@FLOWbackgroundcolor
@@ -1790,11 +518,11 @@
\s!unknown=>\startMPdrawing
show_\@@FLOWdot _points := true ;
\stopMPdrawing]%
-\doglobal\newcounter\FLOWcomment
+ \doglobal\newcounter\FLOWcomment
\let\startFLOWcell\startFLOWcellB
\resetFLOWlocation
\processFLOWbuffer\currentFLOWnumber
-\doglobal\newcounter\FLOWcomment
+ \doglobal\newcounter\FLOWcomment
\let\startFLOWcell\startFLOWcellC
\resetFLOWlocation
\processFLOWbuffer\currentFLOWnumber
@@ -2009,11 +737,11 @@
\long\def\startFLOWcellD#1\stopFLOWcell
{\resetFLOWcell
-\pushmacro\lastFLOWx
-\pushmacro\lastFLOWy
+ \pushmacro\lastFLOWx
+ \pushmacro\lastFLOWy
\ignorespaces#1\unskip % presets vars
-\popmacro\lastFLOWy
-\popmacro\lastFLOWx
+ \popmacro\lastFLOWy
+ \popmacro\lastFLOWx
\let\doprocessFLOWcell\doprocessFLOWcellD
\expandafter\doprocessFLOWcellD\FLOWlocation\end
\let\connection\doFLOWconnectionD
@@ -2166,7 +894,7 @@
[\c!frame=\v!off,\c!background=flowcell,
\c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
{\FLOWtext}}%
- \showFLOWhelp0
+ %\showFLOWhelp0
\ifx\FLOWdestination\empty\else
\setbox0\hbox
{\setupinteraction[\c!color=,\c!contrastcolor=]%
@@ -2184,10 +912,10 @@
\doFLOWblabel \bottombox0\bcFLOWlabel % for me only
\doFLOWllabel \leftbox0\lcFLOWlabel % for me only
\doFLOWrlabel \rightbox0\rcFLOWlabel % for me only
- \ifnum#1=\@@FLOWx\relax \doFLOWllabel \leftbox1\lFLOWexit \fi
- \ifnum#1=\!!countc \doFLOWrlabel \rightbox1\rFLOWexit \fi
- \ifnum#2=\@@FLOWy\relax \doFLOWtlabel \topbox1\tFLOWexit \fi
- \ifnum#2=\!!countd \doFLOWblabel \bottombox1\bFLOWexit \fi
+ \relax\ifnum#1=\@@FLOWx \relax \doFLOWllabel \leftbox1\lFLOWexit \fi
+ \relax\ifnum#1=\!!countc\relax \doFLOWrlabel \rightbox1\rFLOWexit \fi
+ \relax\ifnum#2=\@@FLOWy \relax \doFLOWtlabel \topbox1\tFLOWexit \fi
+ \relax\ifnum#2=\!!countd\relax \doFLOWblabel\bottombox1\bFLOWexit \fi
\boxoffset\zeropoint
\fi}
@@ -2340,10 +1068,10 @@
\processFLOWbuffer{##1}}%
\getvalue{\@FLOW@-#1}}}
-\def\setupFLOWsplit%
+\def\setupFLOWsplit
{\dodoubleargument\getparameters[\@@FLOT]}
-\setupFLOWsplit%
+\setupFLOWsplit
[\c!nx=3,\c!ny=3,
\c!dx=1,\c!dy=1,
\c!command=,
@@ -2543,4 +1271,58 @@
\writestatus\m!system{The chart mkiv xml interface is not yet defined!}
-\protect \endinput
+\protect
+
+\continueifinputfile{m-chart.mkiv}
+
+\input chrt-xml.tex
+
+\usemodule[abr-01]
+
+% \setupFLOWcharts[option=test]
+\setupinteraction[state=start]
+% \setupFLOWcharts[dx=30pt,dy=30pt]
+
+\startFLOWchart[demo]
+ \startFLOWcell
+ \name {one}
+% \destination{CloseDocument}
+ \location {2,2}
+% \shape {action}
+% \text {first}
+% \label [b] {\bfx bottom}
+% \exit [l] {exit l}
+% \exit [r] {exit r}
+% \exit [t] {exit t}
+% \exit [b] {exit b}
+\comment[t]{comment t}
+\comment[b]{comment t}
+ \connection [rt] {two}
+ \stopFLOWcell
+ \startFLOWcell
+ \name {two}
+ \destination{CloseDocument}
+ \location {3,3}
+ \shape {action}
+ \text {second}
+ \figure {cow.pdf}
+% \label [l] {\bfx left}
+ \stopFLOWcell
+\stopFLOWchart
+
+\starttext
+
+\startTEXpage
+% \FLOWchart[convert-en]
+% \FLOWchart[conversion 1]
+% \FLOWchart[conversion 7]
+% \FLOWchart[conversion 9]
+% \FLOWchart[conversion 10]
+ \FLOWchart[demo]
+\stopTEXpage
+
+\startTEXpage
+ \FLOWchart[conversion 10]
+\stopTEXpage
+
+\stoptext
diff --git a/tex/context/base/m-chart.tex b/tex/context/base/m-chart.tex
deleted file mode 100644
index 9f36004f5..000000000
--- a/tex/context/base/m-chart.tex
+++ /dev/null
@@ -1,18 +0,0 @@
-%D \module
-%D [ file=m-chart,
-%D version=1998.10.10,
-%D title=\CONTEXT\ Modules,
-%D subtitle=Flow Charts,
-%D author={Hans Hagen \& Ton Otten},
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D This file will become obsolete.
-
-\loadmarkfile{m-chart}
-
-\protect \endinput
diff --git a/tex/context/base/m-flow.lua b/tex/context/base/m-flow.lua
new file mode 100644
index 000000000..ea04eef17
--- /dev/null
+++ b/tex/context/base/m-flow.lua
@@ -0,0 +1,631 @@
+if not modules then modules = { } end modules ['x-flow'] = {
+ version = 1.001,
+ comment = "companion to m-flow.mkvi",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- when we can resolve mpcolor at the lua end we will use metapost.graphic(....) directly
+
+moduledata.charts = moduledata.charts or { }
+
+local gsub, match, find, format, lower = string.gsub, string.match, string.find, string.format, string.lower
+local lpegmatch = lpeg.match
+
+local points = number.points
+local variables = interfaces.variables
+
+local defaults = {
+ chart = {
+ name = "",
+ option = "",
+ backgroundcolor = "",
+ width = 0,
+ height = 0,
+ dx = 0,
+ dy = 0,
+ offset = 0,
+ bodyfont = "",
+ dot = "",
+ },
+ shape = { -- FLOS
+ rulethickness = 65435,
+ default = "",
+ framecolor = "green",
+ backgroundcolor = "yellow",
+ },
+ focus = { -- FLOF
+ rulethickness = 65435,
+ framecolor = "red",
+ backgroundcolor = "yellow",
+ },
+ line = { -- FLOL
+ rulethickness = 65435,
+ radius = 65435,
+ color = "blue",
+ corner = "",
+ dash = "",
+ arrow = "",
+ offset = "",
+ },
+ set = { -- FLOX
+ },
+ split = {
+ nx = 3,
+ ny = 3,
+ command = "",
+ marking = "",
+ before = "",
+ after = "",
+ }
+}
+
+local validshapes = {
+ ["node"] = { kind = "shape", number = 0 },
+ ["action"] = { kind = "shape", number = 24 },
+ ["procedure"] = { kind = "shape", number = 5 },
+ ["product"] = { kind = "shape", number = 12 },
+ ["decision"] = { kind = "shape", number = 14 },
+ ["archive"] = { kind = "shape", number = 19 },
+ ["loop"] = { kind = "shape", number = 35 },
+ ["wait"] = { kind = "shape", number = 6 },
+ ["subprocedure"] = { kind = "shape", number = 20 },
+ ["singledocument"] = { kind = "shape", number = 32 },
+ ["multidocument"] = { kind = "shape", number = 33 },
+
+ ["right"] = { kind = "line", number = 66 },
+ ["left"] = { kind = "line", number = 67 },
+ ["up"] = { kind = "line", number = 68 },
+ ["down"] = { kind = "line", number = 69 },
+}
+
+local validlabellocations = {
+ l = "l", left = "l",
+ r = "r", right = "r",
+ t = "t", top = "t",
+ b = "b", bottom = "b",
+}
+
+table.setmetatableindex(validshapes,function(t,k)
+ local l = gsub(lower(k)," ","")
+ local v = rawget(t,l)
+ if not v then
+ local n = tonumber(k)
+ if n then
+ v = { "shape", n }
+ else
+ v = rawget(t,"action")
+ end
+ end
+ t[k] = v
+ return v
+end)
+
+local replacements = {
+ ["0"] = "a", ["1"] = "b", ["2"] = "c", ["3"] = "d", ["4"] = "e",
+ ["5"] = "f", ["6"] = "g", ["7"] = "h", ["8"] = "i", ["9"] = "j",
+}
+
+local function cleanname(str)
+ str = gsub(str,"[0-9]",replacements)
+ str = gsub(str,"[^a-zA-Z]","_")
+ return str
+end
+
+local charts = { }
+
+local data, hash, temp, last_x, last_y, name
+
+function commands.flow_start_chart(chartname)
+ data = { }
+ hash = { }
+ last_x, last_y = 0, 0
+ name = chartname
+end
+
+function commands.flow_stop_chart()
+ charts[name] = {
+ data = data,
+ hash = hash,
+ last_x = last_x,
+ last_y = last_y,
+ }
+ data, hash, temp = nil, nil, nil
+end
+
+function commands.flow_set_current_cell(n)
+ temp = data[tonumber(n)] or { }
+end
+
+function commands.flow_start_cell(settings)
+ temp = {
+ labels = { },
+ comments = { },
+ exits = { },
+ connections = { },
+ settings = settings,
+ }
+end
+
+function commands.flow_stop_cell()
+ data[#data+1] = temp
+ hash[temp.name or #data] = temp
+end
+
+function commands.flow_set_name(str)
+ temp.name = str
+end
+
+function commands.flow_set_shape(str)
+ temp.shape = str
+end
+
+function commands.flow_set_destination(str)
+ temp.destination = str
+end
+
+function commands.flow_set_text(align,str)
+ temp.align = align
+ temp.text = str
+end
+
+function commands.flow_set_overlay(str)
+ temp.overlay = str
+end
+
+function commands.flow_set_focus(str)
+ temp.focus = str
+end
+
+function commands.flow_set_figure(str)
+ temp.figure = str
+end
+
+function commands.flow_set_label(location,text)
+ temp.labels[#temp.labels+1] = {
+ location = location,
+ text = text,
+ }
+end
+
+function commands.flow_set_comment(name,str)
+ temp.comments[#temp.comments+1] = {
+ location = location,
+ text = text,
+ }
+end
+
+function commands.flow_set_exit(location,text)
+ temp.exits[#temp.exits+1] = {
+ location = location,
+ text = text,
+ }
+end
+
+function commands.flow_set_include(name,x,y,settings)
+ data[#data+1] = {
+ include = name,
+ x = x,
+ y = y,
+ -- settings = settings,
+ }
+end
+
+local function inject(includedata,data,hash)
+ local subchart = charts[includedata.include]
+ if not subchart then
+ return
+ end
+ local subdata = subchart.data
+ if not subdata then
+ return
+ end
+ local xoffset = (includedata.x or 1) - 1
+ local yoffset = (includedata.y or 1) - 1
+ local settings = includedata.settings
+ for i=1,#subdata do
+ local si = subdata[i]
+ local t = {
+ x = si.x + xoffset,
+ y = si.y + yoffset,
+ settings = settings,
+ }
+ table.setmetatableindex(t,si)
+ data[#data+1] = t
+ hash[si.name or #data] = t
+ end
+end
+
+local function expanded(chart)
+ local expandeddata = { }
+ local expandedhash = { }
+ local expandedchart = {
+ data = expandeddata,
+ hash = expandedhash,
+ }
+ table.setmetatableindex(expandedchart,chart)
+ local data = chart.data
+ local hash = chart.hash
+ for i=1,#data do
+ local di = data[i]
+ if di.include then
+ inject(di,expandeddata,expandedhash)
+ else
+ expandeddata[#expandeddata+1] = di
+ expandedhash[di.name or #expandeddata] = di
+ end
+ end
+ for i=1,#expandeddata do
+ local cell = expandeddata[i]
+ local settings = cell.settings
+ if not settings then
+ cell.settings = chart.settings
+ else
+ table.setmetatableindex(settings,chart.settings)
+ end
+ end
+ return expandedchart
+end
+
+
+local splitter = lpeg.splitat(",")
+
+function commands.flow_set_location(str) -- handle include differently
+ -- wrong: delay real x,y, only store relative
+ local x, y = lpegmatch(splitter,str)
+ if not x or x == "" then
+ x = last_x
+ elseif x == "+" then
+ x = last_x + 1
+ elseif x == "-" then
+ x = last_x - 1
+ elseif find(x,"^[%+%-]") then
+ x = last_x + (tonumber(x) or 0)
+ else
+ x = tonumber(x)
+ end
+ if not y or y == "" then
+ y = last_y
+ elseif y == "+" then
+ y = last_y + 1
+ elseif x == "-" then
+ y = last_y - 1
+ elseif find(y,"^[%+%-]") then
+ y = last_y + (tonumber(y) or 0)
+ else
+ y = tonumber(y)
+ end
+ temp.x = x
+ temp.y = y
+ last_x = x
+ last_y = 0
+end
+
+function commands.flow_set_connection(location,displacement,name)
+ local dx, dy = lpegmatch(splitter,displacement)
+ dx = tonumber(dx) or 1
+ dy = tonumber(dy) or 1
+ temp.connections[#temp.connections+1] = {
+ location = location,
+ dx = dx - 1,
+ dy = dy - 1,
+ name = name,
+ }
+end
+
+local where = {
+ l = "left",
+ r = "right",
+ t = "top",
+ b = "bottom",
+}
+
+local what = {
+ ["p"] = 1,
+ ["m"] = -1,
+ ["+"] = 1,
+ ["-"] = -1,
+}
+
+local function visible(chart,cell)
+ local x, y = cell.x, cell.y
+ return
+ x >= chart.from_x and x <= chart.to_x and
+ y >= chart.from_y and y <= chart.to_y and cell
+end
+
+local function check_cells(chart,xoffset,yoffset,min_x,min_y,max_x,max_y)
+ local data = chart.data
+ if not data then
+ return
+ end
+ for i=1,#data do
+ local cell = data[i]
+ local x, y = cell.x + xoffset, cell.y + yoffset
+ if min_x == 0 then
+ min_x, max_x = x, x
+ min_y, max_y = y, y
+ else
+ if x < min_x then min_x = x end
+ if y < min_y then min_y = y end
+ if x > max_x then max_x = x end
+ if y > max_y then max_y = y end
+ end
+ end
+ return min_x, min_y, max_x, max_y
+end
+
+local function process_cells(chart,xoffset,yoffset)
+ local data = chart.data
+ if not data then
+ return
+ end
+ for i=1,#data do
+ local cell = visible(chart,data[i])
+ if cell then
+ local shape = cell.shape
+ if not shape or shape == "" then
+ shape = settings.shape.default or "none"
+ end
+ if shape ~= variables.none then
+ local settings = cell.settings
+ local shapedata = validshapes[shape]
+ context("flow_begin_sub_chart ;")
+ if shapedata.kind == "line" then
+ context("flow_shape_line_color := \\MPcolor{%s} ;", settings.line.color)
+ context("flow_shape_fill_color := \\MPcolor{%s} ;", settings.line.color)
+ context("flow_shape_line_width := %s ; ", points(settings.line.rulethickness))
+ elseif hasfocus then -- doifcommonelse{FLOWcell,FLOWfocus}@@FLOWfocus
+ context("flow_shape_line_color := \\MPcolor{%s} ;", settings.focus.framecolor)
+ context("flow_shape_fill_color := \\MPcolor{%s} ;", settings.focus.backgroundcolor)
+ context("flow_shape_line_width := %s ; ", points(settings.focus.rulethickness))
+ else
+ context("flow_shape_line_color := \\MPcolor{%s} ;", settings.shape.framecolor)
+ context("flow_shape_fill_color := \\MPcolor{%s} ;", settings.shape.backgroundcolor)
+ context("flow_shape_line_width := %s ; " , points(settings.shape.rulethickness))
+ end
+ context("bodyfontsize := 10pt ;") -- todo
+ context("flow_peepshape := false ;") -- todo
+ context("flow_new_shape(%s,%s,%s) ;",cell.x+xoffset,cell.y+yoffset,shapedata.number)
+ context("flow_end_sub_chart ;")
+ end
+ end
+ end
+end
+
+-- todo : make lpeg for splitter
+
+local function process_connections(chart,xoffset,yoffset)
+ local data = chart.data
+ local hash = chart.hash
+ if not data then
+ return
+ end
+ local settings = chart.settings
+ for i=1,#data do
+ local cell = visible(chart,data[i])
+ if cell then
+ local connections = cell.connections
+ for j=1,#connections do
+ local connection = connections[j]
+ local othername = connection.name
+ local othercell = hash[othername]
+ if othercell then
+ local cellx, celly = cell.x, cell.y
+ local otherx, othery, location = othercell.x, othercell.y, connection.location
+ if otherx > 0 and othery > 0 and cellx > 0 and celly > 0 and connection.location then
+ -- move to setter
+ local what_cell, where_cell, what_other, where_other = match(location,"([%+%-pm]-)([lrtb])([%+%-pm]-)([lrtb])")
+ local what_cell = what [what_cell] or 0
+ local what_other = what [what_other] or 0
+ local where_cell = where[where_cell] or "left"
+ local where_other = where[where_other] or "right"
+ context("flow_smooth := %s ;", settings.line.corner == variables.round and "true" or "false")
+ context("flow_dashline := %s ;", settings.line.dash == variables.yes and "true" or "false")
+ context("flow_arrowtip := %s ;", settings.line.arrow == variables.yes and "true" or "false")
+ context("flow_touchshape := %s ;", settings.line.offset == variables.none and "true" or "false")
+ context("flow_dsp_x := %s ; flow_dsp_y := %s ;",connection.dx or 0, connection.dy or 0)
+ context("flow_connection_line_color := green ;",chart.settings.line.color)
+ context("flow_connection_line_width := 2pt ;",points(chart.settings.line.rulethickness))
+ context("flow_connect_%s_%s(%s,%s,%s) (%s,%s,%s) ;",where_cell,where_other,cellx,celly,what_cell,otherx,othery,what_other)
+ context("flow_dsp_x := 0 ; flow_dsp_y := 0 ;")
+ end
+ end
+ end
+ end
+ end
+end
+
+local texttemplate = "\\setvariables[flowcell:text][x=%s,y=%s,text={%s},align={%s},figure={%s},destination={%s}]"
+
+local function process_texts(chart,xoffset,yoffset)
+ local data = chart.data
+ local hash = chart.hash
+ if not data then
+ return
+ end
+ for i=1,#data do
+ local cell = visible(chart,data[i])
+ if cell then
+ local x = cell.x or 1
+ local y = cell.y or 1
+ local text = cell.text
+ if text and text ~= "" then
+ local a = cell.align or ""
+ local f = cell.figure or ""
+ local d = cell.destination or ""
+ context('flow_chart_draw_text(%s,%s,textext("%s")) ;',x,y,format(texttemplate,x,y,text,a,f,d))
+ end
+ local labels = cell.labels
+ for i=1,#labels do
+ local label = labels[i]
+ local text = label.text
+ local location = validlabellocations[label.location or ""]
+ if text and location then
+ context('flow_chart_draw_label_%s(%s,%s,textext("%s")) ;',location,x,y,text)
+ end
+ end
+ local exits = cell.exits
+ for i=1,#exits do
+ local exit = exits[i]
+ local text = exit.text
+ local location = validlabellocations[exit.location or ""]
+ if text and location then
+ -- maybe make autoexit an option
+ if location == "l" and x == chart.from_x + 1 or
+ location == "r" and x == chart.to_x - 1 or
+ location == "t" and y == chart.to_y - 1 or
+ location == "b" and y == chart.from_y + 1 then
+ context('flow_chart_draw_exit_%s(%s,%s,textext("%s")) ;',location,x,y,text)
+ end
+ end
+ end
+ local comments = cell.comments
+ for i=1,#comments do
+ -- invisible
+ end
+ end
+ end
+end
+
+local function getchart(settings)
+ local chartname = settings.chart.name
+ if not chartname then
+ print("no name given")
+ return
+ end
+ local chart = charts[chartname]
+ if not chart then
+ print("no such chart",chartname)
+ return
+ end
+ chart.settings = settings
+ table.setmetatableindex(settings,defaults)
+ chart = expanded(chart)
+ local _, _, nx, ny = check_cells(chart,0,0,0,0,0,0)
+ chart.from_x = chart.settings.chart.x or 1
+ chart.from_y = chart.settings.chart.y or 1
+ chart.to_x = chart.settings.chart.nx or nx
+ chart.to_y = chart.settings.chart.ny or ny
+ chart.nx = chart.to_x - chart.from_x + 1
+ chart.ny = chart.to_y - chart.from_y + 1
+ return chart
+end
+
+local function makechart(chart)
+ local settings = chart.settings
+ context.begingroup()
+ context.forgetall()
+ --
+ local bodyfont = settings.chart.bodyfont
+ if bodyfont ~= "" then
+ context.switchtobodyfont { bodyfont }
+ end
+ --
+ context.resetMPdrawing()
+ context.startMPdrawing()
+ context("if unknown context_flow : input mp-flow.mpiv ; fi ;")
+ context("flow_begin_chart(0,%s,%s);",chart.nx,chart.ny)
+ --
+ if settings.chart.option == variables.test or settings.chart.dot == variables.yes then
+ context("flow_show_con_points := true ;")
+ context("flow_show_mid_points := true ;")
+ context("flow_show_all_points := true ;")
+ elseif settings.chart.dot ~= "" then -- no checking done, private option
+ context("flow_show_%s_points := true ;",settings.chart.dot)
+ end
+ --
+ local backgroundcolor = settings.chart.backgroundcolor
+ if backgroundcolor and backgroundcolor ~= "" then
+ context("flow_chart_background_color := \\MPcolor{%s} ;",backgroundcolor)
+ end
+ --
+ local shapewidth = settings.chart.width
+ local gridwidth = shapewidth + 2*settings.chart.dx
+ local shapeheight = settings.chart.height
+ local gridheight = shapeheight + 2*settings.chart.dy
+ context("flow_grid_width := %s ;", points(gridwidth))
+ context("flow_grid_height := %s ;", points(gridheight))
+ context("flow_shape_width := %s ;", points(shapewidth))
+ context("flow_shape_height := %s ;", points(shapeheight))
+ --
+ local radius = settings.line.radius
+ local rulethickness = settings.line.rulethickness
+ local dx = settings.chart.dx
+ local dy = settings.chart.dy
+ if radius < rulethickness then
+ radius = 2.5*rulethickness
+ if radius > dx then
+ radius = dx
+ end
+ if radius > dy then
+ radius = dy
+ end
+ end
+ context("flow_connection_line_width := %s ;", points(rulethickness))
+ context("flow_connection_smooth_size := %s ;", points(radius))
+ context("flow_connection_arrow_size := %s ;", points(radius))
+ context("flow_connection_dash_size := %s ;", points(radius))
+ --
+ local offset = settings.chart.offset -- todo: pass string
+ if offset == variables.none or offset == variables.overlay or offset == "" then
+ offset = -2.5 * radius -- or rulethickness?
+ elseif offset == variables.standard then
+ offset = radius -- or rulethickness?
+ end
+ context("flow_chart_offset := %s ;",points(offset))
+ --
+ context("flow_reverse_y := true ;")
+ process_cells(chart,0,0)
+ process_connections(chart,0,0)
+ process_texts(chart,0,0)
+ -- context("clip_chart(%s,%s,%s,%s) ;",x,y,nx,ny) -- todo: draw lines but not shapes
+ context("flow_end_chart ;")
+ context.stopMPdrawing()
+ context.MPdrawingdonetrue() -- brrr
+-- context.MPstaticgraphictrue()
+-- context.MPshiftdrawingfalse()
+ context.getMPdrawing()
+ context.endgroup()
+end
+
+function commands.flow_make_chart(settings)
+ local chart = getchart(settings)
+ if chart then
+ local settings = chart.settings
+ if settings.split.state == variables.start then
+ local nx = chart.settings.split.nx
+ local ny = chart.settings.split.ny
+ local x = 1
+ while true do
+ local y = 1
+ while true do
+ -- FLOTbefore
+ -- doif @@FLOTmarking on -> cuthbox
+ -- @@FLOTcommand
+ chart.from_x = x
+ chart.from_y = y
+ chart.to_x = math.min(x + nx - 1,chart.nx)
+ chart.to_y = math.min(x + ny - 1,chart.ny)
+ makechart(chart)
+ -- FLOTafter
+ y = y + ny
+ if y > chart.max_y then
+ break
+ else
+ y = y - dy
+ end
+ end
+ x = x + nx
+ if x > chart.max_x then
+ break
+ else
+ x = x - dx
+ end
+ end
+ else
+ makechart(chart)
+ end
+ end
+end
diff --git a/tex/context/base/m-flow.mkvi b/tex/context/base/m-flow.mkvi
new file mode 100644
index 000000000..62b70bdaa
--- /dev/null
+++ b/tex/context/base/m-flow.mkvi
@@ -0,0 +1,482 @@
+%D \module
+%D [ file=m-flow, -- m-chart
+%D version=2011.10.1, -- 1998.10.10,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Flow Charts,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% todo (if used):
+% autofocus={name,name,name} -> min/max
+% flowsets
+% autoscaling (bodyfontsteps)
+% comment
+% overlay
+%
+% todo:
+% \useFLOWchart[name][parent][setting,setting][additional settings]
+% \useFLOWchart[name][parent][additional settings]
+% setups
+% mp instance with less files
+
+\registerctxluafile{m-flow}{}
+
+\unprotect
+
+\ifdefined \installsimplecommandhandler \else
+
+ \unexpanded\def\installsimplecommandhandler#1#2#3% no define
+ {\installparameterhandler {#1}{#2}%
+ \installparameterhashhandler{#1}{#2}%
+ \installparametersethandler {#1}{#2}%
+ \installrootparameterhandler{#1}{#2}%
+ \installsetuphandler {#1}{#2}%
+ \installattributehandler {#1}{#2}}
+
+\fi
+
+% todo: figure out a nice way to define the lot: share current and
+% support current as name (nb: we need to set parent then)
+
+\def\??flch{@@flch} % chart
+\def\??flln{@@flln} % line
+\def\??flsh{@@flsh} % shape
+\def\??flfc{@@flfc} % focus
+\def\??flst{@@flst} % sets
+\def\??flsp{@@flsp} % split
+
+\installsimplecommandhandler \??flch {FLOWchart} \??flch
+\installsimplecommandhandler \??flln {FLOWline} \??flln
+\installsimplecommandhandler \??flsh {FLOWshape} \??flsh
+\installsimplecommandhandler \??flfc {FLOWfocus} \??flfc
+\installsimplecommandhandler \??flst {FLOWsets} \??flst
+\installsimplecommandhandler \??flsp {FLOWsplit} \??flsp
+
+\let\setupFLOWcharts\setupFLOWchart
+\let\setupFLOWlines \setupFLOWline
+\let\setupFLOWshapes\setupFLOWshape
+\let\setupFLOWsets \setupFLOWset
+
+\setupFLOWcharts
+ [\c!width=12\bodyfontsize,
+ \c!height=7\bodyfontsize,
+ \c!offset=0pt, % \v!standard, % == auto offset
+ \c!dx=2\bodyfontsize,
+ \c!dy=2\bodyfontsize,
+ \c!nx=0,
+ \c!ny=0,
+ \c!x=1,
+ \c!y=1,
+ % \c!maxwidth=,
+ % \c!maxheight=,
+ % \c!option=,
+ % \c!bodyfont=,
+ % \c!dot=, % private option
+ % \c!autofocus=,
+ % \c!focus=,
+ % \c!background=,
+ % \c!framecolor=
+ % \c!backgroundcolor=, % \s!white
+ \c!rulethickness=\linewidth,
+ \c!frame=\v!off]
+
+\setupFLOWlines
+ [\c!corner=\v!round,
+ \c!arrow=\v!yes,
+ \c!dash=\v!no,
+ \c!radius=.375\bodyfontsize,
+ \c!color=FLOWlinecolor,
+ \c!rulethickness=.15\bodyfontsize,
+ \c!offset=\v!none]
+
+\setupFLOWshapes
+ [\c!default=action,
+ \c!framecolor=FLOWframecolor,
+ \c!background=\v!color,
+ \c!backgroundcolor=FLOWbackgroundcolor,
+ \c!rulethickness=.15\bodyfontsize,
+ \c!offset=.5\bodyfontsize]
+
+\setupFLOWfocus
+ [\c!framecolor=FLOWfocuscolor,
+ \c!background=\FLOWshapeparameter\c!background,
+ \c!backgroundcolor=\FLOWshapeparameter\c!backgroundcolor,
+ \c!backgroundscreen=\FLOWshapeparameter\c!backgroundscreen,
+ \c!rulethickness=\FLOWshapeparameter\c!rulethickness,
+ \c!offset=\FLOWshapeparameter\c!offset]
+
+\setupFLOWsplit
+ [\c!state=\v!stop,
+ \c!marking=\v!on,
+ % \c!command=,
+ % \c!before=,
+ % \c!after=,
+ \c!nx=3,
+ \c!ny=3]
+
+\definecolor [FLOWfocuscolor] [s=.2]
+\definecolor [FLOWlinecolor] [s=.5]
+\definecolor [FLOWframecolor] [s=.7]
+\definecolor [FLOWbackgroundcolor] [s=.9]
+
+\newtoks\everyFLOWchart
+
+\unexpanded\def\startFLOWchart
+ {\startnointerference
+ \the\everyFLOWchart
+ \dosingleempty\start_FLOW_chart}
+
+\unexpanded\def\start_FLOW_chart[#name]%
+ {\ctxcommand{flow_start_chart("#name")}}
+
+\unexpanded\def\stopFLOWchart
+ {\ctxcommand{flow_stop_chart()}%
+ \stopnointerference}
+
+\unexpanded\def\defineFLOWchart % for old times sake
+ {\dodoubleempty\define_FLOW_chart}
+
+\unexpanded\def\define_FLOW_chart[#name][#settings]#cells% todo: save settings
+ {\startnointerference
+ \the\everyFLOWchart
+ \ctxcommand{flow_start_chart("#name")}%
+ #cells%
+ \ctxcommand{flow_stop_chart()}%
+ \stopnointerference}
+
+\unexpanded\def\startFLOWcell
+ {\dodoubleempty\start_FLOW_cell}
+
+\unexpanded\def\start_FLOW_cell[#1][#2]%
+ {\begingroup
+ \iffirstargument
+ \setupFLOWshape[#1]%
+ \fi
+ \ifsecondargument
+ \setupFLOWline[#2]%
+ \fi
+ \ctxcommand{flow_start_cell {
+ shape = {
+ rulethickness = \number\dimexpr\FLOWshapeparameter\c!rulethickness,
+ default = "\FLOWshapeparameter\c!default",
+ framecolor = "\FLOWshapeparameter\c!framecolor",
+ backgroundcolor = "\FLOWshapeparameter\c!backgroundcolor",
+ },
+ focus = {
+ rulethickness = \number\dimexpr\FLOWfocusparameter\c!rulethickness,
+ framecolor = "\FLOWfocusparameter\c!framecolor",
+ backgroundcolor = "\FLOWfocusparameter\c!backgroundcolor",
+ },
+ line = {
+ rulethickness = \number\dimexpr\FLOWlineparameter\c!rulethickness,
+ radius = \number\dimexpr\FLOWlineparameter\c!radius,
+ corner = "\FLOWlineparameter\c!corner",
+ dash = "\FLOWlineparameter\c!dash",
+ arrow = "\FLOWlineparameter\c!arrow",
+ offset = "\FLOWlineparameter\c!offset",
+ },
+ } }%
+ \endgroup}
+
+\unexpanded\def\stopFLOWcell
+ {\ctxcommand{flow_stop_cell()}}
+
+\unexpanded\def\FLOWchart
+ {\dodoubleempty\FLOW_chart}
+
+\def\FLOW_chart[#name][#settings]%
+ {\vbox\bgroup
+ \insidefloattrue
+ \dontcomplain
+ \setupFLOWchart[#settings]%
+ \ctxcommand{flow_make_chart {
+ chart = {
+ name = "#name",
+ option = "\FLOWchartparameter\c!option",
+ backgroundcolor = "\FLOWchartparameter\c!backgroundcolor",
+ width = \number\dimexpr\FLOWchartparameter\c!width,
+ height = \number\dimexpr\FLOWchartparameter\c!height,
+ dx = \number\dimexpr\FLOWchartparameter\c!dx,
+ dy = \number\dimexpr\FLOWchartparameter\c!dy,
+ offset = \number\dimexpr\FLOWchartparameter\c!offset,
+ bodyfont = "\FLOWchartparameter\c!bodyfont",
+ dot = "\FLOWchartparameter\c!dot", % private option
+ },
+ shape = {
+ rulethickness = \number\dimexpr\FLOWshapeparameter\c!rulethickness,
+ default = "\FLOWshapeparameter\c!default",
+ framecolor = "\FLOWshapeparameter\c!framecolor",
+ backgroundcolor = "\FLOWshapeparameter\c!backgroundcolor",
+ },
+ focus = {
+ rulethickness = \number\dimexpr\FLOWfocusparameter\c!rulethickness,
+ framecolor = "\FLOWfocusparameter\c!framecolor",
+ backgroundcolor = "\FLOWfocusparameter\c!backgroundcolor",
+ },
+ line = {
+ rulethickness = \number\dimexpr\FLOWlineparameter\c!rulethickness,
+ radius = \number\dimexpr\FLOWlineparameter\c!radius,
+ corner = "\FLOWlineparameter\c!corner",
+ dash = "\FLOWlineparameter\c!dash",
+ arrow = "\FLOWlineparameter\c!arrow",
+ offset = "\FLOWlineparameter\c!offset",
+ },
+ set = {
+ },
+ split = {
+ state = "\FLOWsplitparameter\c!state",
+ nx = \number\FLOWsplitparameter\c!nx,
+ ny = \number\FLOWsplitparameter\c!ny,
+ command = "",
+ marking = "\FLOWsplitparameter\c!marking",
+ before = "",
+ after = "",
+ }
+ } }%
+ \egroup}
+
+\unexpanded\def\FLOWcharts
+ {\dodoubleempty\FLOW_charts}
+
+\def\FLOW_charts[#name][#settings]
+ {\begingroup
+ \setupFLOWsplit[\c!state=\v!start,#settings]%
+ \FLOW_chart[#name][]%
+ \endgroup}
+
+\appendtoks
+ \let\name \FLOW_name
+ \let\shape \FLOW_shape
+ \let\destination\FLOW_destination
+ \let\focus \FLOW_focus
+ \let\overlay \FLOW_overlay
+ \let\location \FLOW_location
+ \let\text \FLOW_text
+ \let\label \FLOW_label
+ \let\comment \FLOW_comment
+ \let\exit \FLOW_exit
+ \let\connection \FLOW_connection
+ \let\include \FLOW_include
+ \let\figure \FLOW_figure
+ %
+ \let\connect \FLOW_connection
+ \let\locate \FLOW_location
+ %
+ \let\includeFLOWchart\include
+\to \everyFLOWchart
+
+\unexpanded\def\FLOW_name #name{\ctxcommand{flow_set_name("#name")}\ignorespaces}
+\unexpanded\def\FLOW_shape #shape{\ctxcommand{flow_set_shape("#shape")}\ignorespaces}
+\unexpanded\def\FLOW_destination #destination{\ctxcommand{flow_set_destination("#destination")}\ignorespaces}
+\unexpanded\def\FLOW_focus #focus{\ctxcommand{flow_set_focus("#focus")}\ignorespaces}
+\unexpanded\def\FLOW_overlay #overlay{\ctxcommand{flow_set_overlay("#overlay")}\ignorespaces}
+\unexpanded\def\FLOW_location #location{\ctxcommand{flow_set_location("#location")}\ignorespaces}
+\unexpanded\def\FLOW_figure #figure{\ctxcommand{flow_set_figure("#figure")}\ignorespaces}
+
+\unexpanded\def\FLOW_text {\dosingleempty\do_FLOW_text}
+\unexpanded\def\FLOW_label {\dosingleempty\do_FLOW_label}
+\unexpanded\def\FLOW_comment {\dosingleempty\do_FLOW_commment}
+\unexpanded\def\FLOW_exit {\dosingleempty\do_FLOW_exit}
+\unexpanded\def\FLOW_connection {\dodoubleempty\do_FLOW_connection}
+\unexpanded\def\FLOW_include {\dodoubleempty\do_FLOW_include}
+
+\unexpanded\def\do_FLOW_text [#align]#text{\ctxcommand{flow_set_text("#align",\!!bs\detokenize{#text}\!!es)}\ignorespaces}
+\unexpanded\def\do_FLOW_label [#location]#text{\ctxcommand{flow_set_label("#location",\!!bs\detokenize{#text}\!!es)}\ignorespaces}
+\unexpanded\def\do_FLOW_comment [#location]#text{\ctxcommand{flow_set_comment("#location",\!!bs\detokenize{#text}\!!es)}\ignorespaces}
+\unexpanded\def\do_FLOW_exit [#location]#text{\ctxcommand{flow_set_exit("#location",\!!bs\detokenize{#text}\!!es)}\ignorespaces}
+\unexpanded\def\do_FLOW_connection[#location][#offset]#name{\ctxcommand{flow_set_connection("#location","#offset","#name")}\ignorespaces}
+
+\unexpanded\def\do_FLOW_include [#name][#settings]{%
+ \begingroup
+ \getparameters[FLOWi][x=1,y=1,#settings]%
+ \ctxcommand{flow_set_include("#name",\number\FLOWix,\number\FLOWiy,\!!bs\detokenize{#settings}\!!es)}%
+ \endgroup
+ \ignorespaces
+}
+
+\setvariables
+ [flowcell:text]
+ [x=1,
+ y=1,
+ text=,
+ align=,
+ set=\setups{flowcell:text:place}]
+
+% \c!background={\@@FLOWbackground,\FLOWoverlay},
+
+\defineoverlay
+ [flowcell:figure]
+ [\overlayfigure{\getvariable{flowcell:text}{figure}}]
+
+\startsetups flowcell:text:place
+ \begingroup
+ \iftrialtypesetting
+ \directsetup{flowcell:text:place:indeed}
+ \else \iflocation
+ \doifelsenothing {\getvariable{flowcell:text}{destination}} {
+ \directsetup{flowcell:text:place:indeed}
+ } {
+ % tricky: scaling and moving around is not taken into account
+ \setupinteraction[\c!color=,\c!contrastcolor=]
+ \gotobox{\directsetup{flowcell:text:place:indeed}}[\getvariable{flowcell:text}{destination}]
+ }
+ \else
+ \directsetup{flowcell:text:place:indeed}
+ \fi \fi
+ \endgroup
+\stopsetups
+
+\startsetups flowcell:text:place:indeed
+ \begingroup
+ \directsetup{flowcell:text:user}
+ \doifelsenothing {\getvariable{flowcell:text}{figure}} {
+ \doframed
+ [flowcell:\getvariable{flowcell:text}{align}]
+ {\getvariable{flowcell:text}{text}}
+ } {
+ \doframed
+ [flowcell:\getvariable{flowcell:text}{align}]
+ [background=flowcell:figure]
+ {\getvariable{flowcell:text}{text}}
+ }
+ \endgroup
+\stopsetups
+
+\defineframed % to be discussed: shape or global
+ [flowcell:base]
+ [\c!offset=\v!overlay, % no strut ?
+ \c!frame=\FLOWchartparameter\c!frame,
+ \c!background=\FLOWchartparameter\c!background,
+ \c!backgroundcolor=\FLOWchartparameter\c!backgroundcolor,
+ %\c!foregroundcolor=\FLOWshapeparameter\c!foregroundcolor,
+ \c!align=\v!middle,
+ \c!bottom=\vfill,
+ \c!top=\vfill,
+ \c!width=\FLOWchartparameter\c!width,
+ \c!height=\FLOWchartparameter\c!height,
+ % \c!rulethickness=\FLOWchartparameter\c!rulethickness,
+ \c!rulethickness=\zeropoint, % comment for tracing
+ \c!framecolor=\FLOWchartparameter\c!framecolor]
+
+\defineframed[flowcell:] [flowcell:base]
+\defineframed[flowcell:l] [flowcell:base][\c!align=\v!flushleft]
+\defineframed[flowcell:r] [flowcell:base][\c!align=\v!flushright]
+\defineframed[flowcell:m] [flowcell:base][\c!align=\v!middle]
+\defineframed[flowcell:c] [flowcell:base][\c!align=\v!middle]
+
+\defineframed[flowcell:t] [flowcell:base][\c!top=]
+\defineframed[flowcell:b] [flowcell:base][\c!bottom=]
+
+\defineframed[flowcell:lt][flowcell:base][\c!top=,\c!align=\v!flushleft]
+\defineframed[flowcell:rt][flowcell:base][\c!top=,\c!align=\v!flushright]
+\defineframed[flowcell:mt][flowcell:base][\c!top=,\c!align=\v!middle]
+\defineframed[flowcell:ct][flowcell:base][\c!top=,\c!align=\v!middle]
+
+\defineframed[flowcell:lb][flowcell:base][\c!bottom=,\c!align=\v!flushleft]
+\defineframed[flowcell:rb][flowcell:base][\c!bottom=,\c!align=\v!flushright]
+\defineframed[flowcell:mb][flowcell:base][\c!bottom=,\c!align=\v!middle]
+\defineframed[flowcell:cb][flowcell:base][\c!bottom=,\c!align=\v!middle]
+
+% todo: each cell its own setup
+%
+% \startsetups flowcell
+% \definelayer
+% [flowcell]
+% [width=\FLOWshapewidth,
+% height=\FLOWshapeheight]
+% \setlayerframed
+% [flowcell]
+% [preset=rightbottom,offset=1ex]
+% [frame=off]
+% {\tx(\FLOWx,\FLOWy)}
+% \stopsetups
+
+%D \starttyping
+%D \setupFLOWsplit
+%D [nx=5,ny=10,
+%D dx=0,dy=0,
+%D before=,
+%D after=\page]
+%D
+%D \FLOWcharts[mybigflow]
+%D \stoptyping
+%D
+%D \starttyping
+%D \splitfloat
+%D {\placefigure{What a big flowchart this is!}}
+%D {\FLOWcharts[mybigflow]}
+%D \stoptyping
+
+\protect
+
+\continueifinputfile{m-flow.mkvi}
+
+\input chrt-xml.tex
+
+\usemodule[abr-01]
+
+\setupFLOWcharts[option=test]
+\setupFLOWcharts[frame=on]
+\setupinteraction[state=start]
+
+% \setupFLOWcharts[dx=30pt,dy=30pt]
+
+\startFLOWchart[demo]
+ \startFLOWcell[framecolor=darkgray]
+ \name {start}
+ \location {1,1}
+ \shape {action}
+ \text {start}
+ \connection [bl] {one}
+ \stopFLOWcell
+ \startFLOWcell
+ \name {one}
+% \destination{CloseDocument}
+ \location {2,2}
+ \shape {action}
+ \text {first}
+% \label [b] {\bfx bottom}
+ \connection [rt] {two}
+% \exit [l] {exit l}
+% \exit [r] {exit r}
+% \exit [t] {exit t}
+% \exit [b] {exit b}
+ \stopFLOWcell
+ \setupFLOWshapes[framecolor=darkgray]
+ \startFLOWcell % [foregroundcolor=white]
+ \name {two}
+% \destination{CloseDocument}
+ \location {3,3}
+ \shape {action}
+ \text {second}
+ \figure {cow.pdf}
+% \label [l] {\bfx left}
+% \exit [l] {exit l}
+% \exit [r] {exit r}
+% \exit [t] {exit t}
+% \exit [b] {exit b}
+ \stopFLOWcell
+\stopFLOWchart
+
+\starttext
+
+\startTEXpage
+% \FLOWchart[convert-en]
+% \FLOWchart[conversion 1]
+% \FLOWchart[conversion 7]
+% \FLOWchart[conversion 9]
+% \FLOWchart[conversion 10]
+ \FLOWchart[demo]
+
+\stopTEXpage
+
+\startTEXpage
+ \FLOWchart[conversion 10]
+\stopTEXpage
+
+\stoptext
diff --git a/tex/context/base/mlib-pdf.lua b/tex/context/base/mlib-pdf.lua
index 3eaffded1..38e59a94f 100644
--- a/tex/context/base/mlib-pdf.lua
+++ b/tex/context/base/mlib-pdf.lua
@@ -98,18 +98,18 @@ end
function metapost.flushers.pdf.comment(message)
if message then
message = format("%% mps graphic %s: %s", metapost.n, message)
-if experiment then
- context(pdfliteral(message))
-else
- if savedliterals then
- local last = #savedliterals + 1
- savedliterals[last] = message
- context.MPLIBtoPDF(last)
+ if experiment then
+ context(pdfliteral(message))
else
- savedliterals = { message }
- context.MPLIBtoPDF(1)
+ if savedliterals then
+ local last = #savedliterals + 1
+ savedliterals[last] = message
+ context.MPLIBtoPDF(last)
+ else
+ savedliterals = { message }
+ context.MPLIBtoPDF(1)
+ end
end
-end
end
end
@@ -129,18 +129,18 @@ end
function metapost.flushers.pdf.flushfigure(pdfliterals) -- table
if #pdfliterals > 0 then
pdfliterals = concat(pdfliterals,"\n")
-if experiment then
- context(pdfliteral(pdfliterals))
-else
- if savedliterals then
- local last = #savedliterals + 1
- savedliterals[last] = pdfliterals
- context.MPLIBtoPDF(last)
+ if experiment then
+ context(pdfliteral(pdfliterals))
else
- savedliterals = { pdfliterals }
- context.MPLIBtoPDF(1)
+ if savedliterals then
+ local last = #savedliterals + 1
+ savedliterals[last] = pdfliterals
+ context.MPLIBtoPDF(last)
+ else
+ savedliterals = { pdfliterals }
+ context.MPLIBtoPDF(1)
+ end
end
-end
end
end
diff --git a/tex/context/base/mlib-pps.lua b/tex/context/base/mlib-pps.lua
index 330339c40..ca3bbaa75 100644
--- a/tex/context/base/mlib-pps.lua
+++ b/tex/context/base/mlib-pps.lua
@@ -700,7 +700,7 @@ end
local basepoints = number.dimenfactors["bp"]
-local cm = function(object)
+local function cm(object)
local op = object.path
local first, second, fourth = op[1], op[2], op[4]
local tx, ty = first.x_coord , first.y_coord
@@ -768,17 +768,19 @@ local function tx_process(object,prescript,before,after)
if trace_textexts then
report_textexts("processing %s (second pass)",tx_number)
end
- before[#before+1] = format("q %f %f %f %f %f %f cm",cm(object))
+ -- before[#before+1] = format("q %f %f %f %f %f %f cm",cm(object))
+ local sx,rx,ry,sy,tx,ty = cm(object)
before[#before+1] = function()
-- flush always happens, we can have a special flush function injected before
local box = textexts[tx_number]
if box then
- context.MPLIBgettextscaled(tx_number,sxsy(box.width,box.height,box.depth))
+ -- context.MPLIBgettextscaled(tx_number,sxsy(box.width,box.height,box.depth))
+ context.MPLIBgettextscaledcm(tx_number,sx,rx,ry,sy,tx,ty,sxsy(box.width,box.height,box.depth))
else
report_textexts("unknown %s",tx_number)
end
end
- before[#before+1] = "Q"
+ -- before[#before+1] = "Q"
if not trace_textexts then
object.path = false -- else: keep it
end
diff --git a/tex/context/base/mlib-pps.mkiv b/tex/context/base/mlib-pps.mkiv
index 25ebab6fa..b2afbc0da 100644
--- a/tex/context/base/mlib-pps.mkiv
+++ b/tex/context/base/mlib-pps.mkiv
@@ -45,6 +45,19 @@
{\ctxlua{metapost.gettext(\number\MPtextbox,#1)}%
\vbox to \zeropoint{\vss\hbox to \zeropoint{\scale[\c!sx=#2,\c!sy=#3]{\raise\dp\MPtextbox\box\MPtextbox}\forcecolorhack\hss}}}
+% horrible:
+
+\def\MPLIBgettextscaledcm#1#2#3#4#5#6#7#8#9% 2-7: sx,rx,ry,sy,tx,ty
+ {\ctxlua{metapost.gettext(\number\MPtextbox,#1)}%
+ \setbox\scratchbox\hbox
+ {\hskip\dimexpr#6bp\raise#7bp\hbox
+ {\pdfsave
+ \pdfsetmatrix{#2 #3 #4 #5}%
+ \vbox to \zeropoint{\vss\hbox to \zeropoint{\scale[\c!sx=#8,\c!sy=#9]{\raise\dp\MPtextbox\box\MPtextbox}\forcecolorhack\hss}}%
+ \pdfrestore}}%
+ \smashbox\scratchbox
+ \box\scratchbox}
+
\def\MPLIBgraphictext#1%
{\startTEXpage[\c!scale=10000]#1\stopTEXpage}
diff --git a/tex/context/base/mult-low.lua b/tex/context/base/mult-low.lua
index 91fb4baf8..d76010e07 100644
--- a/tex/context/base/mult-low.lua
+++ b/tex/context/base/mult-low.lua
@@ -46,7 +46,8 @@ return {
"startcomponent", "stopcomponent", "component",
"startproduct", "stopproduct", "product",
"startproject", "stopproject", "project",
- "starttext", "stoptext"
+ "starttext", "stoptext",
+ "startmodule", "stopmodule", "usemodule",
},
["helpers"] = {
--
@@ -138,5 +139,7 @@ return {
--
"getfirstcharacter", "doiffirstcharelse",
--
+ "startnointerference", "stopnointerference",
+ --
}
}
diff --git a/tex/context/base/mult-mps.lua b/tex/context/base/mult-mps.lua
index 1dcb4d476..860ae29f1 100644
--- a/tex/context/base/mult-mps.lua
+++ b/tex/context/base/mult-mps.lua
@@ -42,6 +42,7 @@ return {
"xoffset", "chardx", "granularity", "smoothing", "turningcheck", "yoffset",
"chardy", "hppp", "tracingedges", "vppp",
"extra_beginfig", "extra_endfig", "mpxbreak",
+ "endinput",
},
plain = {
"ahangle", "ahlength", "bboxmargin", "defaultpen", "defaultscale",
diff --git a/tex/context/base/pack-rul.mkiv b/tex/context/base/pack-rul.mkiv
index ebadf90e0..5245208a2 100644
--- a/tex/context/base/pack-rul.mkiv
+++ b/tex/context/base/pack-rul.mkiv
@@ -2942,21 +2942,49 @@
%D also simplified the \type {\setupframed} command. There are
%D certainly more places where such improvements can be made.
-\def\defineframed
- {\dodoubleempty\dodefineframed}
-
-\def\dodefineframed[#1][#2]%
+% \def\defineframed
+% {\dodoubleempty\dodefineframed}
+%
+% \def\dodefineframed[#1][#2]%
+% {\ifcsname\??ol:#1\endcsname
+% % already defined, keeps settings
+% \else
+% \expandafter\newcount\csname\??ol:#1\endcsname % \the\everypresetframed
+% \fi
+% \getparameters[\??ol#1][\s!parent=\??ol,#2]%
+% \setuvalue{#1}{\doframed[#1]}}% % \the\everydefineframed
+
+\def\defineframed % also inheritance now
+ {\dotripleempty\dodefineframed}
+
+\def\dodefineframed[#1][#2][#3]%
{\ifcsname\??ol:#1\endcsname
% already defined, keeps settings
\else
\expandafter\newcount\csname\??ol:#1\endcsname % \the\everypresetframed
\fi
- \getparameters[\??ol#1][\s!parent=\??ol,#2]%
+ \ifsecondargument
+ \doifassignmentelse{#2}
+ {\getparameters[\??ol#1][\s!parent=\??ol,#2]}%
+ {\ifcsname#2\endcsname
+ \getparameters[\??ol#1][\s!parent=\??ol#2,#3]%
+ \else
+ \getparameters[\??ol#1][\s!parent=\??ol,#3]%
+ \fi}%
+ \else
+ \getparameters[\??ol#1][\s!parent=\??ol,#2]%
+ \fi
\setuvalue{#1}{\doframed[#1]}}% % \the\everydefineframed
-\def\doframed[#1]%
+\newcount\crapframedcount
+
+\def\doframed[#1]% official (not much checking, todo: parent)
{\bgroup
- \expandafter\let\expandafter\tempframedcount\csname\??ol:#1\endcsname
+ \ifcsname\??ol:#1\endcsname
+ \expandafter\let\expandafter\tempframedcount\csname\??ol:#1\endcsname
+ \else
+ \let\tempframedcount\crapframedcount
+ \fi
\advance\tempframedcount\plusone
\expandafter\def\csname\??ol#1:\the\tempframedcount\s!parent\endcsname{\??ol#1}% \inheritlocalframed
\dodoubleempty\dolocalframed[\??ol#1:\the\tempframedcount]}
diff --git a/tex/context/base/page-one.mkiv b/tex/context/base/page-one.mkiv
index ef2f55752..6156ab8b1 100644
--- a/tex/context/base/page-one.mkiv
+++ b/tex/context/base/page-one.mkiv
@@ -289,7 +289,7 @@
\OTRONEdosettopinserts
\OTRONEdosetbotinserts
\ifsomefloatwaiting
- \doif\rootfloatparameter\c!cache\v!no\doflushfloats
+ \doif{\rootfloatparameter\c!cache}\v!no\doflushfloats
\fi
\fi}
diff --git a/tex/context/base/s-art-01.mkiv b/tex/context/base/s-art-01.mkiv
new file mode 100644
index 000000000..d62689798
--- /dev/null
+++ b/tex/context/base/s-art-01.mkiv
@@ -0,0 +1,36 @@
+\startmodule[art-01]
+
+% \showframe
+
+\setuplayout
+ [topspace=2cm,
+ bottomspace=2.5cm,
+ width=middle,
+ height=middle,
+ footer=0pt]
+
+\setupbodyfont
+ [dejavu]
+
+\setupwhitespace
+ [big]
+
+\setuphead
+ [chapter]
+ [style=\bfc,
+ headerstate=high]
+
+\setuphead
+ [section]
+ [style=\bfb]
+
+\setuphead
+ [subsection]
+ [style=\bfa]
+
+\setuphead
+ [subsubsection]
+ [style=\bf,
+ after=]
+
+\stopmodule
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 179300e49..cc89cf9a6 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 1cba3622d..9634937b1 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/strc-ini.lua b/tex/context/base/strc-ini.lua
index 969e1e5f2..fd25f7d45 100644
--- a/tex/context/base/strc-ini.lua
+++ b/tex/context/base/strc-ini.lua
@@ -170,6 +170,8 @@ local tags = {
--
-- local command = format("\\xmlprocessbuffer{%s}{%s}{}",metadata.xmlroot or "main",tag)
+local experiment = true
+
function helpers.title(title,metadata) -- coding is xml is rather old and not that much needed now
if title and title ~= "" then -- so it might disappear
if metadata then
@@ -178,12 +180,21 @@ function helpers.title(title,metadata) -- coding is xml is rather old and not th
-- title can contain raw xml
local tag = tags[metadata.kind] or tags.generic
local xmldata = format("<?xml version='1.0'?><%s>%s</%s>",tag,title,tag)
+if not experiment then
buffers.assign(tag,xmldata)
+end
if trace_processors then
report_processors("putting xml data in buffer: %s",xmldata)
report_processors("processing buffer with setup '%s' and tag '%s'",xmlsetup or "",tag)
end
+if experiment then
+ -- the question is: will this be forgotten ... better store in a via file
+ local xmltable = lxml.convert("temp",xmldata or "")
+ lxml.store("temp",xmltable)
+ context.xmlsetup("temp",xmlsetup or "")
+else
context.xmlprocessbuffer("dummy",tag,xmlsetup or "")
+end
elseif xmlsetup then -- title is reference to node (so \xmlraw should have been used)
if trace_processors then
report_processors("feeding xmlsetup '%s' using node '%s'",xmlsetup,title)
diff --git a/tex/context/base/strc-ref.mkvi b/tex/context/base/strc-ref.mkvi
index b7159dfbc..414dcbafe 100644
--- a/tex/context/base/strc-ref.mkvi
+++ b/tex/context/base/strc-ref.mkvi
@@ -1191,7 +1191,7 @@
\fi
\endgroup}
-\unexpanded\def\gotobox#content[#label]% no test for valid references
+\unexpanded\def\gotobox#content[#label]%
{\dontleavehmode
\begingroup
\global\lastsavedreferenceattribute\attributeunsetvalue
diff --git a/tex/context/base/trac-set.lua b/tex/context/base/trac-set.lua
index 27b5f17f2..f7708b5d5 100644
--- a/tex/context/base/trac-set.lua
+++ b/tex/context/base/trac-set.lua
@@ -74,6 +74,10 @@ local function set(t,what,newvalue)
if type(what) ~= "table" then
return
end
+ if not done then -- catch ... why not set?
+ done = { }
+ t.done = done
+ end
for w, value in next, what do
if value == "" then
value = newvalue
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index 7371dcfc9..981b8510d 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 10/03/11 12:59:24
+-- merge date : 10/05/11 23:32:57
do -- begin closure to overcome local limits and interference
@@ -5136,15 +5136,21 @@ local function showfeatureorder(rawdata,filename)
if features then
for feature, scripts in next, features do
local tt = { }
- for script, languages in next, scripts do
- local ttt = { }
- for language, _ in next, languages do
- ttt[#ttt+1] = language
+ if type(scripts) == "table" then
+ for script, languages in next, scripts do
+ local ttt = { }
+ for language, _ in next, languages do
+ ttt[#ttt+1] = language
+ end
+ tt[#tt+1] = format("[%s: %s]",script,concat(ttt," "))
+ end
+ if trace_loading then
+ report_otf(" %s: %s",feature,concat(tt," "))
+ end
+ else
+ if trace_loading then
+ report_otf(" %s: %s",feature,tostring(scripts))
end
- tt[#tt+1] = format("[%s: %s]",script,concat(ttt," "))
- end
- if trace_loading then
- report_otf(" %s: %s",feature,concat(tt," "))
end
end
end
@@ -12136,7 +12142,7 @@ function definers.loadfont(specification)
local embedding
if directive_embedall then
embedding = "full"
- elseif properties.filename and constructors.dontembed[properties.filename] then
+ elseif properties and properties.filename and constructors.dontembed[properties.filename] then
embedding = "no"
else
embedding = "subset"