On Sat, Sep 13, 2008 at 2:18 PM, Wolfgang Schuster
Am 10.09.2008 um 17:15 schrieb Hans Hagen:
newspeak would be using an attribute and postprocessing the node list -)
How could I write this in newspeak:
\newsignal\yesnosignal
\def\yesno{\scratchdimen\lastskip\ifdim\scratchdimen=\yesnosignal YES \else NO\fi}
\starttext
text \hskip\yesnosignal \yesno\ text \hskip\yesnosignal text \yesno\ text
\stoptext
It's no mkiv way (aka "newspeak") . I worked to something like this at Bohinj (I don't know why '25' in an.number==25 ) . I'm not sure that it works, If i have time I will check it . %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def\StudyBox#1#2#3{% \startluacode nodes = nodes or {} local traverse_id = node.traverse_id local head = tex.box[#1].list local m = 0 local hlist, vlist, whatsit,glue = node.id('hlist'), node.id('vlist'), node.id('whatsit'),node.id('glue') local attribute = node.id('attribute') local attributeList = node.id('attribute_list') texio.write_nl(' ** SigStartC='..tostring(tex.count['SignalStartC'])..' SigStopC='..tostring(tex.count['SignalStopC'])..'\n') local SigStartC = #2 or 0 local SigStopC = #3 or 0 local function searchrecursive(head) %%-- if node.type(head.id)== 'rule' then attlist = head.attr %%print("==>",tostring(nodes.serialize(nodes.totable(head)))) for an in node.traverse(attlist) do if node.has_field(an, 'number') and node.has_field(an, 'value') and an.number==25 and an.value==101 then texio.write_nl('SigStartC INCRESEAD'..'\n') SigStartC = SigStartC +1 end if node.has_field(an, 'number') and node.has_field(an, 'value') and an.number==25 and an.value==111 then texio.write_nl('SigStop decresead'..'\n') SigStopC = SigStopC +1 end end %%-- end if node.has_field(head,'list') then %%-- print("ok") for n in node.traverse(head.list) do %%-- print(tostring(n)) searchrecursive(n) end end end texio.write_nl('SigStartC='..SigStartC..' SigStopC='..SigStopC..'\n') searchrecursive(tex.box[#1]) texio.write_nl('SigStartC='..SigStartC..' SigStopC='..SigStopC..'\n') tex.setcount('SignalStartC',SigStartC) tex.setcount('SignalStopC',SigStopC) \stopluacode} \global\newcount\SignalStartC \global\newcount\SignalStopC \defineattribute[SigStart] \def\SignalStart{\hbox attr\dogetattributeid{SigStart}=101 to 0sp {\vrule width 0sp height0sp depth0sp}} \def\SignalStop{\hbox attr\dogetattributeid{SigStart}=111 to 0sp {\vrule width 0sp height0sp depth0sp}} \starttext \setbox100=\vbox{ \nobreak\SignalStart\nobreak Some text . \nobreak\SignalStop\nobreak } \StudyBox{100}{\the\SignalStartC}{\the\SignalStopC}% end \stoptext %%%%%%%%%%%%%%%% See log and output for some -- luigi