diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-10-24 11:13:27 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-10-24 11:13:27 +0200 |
commit | d91c37679b13162a4ead85abbe564090b2e1b51c (patch) | |
tree | 01b9c9e5a2437c7381b0f6d109cd51f0f6bed84e /metapost | |
parent | cb218b728af372a1ed6c9188765022dc057799ac (diff) | |
download | context-d91c37679b13162a4ead85abbe564090b2e1b51c.tar.gz |
2017-10-24 10:36:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpii/mp-tool.mpii | 1 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-grph.mpiv | 5 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-luas.mpiv | 7 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-text.mpiv | 14 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-tool.mpiv | 34 |
5 files changed, 22 insertions, 39 deletions
diff --git a/metapost/context/base/mpii/mp-tool.mpii b/metapost/context/base/mpii/mp-tool.mpii index a3300f5bb..562139fed 100644 --- a/metapost/context/base/mpii/mp-tool.mpii +++ b/metapost/context/base/mpii/mp-tool.mpii @@ -2816,3 +2816,4 @@ enddef; extra_endfig := extra_endfig & "mfun_apply_max_dimensions ;" ; let dump = relax ; + diff --git a/metapost/context/base/mpiv/mp-grph.mpiv b/metapost/context/base/mpiv/mp-grph.mpiv index 5938b9f02..04d4920f6 100644 --- a/metapost/context/base/mpiv/mp-grph.mpiv +++ b/metapost/context/base/mpiv/mp-grph.mpiv @@ -65,7 +65,6 @@ enddef ; numeric currentgraphictext ; currentgraphictext := 0 ; -def data_mpo_file = job_name & "-mpgraph.mpo" enddef ; def data_mpy_file = job_name & "-mpgraph.mpy" enddef ; def begingraphictextfig (expr n) = @@ -82,10 +81,10 @@ def endgraphictextfig = enddef ; def loadfigure primary filename = - doloadfigure (filename) + mfun_load_figure(filename) enddef ; -def doloadfigure (expr filename) text figureattributes = +def mfun_load_figure (expr filename) text figureattributes = begingroup ; save figurenumber, figurepicture, number, fixedplace ; numeric figurenumber ; figurenumber := 0 ; diff --git a/metapost/context/base/mpiv/mp-luas.mpiv b/metapost/context/base/mpiv/mp-luas.mpiv index 6444c6f07..99df0b861 100644 --- a/metapost/context/base/mpiv/mp-luas.mpiv +++ b/metapost/context/base/mpiv/mp-luas.mpiv @@ -49,10 +49,13 @@ boolean context_luas ; context_luas := true ; % % Fourth variant: +string mfun_lua_bs ; mfun_lua_bs = "[[" ; +string mfun_lua_es ; mfun_lua_es = "]]" ; + vardef mlib_luas_luacall(text t) = runscript("" for s = t : if string s : - & s + & mfun_lua_bs & s & mfun_lua_es elseif numeric s : & decimal s elseif boolean s : @@ -72,7 +75,7 @@ vardef mlib_luas_lualist(expr c)(text t) = hide(b := true) fi if string s : - & ditto & s & ditto + & mfun_lua_bs & s & mfun_lua_es elseif numeric s : & decimal s elseif boolean s : diff --git a/metapost/context/base/mpiv/mp-text.mpiv b/metapost/context/base/mpiv/mp-text.mpiv index b68e8412a..043d09d80 100644 --- a/metapost/context/base/mpiv/mp-text.mpiv +++ b/metapost/context/base/mpiv/mp-text.mpiv @@ -59,10 +59,10 @@ def build_parshape (expr p, offset_or_path, dx, dy, baselineskip, strutheight, s startsavingdata ; - savedata "\global\parvoffset " & decimal voffset&"bp " ; - savedata "\global\parhoffset " & decimal hoffset&"bp " ; - savedata "\global\parwidth " & decimal hsize&"bp " ; - savedata "\global\parheight " & decimal vsize&"bp " ; + savedata "\global\parvoffset " & decimal voffset & "bp " ; + savedata "\global\parhoffset " & decimal hoffset & "bp " ; + savedata "\global\parwidth " & decimal hsize & "bp " ; + savedata "\global\parheight " & decimal vsize & "bp " ; if not path offset_or_path : q := q xscaled ((hsize-2hoffset)/hsize) yscaled ((vsize-2voffset)/vsize) ; @@ -144,13 +144,13 @@ def build_parshape (expr p, offset_or_path, dx, dy, baselineskip, strutheight, s if (i=strutheight) and (width[n]<baselineskip) : n := n - 1 ; - savedata "\global\chardef\parfirst=1 " ; + savedata "\global\parfirst\plusone " ; fi ; endfor ; - savedata "\global\parlines " & decimal n ; - savedata "\global\partoks{ " ; + savedata "\global\parlines " & decimal n ; + savedata "\global\partoks{ " ; for i=1 upto n: savedata decimal indent[i]&"bp " & decimal width[i]&"bp " ; endfor ; diff --git a/metapost/context/base/mpiv/mp-tool.mpiv b/metapost/context/base/mpiv/mp-tool.mpiv index cd04b8dcb..34984465f 100644 --- a/metapost/context/base/mpiv/mp-tool.mpiv +++ b/metapost/context/base/mpiv/mp-tool.mpiv @@ -234,50 +234,27 @@ def job_name = jobname enddef ; -def data_mpd_file = - job_name & "-mp.mpd" -enddef ; - %D Because \METAPOST\ has a hard coded limit of 4~datafiles, %D we need some trickery when we have multiple files. This will %D be redone (via \LUA). -if unknown collapse_data : - boolean collapse_data ; - collapse_data := false ; -fi ; - boolean savingdata ; savingdata := false ; boolean savingdatadone ; savingdatadone := false ; def savedata expr txt = - write if collapse_data : - txt - else : - if savingdata : txt else : "\MPdata{" & decimal charcode & "}{" & txt & "}" fi & "%" - fi to data_mpd_file ; + lua.mp.save_data(txt); enddef ; def startsavingdata = - savingdata := true ; - savingdatadone := true ; - if collapse_data : - write "\MPdata{" & decimal charcode & "}{%" to data_mpd_file ; - fi ; + lua.mp.start_saving_data(); enddef ; def stopsavingdata = - if collapse_data : - write "}%" to data_mpd_file ; - fi ; - savingdata := false ; + lua.mp.stop_saving_data() ; enddef ; def finishsavingdata = - if savingdatadone : - write EOF to data_mpd_file ; - savingdatadone := false ; - fi ; + lua.mp.finish_saving_data() ; enddef ; %D Instead of a keystroke eating save and allocation @@ -3222,6 +3199,9 @@ def loadmodule expr name = % no vardef fi ; enddef ; +def loadfile (expr filename) = scantokens("input " & filename) enddef ; +def loadimage (expr filename) = image(scantokens("input " & filename);) enddef ; + %D Handy for backgrounds: def drawpathwithpoints expr p = |