From: "luigi scarso" <luigi.scarso@gmail.com>
To: "mailing list for ConTeXt users" <ntg-context@ntg.nl>
Subject: Re: ifdim ... or ... else ...
Date: Sun, 14 Sep 2008 16:30:14 +0200 [thread overview]
Message-ID: <fe8d59da0809140730x796c54f4u43cb1001d002ddcc@mail.gmail.com> (raw)
In-Reply-To: <CE4C9D54-0492-4287-9A0A-F89E9C557F3C@gmail.com>
On Sat, Sep 13, 2008 at 2:18 PM, Wolfgang Schuster
<schuster.wolfgang@googlemail.com> wrote:
>
> 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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage : http://www.pragma-ade.nl / http://tex.aanhet.net
archive : https://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___________________________________________________________________________________
prev parent reply other threads:[~2008-09-14 14:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-10 11:49 Steffen Wolfrum
2008-09-10 12:12 ` Thomas A. Schmitz
2008-09-10 12:15 ` Marcin Borkowski
2008-09-10 12:23 ` was: " Steffen Wolfrum
2008-09-10 12:28 ` Wolfgang Schuster
2008-09-10 12:31 ` Hans Hagen
2008-09-10 14:12 ` Wolfgang Schuster
2008-09-10 15:15 ` Hans Hagen
2008-09-13 12:18 ` Wolfgang Schuster
2008-09-13 19:25 ` Hans Hagen
2008-09-14 14:30 ` luigi scarso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fe8d59da0809140730x796c54f4u43cb1001d002ddcc@mail.gmail.com \
--to=luigi.scarso@gmail.com \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).