ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Joseph Canedo <josephcanedo@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: Change of nuts.dimensions function ?
Date: Thu, 15 Feb 2018 21:29:00 +0100	[thread overview]
Message-ID: <5a85ed86.919cdf0a.e9ed9.6927@mx.google.com> (raw)
In-Reply-To: <4fca553b-447b-69b0-c95e-2bb406d97392@wxs.nl>


[-- Attachment #1.1: Type: text/plain, Size: 2129 bytes --]

Hi Hans,
Thanks a lot, the function nuts.dimensions seems to work again as before.

Another issue I am seeing now is that for some reason the dir nodes push/pop are unbalanced. If I understand the logic of these whatsit nodes they behave like a stack to control the text direction, so I’d assume the number of push nodes and pop nodes is balanced. Currently I see 2 pop for 1 push in shipouts callback (but balanced pop/push nodes in processors callback). If that’s expected from now on I’ll change the logic in my handler.

Simple MWE that reproduces is attached.

Thanks
Best regards

Joseph

De : Hans Hagen
Envoyé le :jeudi 8 février 2018 10:14
À : ntg-context@ntg.nl
Objet :Re: [NTG-context] Change of nuts.dimensions function ?

On 2/7/2018 2:57 PM, Joseph Canedo wrote:
> Hello all,
> 
> It seems that with latest ConTeXt beta (with luatex 1.07.0) it seems 
> that nuts.dimensions function behaviour has changed. Simple MWE shows 
> the change.
> 
> Which function should be used now to get natural width of a range [n, t[ 
> of nodes please?
i'll check it but if you're on windows you're running the (currently 
very) experimental version which can actually be broken in some aspects 
(so you then need to update regularaly)

Hans


-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 4785 bytes --]

[-- Attachment #2: dir.tex --]
[-- Type: application/octet-stream, Size: 1751 bytes --]

\startluacode

local nuts   = nodes.nuts
local tonut  = nuts.tonut
local tonode = nuts.tonode
local getfield = nuts.getfield
local getid = nuts.getid
local getnext = nuts.getnext
local getlist = nuts.getlist

local tasks = nodes.tasks
local nodecodes = nodes.nodecodes
local traverse_id = nuts.traverse_id
local dir_code = nodecodes.dir
local hlist_code = nodecodes.hlist
local vlist_code = nodecodes.vlist

function handler(head)
   local found_dir = false
   head = tonut(head)
   for dir_node in traverse_id(dir_code, head) do
      local dir, level = getfield(dir_node, 'dir'), getfield(dir_node, 'level')
      if not found_dir then print('processor') found_dir = true end
      print('dir=' .. dir .. ' level=' .. level)
   end
   return tonode(head)
end

function list_handler(list, found_dir)
   local n = list
   while n do
      local id = getid(n)
      if id == hlist_code or id == vlist_code then list_handler(getlist(n), found_dir)
      elseif id == dir_code then
         local dir, level = getfield(n, 'dir'), getfield(n, 'level')
         if not found_dir then print('shipout') found_dir = true end
         print('dir=' .. dir .. ' level=' .. level)
      end
      n = getnext(n)
   end
end

function handler2(head)
   head = tonut(head)
   local found_dir = false
   list_handler(head, found_dir)
   return tonode(head)
end

tasks.appendaction("processors", "after", "handler")
tasks.enableaction("processors", "handler")

tasks.appendaction("shipouts", "after", "handler2")
tasks.enableaction("shipouts", "handler2")

\stopluacode

\starttext

Foo {\setupalign[r2l]Right to left} Bar.

Foo {\setupalign[r2l]Right {\setupalign[l2r]Left again} Right} Bar.

\stoptext

[-- Attachment #3: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2018-02-15 20:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-07 13:57 Joseph Canedo
2018-02-08  9:13 ` Hans Hagen
2018-02-15 20:29   ` Joseph Canedo [this message]
2018-02-16 11:06     ` Hans Hagen

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=5a85ed86.919cdf0a.e9ed9.6927@mx.google.com \
    --to=josephcanedo@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).