Hi, In order to make sure that Mojca will not enter stress mode due to her gnuplot commitments, and also to give other textext users a way out, we now have a new feature: texts processed inside the tex run. (yet to be tested in intermediate runs, but in the future we may stick to runtime completely (experiments with persitent mp runs are pretty promissing). Attached is a test file. The interesting thing is that one can now have arbitrary content in a mp textext (different name btw). Beware: the current context is used so one needs to feed specific settings using the mp environment or else. Normally this is no big problem. I may change the name of \sometxt (not sure yet). There is some trickery involved in expanding the \sometxt and it took me a while to figure out a good way to make the text manipuletable by mp in the usual way while still keeping the real thing inside tex. It may learn you a few tricks -) I'm currently uploading the release (beta) that supports this (plus A's static graphics in disguise) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Not that I would really need to type in the following example, but if I didn't find something interesting, Hans would accuse me of not taking a look at it at all ;) \startMPpage draw (0,0)--(5cm,0); draw (0,0)--(5cm,5cm); picture p; p := \sometxt{\bTABLE \bTR\bTD abc\eTD\bTD xyz\eTD\eTR \bTR\bTD abc\eTD\bTD xyz\eTD\eTR \bTR\bTD abc\eTD\bTD xyz\eTD\eTR \eTABLE}; % or withcolor here draw p withcolor transparent(1,.5,red); \stopMPpage (To be honest I wanted to send the following example, but I didn't want to torture: %\startMPpage %draw \sometxt{ % \startCSV % a b c % \stopCSV % } ; %\stopMPpage ) General opinion: AMAZING speed, amazing feature! I love the fact that the labels are typest in the flow of the current document, so now macros defined earlier in the document may be used for labels as well. That's simply great! Also because of the fact that \def's refused to work inside of metafun graphics and no additional runs are needed. That's far more elegant and way more efficient that the way I would have to go for separating labels from \MPfigs Hans, that's marvellous! Thanks a lot! Mojca Just a side note: I noticed the new database module already in the beta, but the first Hans's fix (before Taco has touched it) introduced a new "tab-bug" which hasn't been quite resolved yet. If "separator=tab", it should trigger catcode change of tab to a "normal letter" and use that one for separating columns. Well, indeed it seems that the catcode is changed, but then I get the letter number 9 in EC font (macron) instead of going to new column. I'm now asking for impossible again, but: any simple/reasonable way to control the baseline/general positioning of the labels? (textext included text with baseline at y=0 by default, the new mechanism simply puts the lower corner to the baseline)
Question, questions and questions again ... The question from yestarday wasn't a serious one. But this one might get closer. After I've rewritten the context.trm to try the new \sometxt out, I struggled against the following problem: \startMPcode picture p; vardef rotateme(expr m) = (m rotated 90) enddef; % this works p := \sometxt{sin (x)}; draw rotateme(p); % this doesn't draw rotateme( \sometxt{sin (x)} ); \stopMPcode Is handling the second situation too complext for the existing mechanism? The solution on "my side" is trivial - I can split the behaviour in the gnuplot module to work in two steps instead in a single one, but perhaps this can be easility fixed as well. Mojca
Mojca Miklavec wrote:
Question, questions and questions again ...
The question from yestarday wasn't a serious one. But this one might get closer. After I've rewritten the context.trm to try the new \sometxt out, I struggled against the following problem:
\startMPcode picture p;
vardef rotateme(expr m) = (m rotated 90) enddef;
% this works p := \sometxt{sin (x)}; draw rotateme(p);
% this doesn't draw rotateme( \sometxt{sin (x)} ); \stopMPcode
Is handling the second situation too complext for the existing mechanism? The solution on "my side" is trivial - I can split the behaviour in the gnuplot module to work in two steps instead in a single one, but perhaps this can be easility fixed as well. it works ok if we remove the ; from the \sometxt macro
\starttext \long\def\sometxt#1{sometxt(nexttxt)} % to be used in mp definitions \startMPcode vardef rotateme(expr m) = (m rotated 90) enddef; picture p; p := \sometxt{$\sin(x)$}; draw rotateme(p); draw rotateme(\sometxt{$\cos(x)$}); \stopMPcode \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
Mojca Miklavec wrote:
Not that I would really need to type in the following example, but if I didn't find something interesting, Hans would accuse me of not taking a look at it at all ;)
\startMPpage draw (0,0)--(5cm,0); draw (0,0)--(5cm,5cm);
picture p; p := \sometxt{\bTABLE \bTR\bTD abc\eTD\bTD xyz\eTD\eTR \bTR\bTD abc\eTD\bTD xyz\eTD\eTR \bTR\bTD abc\eTD\bTD xyz\eTD\eTR \eTABLE}; % or withcolor here
draw p withcolor transparent(1,.5,red); \stopMPpage
(To be honest I wanted to send the following example, but I didn't want to torture: %\startMPpage %draw \sometxt{ % \startCSV % a b c % \stopCSV % } ; %\stopMPpage )
General opinion: AMAZING speed, amazing feature! I love the fact that the labels are typest in the flow of the current document, so now macros defined earlier in the document may be used for labels as well. That's simply great! Also because of the fact that \def's refused to work inside of metafun graphics and no additional runs are needed.
That's far more elegant and way more efficient that the way I would have to go for separating labels from \MPfigs
Hans, that's marvellous! Thanks a lot!
Mojca
Just a side note: I noticed the new database module already in the beta, but the first Hans's fix (before Taco has touched it) introduced a new "tab-bug" which hasn't been quite resolved yet. If "separator=tab", it should trigger catcode change of tab to a "normal letter" and use that one for separating columns. Well, indeed it seems that the catcode is changed, but then I get the letter number 9 in EC font (macron) instead of going to new column.
so what patc is needed
I'm now asking for impossible again, but: any simple/reasonable way to control the baseline/general positioning of the labels? (textext included text with baseline at y=0 by default, the new mechanism simply puts the lower corner to the baseline)
sign, the never satisfied mojca ... added: [n] == nodepth or shift over txtdepth example: \setupcolors[state=start] \starttext \startMPpage draw (0,0)--(5cm,0); draw (0,0)--(5cm,5cm); picture p; p := \sometxt{\bTABLE \bTR\bTD abc\eTD\bTD xyz\eTD\eTR \bTR\bTD abc\eTD\bTD xyz\eTD\eTR \bTR\bTD abc\eTD\bTD xyz\eTD\eTR \eTABLE} ; draw p ; draw \sometxt[n]{nodepth} ; draw \sometxt{depth} ; draw \sometxt{more and more depth} shifted (0,txtdepth) ; \stopMPpage \foundbox\currentTeXtext{1} \stoptext ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com | www.pragma-pod.nl ----------------------------------------------------------------- %D \module %D [ file=mp-txts.mp, %D version=2006.06.08, %D title=\CONTEXT\ \METAPOST\ graphics, %D subtitle=more text support, %D author=Hans Hagen, %D date=\currentdate, %D copyright=PRAGMA] %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_txts : endinput ; fi ; boolean context_txts ; context_txts := true ; %D The real code: string txtfile ; txtfile := "" ; string txtfont ; txtfont := defaultfont ; string txtpref ; txtpref := "00001::::" ; numeric txtnext ; txtnext := 0 ; numeric txtdepth ; txtdepth := 0 ; vardef nexttxt = txtnext := txtnext + 1 ; txtnext enddef ; picture savedtxts[] ; numeric depthtxts[] ; vardef zerofilled(expr fd) = if fd<10: "0000" else : if fd<100: "000" else : if fd<1000: "00" else : if fd<10000: "0" else : fi fi fi fi & decimal fd enddef; vardef savetxt(expr n,w,h,d) text t = depthtxts[n] := d ; savedtxts[n] := ((txtpref & zerofilled(n)) infont txtfont) xysized(w,h+d) t enddef ; vardef sometxt(expr n) = if known savedtxts[n] : txtdepth := depthtxts[n] ; savedtxts[n] else : txtdepth := 0 ; nullpicture fi enddef ; def loadtxts = if txtfile <> "" : readfile(txtfile) ; fi ; enddef ; def StartTexts = loadtxts ; enddef ; def StopTexts = enddef ;
Hans Hagen wrote:
Just a side note: I noticed the new database module already in the beta, but the first Hans's fix (before Taco has touched it) introduced a new "tab-bug" which hasn't been quite resolved yet. If "separator=tab", it should trigger catcode change of tab to a "normal letter" and use that one for separating columns. Well, indeed it seems that the catcode is changed, but then I get the letter number 9 in EC font (macron) instead of going to new column.
so what patc is needed
--- m-database.tex~ 2006-06-19 16:08:51.282834397 +0200 +++ m-database.tex 2006-06-19 16:23:12.886574121 +0200 @@ -178,9 +178,12 @@ {\executeifdefined {\??ls::\csname\??ls\currentseparatedlist\c!separator\endcsname}% {\csname\??ls\currentseparatedlist\c!separator\endcsname}}% + \doifinstringelse{tab} + {\getvalue{\??ls\currentseparatedlist\c!separator}} + {\catcode`\^^I=12 }{}% \ifx\currentlistseparator\empty\def\currentlistseparator{,}\fi} -\setvalue{\??ls::tab}{ } +{\catcode`\^^I=12 \setgvalue{\??ls::tab}{ }} \setvalue{\??ls::space}{ } \setvalue{\??ls::comma}{,}
participants (3)
-
Hans Hagen
-
Mojca Miklavec
-
Taco Hoekwater