summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2006-04-22 10:41:00 +0200
committerHans Hagen <pragma@wxs.nl>2006-04-22 10:41:00 +0200
commit344364dee440fb66701665e8389445755c7d00f2 (patch)
tree58681cf1fe6b2c2472f84c38aee6090338703cb1
parent7fe03c832e11f626335835ccbe3b48149f1ccac6 (diff)
downloadcontext-344364dee440fb66701665e8389445755c7d00f2.tar.gz
stable 2006.04.22 10:41
-rw-r--r--scripts/context/ruby/base/ctx.rb64
-rw-r--r--scripts/context/ruby/base/kpse.rb16
-rw-r--r--scripts/context/ruby/base/kpsedirect.rb16
-rw-r--r--scripts/context/ruby/base/kpsefast.rb25
-rw-r--r--scripts/context/ruby/base/kpseremote.rb19
-rw-r--r--scripts/context/ruby/base/switch.rb23
-rw-r--r--scripts/context/ruby/base/tex.rb95
-rw-r--r--scripts/context/ruby/base/texutil.rb47
-rw-r--r--scripts/context/ruby/texmfstart.rb12
-rw-r--r--scripts/context/ruby/xmltools.rb190
-rw-r--r--tex/context/base/cont-new.tex2
-rw-r--r--tex/context/base/context.tex5
-rw-r--r--tex/context/base/core-fig.tex2
-rw-r--r--tex/context/base/core-itm.tex206
-rw-r--r--tex/context/base/core-mat.tex255
-rw-r--r--tex/context/base/core-not.tex77
-rw-r--r--tex/context/base/core-ntb.tex176
-rw-r--r--tex/context/base/core-num.tex16
-rw-r--r--tex/context/base/core-pgr.tex1651
-rw-r--r--tex/context/base/core-pos.tex1923
-rw-r--r--tex/context/base/core-rul.tex16
-rw-r--r--tex/context/base/core-sec.tex162
-rw-r--r--tex/context/base/core-spa.tex2
-rw-r--r--tex/context/base/m-streams.tex38
-rw-r--r--tex/context/base/m-visual.tex21
-rw-r--r--tex/context/base/meta-dum.tex12
-rw-r--r--tex/context/base/meta-pag.tex21
-rw-r--r--tex/context/base/page-flt.tex303
-rw-r--r--tex/context/base/page-mul.tex24
-rw-r--r--tex/context/base/page-num.tex2
-rw-r--r--tex/context/base/page-set.tex26
-rw-r--r--tex/context/base/spec-dpx.tex6
-rw-r--r--tex/context/base/spec-dvi.tex4
-rw-r--r--tex/context/base/supp-box.tex33
-rw-r--r--tex/context/base/unic-ini.tex2
-rw-r--r--tex/context/base/verb-c.tex483
-rw-r--r--tex/context/base/verb-ini.tex17
-rw-r--r--tex/context/base/x-fig-01.tex8
-rw-r--r--tex/context/base/x-newcml.tex6
-rw-r--r--tex/context/base/x-newmml.tex104
-rw-r--r--tex/context/base/x-openmath.tex4
-rw-r--r--tex/context/base/x-res-01.tex65
-rw-r--r--tex/context/base/x-xml-11.tex44
-rw-r--r--tex/context/base/xtag-mmc.tex4
-rw-r--r--tex/context/interface/cont-cz.xml2
-rw-r--r--tex/context/interface/cont-de.xml2
-rw-r--r--tex/context/interface/cont-en.xml2
-rw-r--r--tex/context/interface/cont-fr.xml2
-rw-r--r--tex/context/interface/cont-it.xml2
-rw-r--r--tex/context/interface/cont-nl.xml2
-rw-r--r--tex/context/interface/cont-ro.xml2
-rw-r--r--tex/context/interface/keys-cz.xml2
-rw-r--r--tex/context/interface/keys-de.xml2
-rw-r--r--tex/context/interface/keys-en.xml2
-rw-r--r--tex/context/interface/keys-fr.xml2
-rw-r--r--tex/context/interface/keys-it.xml2
-rw-r--r--tex/context/interface/keys-nl.xml2
-rw-r--r--tex/context/interface/keys-ro.xml2
58 files changed, 3744 insertions, 2511 deletions
diff --git a/scripts/context/ruby/base/ctx.rb b/scripts/context/ruby/base/ctx.rb
index b1fda3c3a..6c8dd5a44 100644
--- a/scripts/context/ruby/base/ctx.rb
+++ b/scripts/context/ruby/base/ctx.rb
@@ -52,17 +52,43 @@ class CtxRunner
end
if not @ctxname then
- report('provide ctx file')
+ report('no ctx file specified')
return
end
- if not FileTest.file?(@ctxname) and defaultname and FileTest.file?(defaultname) then
- @ctxname = defaultname
- end
+ # name can be kpse:res-make.ctx
if not FileTest.file?(@ctxname) then
- report('provide ctx file')
- return
+ fullname, done = '', false
+ if @ctxname =~ /^kpse:/ then
+ begin
+ if fullname = Kpse.found(@ctxname.sub(/^kpse:/,'')) then
+ @ctxname, done = fullname, true
+ end
+ rescue
+ # should not happen
+ end
+ else
+ ['..','../..'].each do |path|
+ begin
+ fullname = File.join(path,@ctxname)
+ if FileTest.file?(fullname) then
+ @ctxname, done = fullname, true
+ end
+ rescue
+ # probably strange join
+ end
+ break if done
+ end
+ end
+ if ! done && defaultname && FileTest.file?(defaultname) then
+ report("using default ctxfile #{defaultname}")
+ @ctxname = defaultname
+ end
+ if not done then
+ report('no ctx file found')
+ return false
+ end
end
@xmldata = IO.read(@ctxname)
@@ -196,17 +222,27 @@ class CtxRunner
name = e.attributes.get_attribute(attribute).to_s
name = e.text.to_s if name.empty?
name.strip! if name
- if name and not name.empty? and FileTest.file?(name) then
- if f = File.open(name,'r') and i = REXML::Document.new(f) then
- report("including ctx file #{name}")
- REXML::XPath.each(i.root,"*") do |ii|
- xmldata.root.insert_after(e,ii)
- more = true
+ done = false
+ if name and not name.empty? then
+ ['.',File.dirname(@ctxname),'..','../..'].each do |path|
+ begin
+ fullname = if path == '.' then name else File.join(path,name) end
+ if FileTest.file?(fullname) then
+ if f = File.open(fullname,'r') and i = REXML::Document.new(f) then
+ report("including ctx file #{name}")
+ REXML::XPath.each(i.root,"*") do |ii|
+ xmldata.root.insert_after(e,ii)
+ more = true
+ end
+ end
+ done = true
+ end
+ rescue
end
end
- else
- report("no valid ctx inclusion file #{name}")
+ break if done
end
+ report("no valid ctx inclusion file #{name}") unless done
rescue Exception
# skip this file
ensure
diff --git a/scripts/context/ruby/base/kpse.rb b/scripts/context/ruby/base/kpse.rb
index d05600b8f..0e3292d00 100644
--- a/scripts/context/ruby/base/kpse.rb
+++ b/scripts/context/ruby/base/kpse.rb
@@ -18,6 +18,18 @@ require 'rbconfig'
#
# miktex has mem|fmt|base paths
+class String
+
+ def split_path
+ self.split(/\:\;/)
+ end
+
+ def join_path
+ self.join(FILE::PATH_SEPARATOR)
+ end
+
+end
+
module Kpse
@@located = Hash.new
@@ -138,7 +150,7 @@ module Kpse
# maybe we should check for writeability
unless @@paths.key?('formatpaths') then
begin
- setpath('formatpaths',run("--show-path=fmt").gsub(/\\/,'/').split(File::PATH_SEPARATOR))
+ setpath('formatpaths',run("--show-path=fmt").gsub(/\\/,'/').split_path)
rescue
setpath('formatpaths',[])
end
@@ -195,7 +207,7 @@ module Kpse
end
# locate writable path
if ! formatpath.empty? then
- formatpath.split(File::PATH_SEPARATOR).each do |fp|
+ formatpath.split_path.each do |fp|
fp.gsub!(/\\/,'/')
# remove funny patterns
fp.sub!(/^!!/,'')
diff --git a/scripts/context/ruby/base/kpsedirect.rb b/scripts/context/ruby/base/kpsedirect.rb
index d38e892b1..6fa8c8601 100644
--- a/scripts/context/ruby/base/kpsedirect.rb
+++ b/scripts/context/ruby/base/kpsedirect.rb
@@ -3,21 +3,19 @@ class KpseDirect
attr_accessor :progname, :format, :engine
def initialize
- @progname = ''
- @format = ''
- @engine = ''
+ @progname, @format, @engine = '', '', ''
end
def expand_path(str)
- `kpsewhich -expand-path=#{str}`.chomp
+ clean_name(`kpsewhich -expand-path=#{str}`.chomp)
end
def expand_var(str)
- `kpsewhich -expand-var=#{str}`.chomp
+ clean_name(`kpsewhich -expand-var=#{str}`.chomp)
end
def find_file(str)
- `kpsewhich #{_progname_} #{_format_} #{str}`.chomp
+ clean_name(`kpsewhich #{_progname_} #{_format_} #{str}`.chomp)
end
def _progname_
@@ -27,4 +25,10 @@ class KpseDirect
if @format.empty? then '' else "-format=\"#{@format}\"" end
end
+ private
+
+ def clean_name(str)
+ str.gsub(/\\/,'/')
+ end
+
end
diff --git a/scripts/context/ruby/base/kpsefast.rb b/scripts/context/ruby/base/kpsefast.rb
index 231c6221c..dbc9f55e8 100644
--- a/scripts/context/ruby/base/kpsefast.rb
+++ b/scripts/context/ruby/base/kpsefast.rb
@@ -50,7 +50,7 @@ module KpseUtil
end
filenames = Array.new
if ENV['TEXMFCNF'] and not ENV['TEXMFCNF'].empty? then
- ENV['TEXMFCNF'].split(File::PATH_SEPARATOR).each do |path|
+ ENV['TEXMFCNF'].split_path.each do |path|
filenames << File.join(path,@@texmfcnf)
end
elsif ENV['SELFAUTOPARENT'] == '.' then
@@ -79,6 +79,18 @@ module KpseUtil
end
+class String
+
+ def split_path
+ self.split(/\:\;/)
+ end
+
+ def join_path
+ self.join(FILE::PATH_SEPARATOR)
+ end
+
+end
+
class KpseFast
# formats are an incredible inconsistent mess
@@ -281,7 +293,7 @@ class KpseFast
end
filenames = Array.new
if @environment['TEXMFCNF'] and not @environment['TEXMFCNF'].empty? then
- @environment['TEXMFCNF'].split(File::PATH_SEPARATOR).each do |path|
+ @environment['TEXMFCNF'].split_path.each do |path|
filenames << File.join(path,@@texmfcnf)
end
elsif @environment['SELFAUTOPARENT'] == '.' then
@@ -600,7 +612,7 @@ class KpseFast
puts ""
puts @variables ["KPSE_TEST_PATTERN_#{i}"]
puts ""
- puts expand_path("KPSE_TEST_PATTERN_#{i}").split(File::PATH_SEPARATOR)
+ puts expand_path("KPSE_TEST_PATTERN_#{i}").split_path
puts ""
end
end
@@ -612,11 +624,11 @@ class KpseFast
# kpse stuff
def expand_braces(str) # output variable and brace expansion of STRING.
- _expanded_path_(original_variable(str).split(";")).join(File::PATH_SEPARATOR)
+ _expanded_path_(original_variable(str).split_path).join_path
end
def expand_path(str) # output complete path expansion of STRING.
- _expanded_path_(expanded_variable(str).split(";")).join(File::PATH_SEPARATOR)
+ _expanded_path_(expanded_variable(str).split_path).join_path
end
def expand_var(str) # output variable expansion of STRING.
@@ -624,8 +636,7 @@ class KpseFast
end
def show_path(str) # output search path for file type NAME
- # expanded_path(var_of_format(str)).join(File::PATH_SEPARATOR)
- expanded_path(str).join(File::PATH_SEPARATOR)
+ expanded_path(str).join_path
end
def var_value(str) # output the value of variable $STRING.
diff --git a/scripts/context/ruby/base/kpseremote.rb b/scripts/context/ruby/base/kpseremote.rb
index f5a72b712..f1f3cb10f 100644
--- a/scripts/context/ruby/base/kpseremote.rb
+++ b/scripts/context/ruby/base/kpseremote.rb
@@ -80,25 +80,32 @@ class KpseRemote
@kpse.expand_variables(@tree)
end
def expand_braces(str)
- @kpse.expand_braces(@tree,str)
+ clean_name(@kpse.expand_braces(@tree,str))
end
def expand_path(str)
- @kpse.expand_path(@tree,str)
+ clean_name(@kpse.expand_path(@tree,str))
end
def expand_var(str)
- @kpse.expand_var(@tree,str)
+ clean_name(@kpse.expand_var(@tree,str))
end
def show_path(str)
- @kpse.show_path(@tree,str)
+ clean_name(@kpse.show_path(@tree,str))
end
def var_value(str)
- @kpse.var_value(@tree,str)
+ clean_name(@kpse.var_value(@tree,str))
end
def find_file(filename)
- @kpse.find_file(@tree,filename)
+ clean_name(@kpse.find_file(@tree,filename))
end
def find_files(filename,first=false)
+ # dodo: each filename
@kpse.find_files(@tree,filename,first)
end
+ private
+
+ def clean_name(str)
+ str.gsub(/\\/,'/')
+ end
+
end
diff --git a/scripts/context/ruby/base/switch.rb b/scripts/context/ruby/base/switch.rb
index 160b50aba..3113ad4d6 100644
--- a/scripts/context/ruby/base/switch.rb
+++ b/scripts/context/ruby/base/switch.rb
@@ -33,13 +33,26 @@ end
class File
+ # def File.needsupdate(oldname,newname)
+ # begin
+ # if $mswindows then # we cannot use != due to some rounding error
+ # return File.stat(oldname).mtime > File.stat(newname).mtime
+ # else
+ # return File.stat(oldname).mtime != File.stat(newname).mtime
+ # end
+ # rescue
+ # return true
+ # end
+ # end
+
+ @@update_eps = 1
+
def File.needsupdate(oldname,newname)
begin
- if $mswindows then
- return File.stat(oldname).mtime > File.stat(newname).mtime
- else
- return File.stat(oldname).mtime != File.stat(newname).mtime
- end
+ oldtime = File.stat(oldname).mtime.to_i
+ newtime = File.stat(newname).mtime.to_i
+ delta = newtime - oldtime
+ (delta > @@update_eps) || (-delta > @@update_eps)
rescue
return true
end
diff --git a/scripts/context/ruby/base/tex.rb b/scripts/context/ruby/base/tex.rb
index 0d1e01b95..5e9a9566f 100644
--- a/scripts/context/ruby/base/tex.rb
+++ b/scripts/context/ruby/base/tex.rb
@@ -781,32 +781,33 @@ class TEX
if tmp = openedfile(File.suffixed(rawname,'run')) then
tmp << "\\starttext\n"
if forcexml then
- if FileTest.file?(rawname) && (xml = File.open(rawname)) then
- xml.each do |line|
- case line
- when /<\?context\-directive\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*?)\s*\?>/o then
- category, key, value, rest = $1, $2, $3, $4
- case category
- when 'job' then
- case key
- when 'control' then
- setvariable(value,if rest.empty? then true else rest end)
- when 'mode', 'modes' then
- tmp << "\\enablemode[#{value}]\n"
- when 'stylefile', 'environment' then
- tmp << "\\environment #{value}\n"
- when 'module' then
- tmp << "\\usemodule[#{value}]\n"
- when 'interface' then
- contextinterface = value
- end
- end
- when /<[a-z]+/io then # beware of order, first pi test
- break
- end
- end
- xml.close
- end
+ # if FileTest.file?(rawname) && (xml = File.open(rawname)) then
+ # xml.each do |line|
+ # case line
+ # when /<\?context\-directive\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*?)\s*\?>/o then
+ # category, key, value, rest = $1, $2, $3, $4
+ # case category
+ # when 'job' then
+ # case key
+ # when 'control' then
+ # setvariable(value,if rest.empty? then true else rest end)
+ # when 'mode', 'modes' then
+ # tmp << "\\enablemode[#{value}]\n"
+ # when 'stylefile', 'environment' then
+ # tmp << "\\environment #{value}\n"
+ # when 'module' then
+ # tmp << "\\usemodule[#{value}]\n"
+ # when 'interface' then
+ # contextinterface = value
+ # end
+ # end
+ # when /<[a-z]+/io then # beware of order, first pi test
+ # break
+ # end
+ # end
+ # xml.close
+ # end
+ tmp << checkxmlfile(rawname)
tmp << "\\processXMLfilegrouped{#{rawname}}\n"
else
tmp << "\\processfile{#{rawname}}\n"
@@ -819,6 +820,40 @@ class TEX
end
end
+ def checkxmlfile(rawname)
+ tmp = ''
+ if FileTest.file?(rawname) && (xml = File.open(rawname)) then
+ xml.each do |line|
+ case line
+ when /<\?context\-directive\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*?)\s*\?>/o then
+ category, key, value, rest = $1, $2, $3, $4
+ case category
+ when 'job' then
+ case key
+ when 'control' then
+ setvariable(value,if rest.empty? then true else rest end)
+ when 'mode', 'modes' then
+ tmp << "\\enablemode[#{value}]\n"
+ when 'stylefile', 'environment' then
+ tmp << "\\environment #{value}\n"
+ when 'module' then
+ tmp << "\\usemodule[#{value}]\n"
+ when 'interface' then
+ contextinterface = value
+ when 'ctxfile' then
+ setvariable('ctxfile', value)
+ report("using source driven ctxfile #{value}")
+ end
+ end
+ when /<[a-z]+/io then # beware of order, first pi test
+ break
+ end
+ end
+ xml.close
+ end
+ return tmp
+ end
+
end
class TEX
@@ -1154,7 +1189,7 @@ checktestversion
begin
logger = Logger.new('TeXUtil')
if tu = TeXUtil::Converter.new(logger) and tu.loaded(fname) then
- tu.saved if tu.processed
+ ok = tu.processed && tu.saved && tu.finalized
end
rescue
Kpse.runscript('texutil',fname,options)
@@ -1289,6 +1324,8 @@ checktestversion
end
end
+ jobsuffix = makestubfile(rawname,forcexml) if dummyfile || forcexml
+
# preprocess files
unless getvariable('noctx') then
@@ -1321,8 +1358,6 @@ checktestversion
# end of preprocessing and merging
- jobsuffix = makestubfile(rawname,forcexml) if dummyfile || forcexml
-
if globalfile || FileTest.file?(rawname) then
if not dummyfile and not globalfile then
@@ -1435,6 +1470,8 @@ checktestversion
PDFview.open(File.suffixed(if result.empty? then rawname else result end,'pdf'))
end
+ else
+ report("nothing to process")
end
end
diff --git a/scripts/context/ruby/base/texutil.rb b/scripts/context/ruby/base/texutil.rb
index 583aa6bbf..86de0ee91 100644
--- a/scripts/context/ruby/base/texutil.rb
+++ b/scripts/context/ruby/base/texutil.rb
@@ -122,6 +122,16 @@ class TeXUtil
end
end
+ def finalizers
+ @plugins.each do |p|
+ begin
+ eval("#{p}").finalizer(@logger)
+ rescue Exception
+ @logger.report("fatal error in plugin finalizer #{p} (#{$!})")
+ end
+ end
+ end
+
end
class Sorter
@@ -342,6 +352,9 @@ end
end
end
+ def MyFiles::finalizer(logger)
+ end
+
end
end
@@ -370,6 +383,9 @@ end
def MyCommands::processor(logger)
end
+ def MyCommands::finalizer(logger)
+ end
+
end
end
@@ -400,6 +416,14 @@ end
def MyExtras::processor(logger)
@@programs.each do |p|
+ # cmd = @@programs[p.to_i]
+ # logger.report("running #{cmd}")
+ # system(cmd)
+ end
+ end
+
+ def MyExtras::finalizer(logger)
+ @@programs.each do |p|
cmd = @@programs[p.to_i]
logger.report("running #{cmd}")
system(cmd)
@@ -486,6 +510,9 @@ end
end
end
+ def MySynonyms::finalizer(logger)
+ end
+
end
end
@@ -742,6 +769,9 @@ end
end
end
+ def MyRegisters::finalizer(logger)
+ end
+
end
end
@@ -779,6 +809,10 @@ end
@@plugins.processors if @@plugins
end
+ def MyPlugins::finalizer(logger)
+ @@plugins.finalizers if @@plugins
+ end
+
end
end
@@ -832,6 +866,9 @@ end
logger.report("divisions : #{@@divisions.size}") # logger.report(@@divisions.inspect)
end
+ def MyKeys::finalizer(logger)
+ end
+
end
end
@@ -898,19 +935,27 @@ end
def saved(filename=@filename)
if @fatalerror then
report("fatal error, no tuo file saved")
+ return false
else
- begin
+ begin
if f = File.open(File.suffixed(filename,'tuo'),'w') then
@plugins.writers(f)
f.close
end
rescue
report("fatal error when saving file (#{$!})")
+ return false
else
report("tuo file saved")
+ return true
end
end
+ end
+
+ def finalized
+ @plugins.finalizers
@plugins.resets
+ return true # for the moment
end
def reset
diff --git a/scripts/context/ruby/texmfstart.rb b/scripts/context/ruby/texmfstart.rb
index 72c90ad8f..676b4351c 100644
--- a/scripts/context/ruby/texmfstart.rb
+++ b/scripts/context/ruby/texmfstart.rb
@@ -321,10 +321,10 @@ def expanded(arg) # no "other text files", too restricted
method, original, resolved = $1, $2, ''
if $program && ! $program.empty? then
# pstrings = ["-progname=#{$program}"]
-pstrings = [$program]
+ pstrings = [$program]
else
# pstrings = ['','-progname=context']
-pstrings = ['','context']
+ pstrings = ['','context']
end
# auto suffix with texinputs as fall back
if ENV["_CTX_K_V_#{original}_"] then
@@ -342,7 +342,7 @@ pstrings = ['','context']
# resolved = `#{command}`.chomp
$kpse.progname = pstr
$kpse.format = ''
- resolved = $kpse.find_file(original)
+ resolved = $kpse.find_file(original).gsub(/\\/,'/')
rescue
resolved = ''
end
@@ -356,7 +356,7 @@ pstrings = ['','context']
# resolved = `#{command}`.chomp
$kpse.progname = pstr
$kpse.format = 'other text files'
- resolved = $kpse.find_file(original)
+ resolved = $kpse.find_file(original).gsub(/\\/,'/')
rescue
resolved = ''
end
@@ -599,7 +599,7 @@ def find(filename,program)
report("using 'kpsewhich' to locate '#{filename}' in suffix space '#{suffix}' (1)")
# fullname = `kpsewhich -progname=#{program} -format=texmfscripts #{filename}.#{suffix}`.chomp
$kpse.format = 'texmfscripts'
- fullname = $kpse.find_file("#{filename}.#{suffix}")
+ fullname = $kpse.find_file("#{filename}.#{suffix}").gsub(/\\/,'/')
rescue
report("kpsewhich cannot locate '#{filename}' in suffix space '#{suffix}' (1)")
fullname = nil
@@ -612,7 +612,7 @@ def find(filename,program)
report("using 'kpsewhich' to locate '#{filename}' in suffix space '#{suffix}' (2)")
# fullname = `kpsewhich -progname=#{program} -format="other text files" #{filename}.#{suffix}`.chomp
$kpse.format = 'other text files'
- fullname = $kpse.find_file("#{filename}.#{suffix}")
+ fullname = $kpse.find_file("#{filename}.#{suffix}").gsub(/\\/,'/')
rescue
report("kpsewhich cannot locate '#{filename}' in suffix space '#{suffix}' (2)")
fullname = nil
diff --git a/scripts/context/ruby/xmltools.rb b/scripts/context/ruby/xmltools.rb
index a57f74450..97b572e19 100644
--- a/scripts/context/ruby/xmltools.rb
+++ b/scripts/context/ruby/xmltools.rb
@@ -10,13 +10,16 @@
# info : j.hagen@xs4all.nl
# www : www.pragma-ade.com
+# todo : use kpse lib
+
# This script will harbor some handy manipulations on tex
# related files.
-banner = ['XMLTools', 'version 1.1.1', '2002/2005', 'PRAGMA ADE/POD']
+banner = ['XMLTools', 'version 1.2.0', '2002/2006', 'PRAGMA ADE/POD']
unless defined? ownpath
ownpath = $0.sub(/[\\\/][a-z0-9\-]*?\.rb/i,'')
+ # ownpath = File.dirname($0)
$: << ownpath
end
@@ -235,77 +238,150 @@ class Commands
def analyze
- file = @commandline.argument('first')
- result = @commandline.option('output')
+ file = @commandline.argument('first')
+ result = @commandline.option('output')
+ utf = @commandline.option('utf')
+ process = @commandline.option('process')
if FileTest.file?(file) then
if data = IO.read(file) then
- report("xml file #{file} loaded")
- elements = Hash.new
- attributes = Hash.new
- entities = Hash.new
- data.scan(/<([^>\s\/\!\?]+)([^>]*?)>/o) do
- element, attributelist = $1, $2
- if elements.key?(element) then
- elements[element] += 1
- else
- elements[element] = 1
- end
- attributelist.scan(/\s*([^\=]+)\=([\"\'])(.*?)(\2)/) do
- key, value = $1, $3
- attributes[element] = Hash.new unless attributes.key?(element)
- attributes[element][key] = Hash.new unless attributes[element].key?(key)
- if attributes[element][key].key?(value) then
- attributes[element][key][value] += 1
+ if data =~ /<?xml.*?version\=/ then
+ report("xml file #{file} loaded")
+ elements = Hash.new
+ attributes = Hash.new
+ entities = Hash.new
+ chars = Hash.new
+ unicodes = Hash.new
+ names = Hash.new
+ data.scan(/<([^>\s\/\!\?]+)([^>]*?)>/o) do
+ element, attributelist = $1, $2
+ if elements.key?(element) then
+ elements[element] += 1
else
- attributes[element][key][value] = 1
+ elements[element] = 1
+ end
+ attributelist.scan(/\s*([^\=]+)\=([\"\'])(.*?)(\2)/) do
+ key, value = $1, $3
+ attributes[element] = Hash.new unless attributes.key?(element)
+ attributes[element][key] = Hash.new unless attributes[element].key?(key)
+ if attributes[element][key].key?(value) then
+ attributes[element][key][value] += 1
+ else
+ attributes[element][key][value] = 1
+ end
end
end
- end
- data.scan(/\&([^\;]+)\;/o) do
- entity = $1
- if entities.key?(entity) then
- entities[entity] += 1
- else
- entities[entity] = 1
+ data.scan(/\&([^\;]+)\;/o) do
+ entity = $1
+ if entities.key?(entity) then
+ entities[entity] += 1
+ else
+ entities[entity] = 1
+ end
end
- end
- result = file.gsub(/\..*?$/, '') + '.xlg' if result.empty?
- if f = File.open(result,'w') then
- report("saving report in #{result}")
- f.puts "<?xml version='1.0'?>\n"
- f.puts "<document>\n"
- if entities.length>0 then
- f.puts " <entities>\n"
- entities.keys.asort.each do |entity|
- f.puts " <entity name=#{entity.xstring} n=#{entities[entity].to_s.xstring}/>\n"
+ if utf then
+ data.scan(/(\w)/u) do
+ chars[$1] = (chars[$1] || 0) + 1
+ end
+ if chars.size > 0 then
+ begin
+ # todo : use kpse lib
+ filename, ownpath, foundpath = 'contextnames.txt', File.dirname($0), ''
+ begin
+ foundpath = File.dirname(`kpsewhich -progname=context -format=\"other text files\" #{filename}`.chomp)
+ rescue
+ foundpath = '.'
+ else
+ foundpath = '.' if foundpath.empty?
+ end
+ [foundpath,ownpath,File.join(ownpath,'../../../context/data')].each do |path|
+ fullname = File.join(path,filename)
+ if FileTest.file?(fullname) then
+ report("loading '#{fullname}'")
+ # rough scan, we assume no valid lines after comments
+ IO.read(fullname).scan(/^([0-9A-F][0-9A-F][0-9A-F][0-9A-F])\s*\;\s*(.*?)\s*\;\s*(.*?)\s*\;\s*(.*?)\s*$/) do
+ names[$1.hex.to_i.to_s] = [$2,$3,$4]
+ end
+ break
+ end
+ end
+ rescue
+ end
end
- f.puts " </entities>\n"
end
- if elements.length>0 then
- f.puts " <elements>\n"
- elements.keys.sort.each do |element|
- if attributes.key?(element) then
- f.puts " <element name=#{element.xstring} n=#{elements[element].to_s.xstring}>\n"
+ result = file.gsub(/\..*?$/, '') + '.xlg' if result.empty?
+ if f = File.open(result,'w') then
+ report("saving report in #{result}")
+ f.puts "<?xml version='1.0'?>\n"
+ f.puts "<document>\n"
+ if entities.length>0 then
+ total = 0
+ entities.each do |k,v|
+ total += v
+ end
+ f.puts " <entities n=#{total.to_s.xstring}>\n"
+ entities.keys.asort.each do |entity|
+ f.puts " <entity name=#{entity.xstring} n=#{entities[entity].to_s.xstring}/>\n"
+ end
+ f.puts " </entities>\n"
+ end
+ if utf && (chars.size > 0) then
+ total = 0
+ chars.each do |k,v|
+ total += v
+ end
+ f.puts " <characters n=#{total.to_s.xstring}>\n"
+ chars.each do |k,v|
+ if k.length > 1 then
+ begin
+ u = k.unpack('U')
+ unicodes[u] = (unicodes[u] || 0) + v
+ rescue
+ report("invalid utf codes")
+ end
+ end
+ end
+ unicodes.keys.sort.each do |u|
+ ustr = u.to_s
+ if names[ustr] then
+ f.puts " <character number=#{ustr.xstring} pname=#{names[ustr][0].xstring} cname=#{names[ustr][1].xstring} uname=#{names[ustr][2].xstring} n=#{unicodes[u].to_s.xstring}/>\n"
+ else
+ f.puts " <character number=#{ustr.xstring} n=#{unicodes[u].to_s.xstring}/>\n"
+ end
+ end
+ f.puts " </characters>\n"
+ end
+ if elements.length>0 then
+ f.puts " <elements>\n"
+ elements.keys.sort.each do |element|
if attributes.key?(element) then
- attributes[element].keys.asort.each do |attribute|
- f.puts " <attribute name=#{attribute.xstring}>\n"
- attributes[element][attribute].keys.asort.each do |value|
- f.puts " <instance value=#{value.xstring} n=#{attributes[element][attribute][value].to_s.xstring}/>\n"
+ f.puts " <element name=#{element.xstring} n=#{elements[element].to_s.xstring}>\n"
+ if attributes.key?(element) then
+ attributes[element].keys.asort.each do |attribute|
+ f.puts " <attribute name=#{attribute.xstring}>\n"
+ attributes[element][attribute].keys.asort.each do |value|
+ f.puts " <instance value=#{value.xstring} n=#{attributes[element][attribute][value].to_s.xstring}/>\n"
+ end
+ f.puts " </attribute>\n"
end
- f.puts " </attribute>\n"
end
+ f.puts " </element>\n"
+ else
+ f.puts " <element name=#{element.xstring} n=#{elements[element].to_s.xstring}/>\n"
end
- f.puts " </element>\n"
- else
- f.puts " <element name=#{element.xstring} n=#{elements[element].to_s.xstring}/>\n"
end
+ f.puts " </elements>\n"
+ end
+ f.puts "</document>\n"
+ f.close
+ if process then
+ system("texmfstart texexec --purgeall --pdf --use=xml-analyze #{result}")
end
- f.puts " </elements>\n"
+ else
+ report("unable to open file '#{result}'")
end
- f.puts "</document>\n"
else
- report("unable to open file '#{result}'")
+ report("invalid xml file '#{file}'")
end
else
report("unable to load file '#{file}'")
@@ -322,7 +398,7 @@ commandline = CommandLine.new
commandline.registeraction('dir', 'generate directory listing')
commandline.registeraction('mmlpages','generate graphic from mathml')
-commandline.registeraction('analyze', 'report entities and elements')
+commandline.registeraction('analyze', 'report entities and elements [--utf --process]')
# commandline.registeraction('dir', 'filename --pattern= --output= [--recurse --stripname --longname --url --root]')
# commandline.registeraction('mmlpages','filename [--eps --jpg --png --style= --mode=]')
@@ -344,6 +420,8 @@ commandline.registervalue('root')
commandline.registerflag('eps')
commandline.registerflag('png')
commandline.registerflag('jpg')
+commandline.registerflag('utf')
+commandline.registerflag('process')
commandline.registervalue('style')
commandline.registervalue('modes')
diff --git a/tex/context/base/cont-new.tex b/tex/context/base/cont-new.tex
index b94f54ce4..5138aed32 100644
--- a/tex/context/base/cont-new.tex
+++ b/tex/context/base/cont-new.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2006.04.10 20:04}
+\newcontextversion{2006.04.22 10:41}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context.tex b/tex/context/base/context.tex
index 30070c479..2c99a187e 100644
--- a/tex/context/base/context.tex
+++ b/tex/context/base/context.tex
@@ -31,7 +31,7 @@
%D 2004.8.30 the low level interface is english. Watch out and adapt
%D your styles an modules.
-\def\contextversion{2006.04.10 20:04}
+\def\contextversion{2006.04.22 10:41}
%D For those who want to use this:
@@ -253,6 +253,7 @@
\input core-syn.tex
\input core-spa.tex
\input core-sys.tex
+\input core-pos.tex
\input page-ini.tex
\input page-not.tex
@@ -296,7 +297,7 @@
%D On which the next one depends:
-\input core-pos.tex
+\input core-pgr.tex
\input core-bar.tex
\input core-snc.tex
diff --git a/tex/context/base/core-fig.tex b/tex/context/base/core-fig.tex
index 3edc1413d..909dbbaf7 100644
--- a/tex/context/base/core-fig.tex
+++ b/tex/context/base/core-fig.tex
@@ -1156,7 +1156,7 @@
% up in files, therefore:
\let\@@efobject\v!no
\fi
- \edef\@@efobjectname{\@@effilename-\@@eftype-\@@effiletype-\@@efpage}%
+ \edef\@@efobjectname{\@@effilename-\@@eftype-\@@effiletype-\@@efpage}% will be configurable
\doifelse\@@efobject\v!no
\donefalse
{\doifspecialavailableelse\dostartscaling
diff --git a/tex/context/base/core-itm.tex b/tex/context/base/core-itm.tex
index f84bd9960..96c2d5817 100644
--- a/tex/context/base/core-itm.tex
+++ b/tex/context/base/core-itm.tex
@@ -79,7 +79,7 @@
% #1=level #2=parameter
\def\getitemparameter #1#2{\csname\??op\currentitemgroup#1#2\endcsname}
-\def\setitemparameter #1#2{\@EA\def\csname\??op\currentitemgroup#1#2\endcsname}
+\def\setitemparameter #1#2{\@EA\def\csname\??op\currentitemgroup#1#2\endcsname} % #3 -> {#3}
\def\letitemparameter #1#2{\@EA\let\csname\??op\currentitemgroup#1#2\endcsname}
% test this: saves hash entries and is also faster
@@ -195,7 +195,7 @@
\v!serried*=>\setitemparameter{#1}\c!factor{-1},
#2#3*\v!serried*=>\setitemparameter{#1}\c!factor{-#2#3},
#2*\v!serried*=>\setitemparameter{#1}\c!factor{-#2},
- \v!stopper*=>\setitemparameter{#1}\c!placestopper\v!yes,
+ \v!stopper*=>\setitemparameter{#1}\c!placestopper{\v!yes}, % keep {}
\v!unpacked*=>\setfalse\packlistitem,
\v!repeat*=>\settrue\repeatlistitem, % new
\v!standard*=>\dosetupstandarditemgroup{#1}]}
@@ -220,21 +220,11 @@
\letitemparameter{#1}\c!after \empty
\letitemparameter{#1}\c!inbetween \empty}
-% \def\dosetupitemgroupconstant[#1][#2]%
-% {\def\dodosetupitemgroupconstant##1%
-% {\dododosetupitemgroupconstant[#1][##1*]}%
-% \processcommacommand[#2]\dodosetupitemgroupconstant} % expansion of #2 is handy for xml
-
\def\dosetupitemgroupconstant[#1][#2]%
{\def\dodosetupitemgroupconstant##1% catches empty in [a,b,] handy for xml
{\doifsomething{##1}{\dododosetupitemgroupconstant[#1][##1*]}}%
\processcommacommand[#2]\dodosetupitemgroupconstant} % expansion of #2 is handy for xml
-%\def\dododododosetupitemgroup[#1][#2]%
-% {\doifassignmentelse{#2}
-% {\dosetupitemgroupvariable[#1][#2]}
-% {\setitemparameter{#1}\empty{\dosetupitemgroupconstant[#1][#2]}}}%
-
\def\dododododosetupitemgroup[#1][#2]%
{\doifassignmentelse{#2}%
{\dosetupitemgroupvariable[#1][#2]}%
@@ -277,18 +267,6 @@
\pluscounter{\@@itemcounter\itemlevel}%
\fi\fi}
-% \def\setitemlevel#1%
-% {\ifnum\itemlevel>0\relax
-% \settrue\firstlistitem
-% \doifnotinset\v!verder{#1}
-% {\resetcounter{\@@itemcounter\itemlevel}}%
-% \def\tempnumber%
-% {\countervalue{\@@itemcounter\itemlevel}}%
-% \doifelse{\getitemparameter\itemlevel\c!plaatsafsluiter}\v!ja
-% {\def\tempsymbol{\getitemparameter\itemlevel\c!afsluiter}}
-% {\let\tempsymbol\empty}%
-% \fi}
-
\def\setitemlevel#1%
{\ifnum\itemlevel>\zerocount
\settrue\firstlistitem
@@ -383,121 +361,6 @@
\fi
\expanded{\redostartitemgroup[\itemgroupoptions]}}% [#2]
-% \def\redostartitemgroup[#1][#2]%
-% {\setfalse\inlinelistitem % new, no indent (leftskip)
-% \setfalse\concatnextitem % new, concat
-% \setfalse\txtlistitem
-% \ifhmode
-% \ifconditional\autoconcatnextitem % new, concat
-% \ifdim\lastskip=\itemsignal % new, concat
-% \settrue\concatnextitem % new, concat
-% \fi % new, concat
-% \fi % new, concat
-% \ifconditional\textlistitem\else\doifnotinset\v!text{#1}\par\fi % suboptimal
-% \fi
-% \begingroup
-% \ifnum\itemlevel=\plusone % NIEUW
-% \doadaptleftskip {\getitemparameter1\c!margin}%
-% \doadaptleftskip {\getitemparameter1\c!leftmargin}%
-% \doadaptrightskip{\getitemparameter1\c!rightmargin}%
-% \fi
-% \dosetraggedcommand{\getitemparameter\itemlevel\c!align}\raggedcommand
-% \doifsomething{\getitemparameter\itemlevel\c!indenting}
-% {% is \expanded needed?
-% \expanded{\setupindenting[\getitemparameter\itemlevel\c!indenting]}}%
-% \doifinset\v!columns{#1}%
-% {\ifinsidecolumns\else\ifnum\itemcolumndepth=\zerocount
-% \globallet\itemcolumndepth\itemlevel
-% \getitemparameter\itemlevel\c!before
-% \processfirstactioninset
-% [#1]
-% [ \v!one=>\!!counta1\relax,
-% \v!two=>\!!counta2\relax,
-% \v!three=>\!!counta3\relax,
-% \v!four=>\!!counta4\relax,
-% \v!five=>\!!counta5\relax,
-% \s!unknown=>\@EA\!!counta\getitemparameter\itemlevel\c!n]%
-% %
-% % now handled in column routines
-% %
-% % \edef\columneditemleftskip{\the\leftskip}%
-% % \def\postprocesscolumnbox##1%
-% % {\scratchdimen\columneditemleftskip
-% % \divide\scratchdimen \nofcolumns
-% % \hbox{\hskip\columneditemleftskip\hbox{\box##1}}}%
-% % \scratchdimen-\columneditemleftskip
-% % \multiply\scratchdimen \nofcolumns
-% % \advance\scratchdimen \columneditemleftskip
-% % \advance\scratchdimen \hsize
-% % \edef\columntextwidth{\the\scratchdimen}%
-% % \leftskip\zeropoint
-% %
-% \startcolumns
-% [\c!n=\!!counta, % netter \??op\itemlevel\c!n
-% \c!height=,
-% \c!rule=\v!off,
-% \c!balance=\v!yes,
-% \c!align=\v!no]%
-% \fi\fi}%
-% \doifinsetelse\v!intro{#1}{\settrue\introlistitem}{\setfalse\introlistitem}%
-% % == \doifinsetelse\v!intro{#1}\settrue\setfalse\introlistitem
-% \doglobal\increment\noflists
-% \let\currentlist\noflists
-% \newcounter\noflistelements
-% \setfalse\headlistitem
-% \setfalse\sublistitem
-% \setfalse\symbollistitem
-% \let\marsymbol\relax
-% \globallet\somdestination\empty
-% \let\symsymbol\empty
-% \the\itemgroupcommands
-% \setitemlevel{#1}%
-% %\getitemparameter\itemlevel\empty
-% \let\listitem\empty % ** start value
-% \doifelsenothing{#1} % iffirstargument
-% {\edef\@@opsymbol{\getitemparameter\itemlevel\c!symbol}%
-% \letgvalueempty{\@@globalitemsymbol\itemlevel}%
-% \global\letitemparameter\itemlevel\v!continue\empty
-% % \setitemmark\@@opsymbol % ** default value
-% \dosetupitemgroupvariable[\itemlevel][#2]}
-% {\dosetupitemgroupconstant[\itemlevel][#1]%
-% \dosetupitemgroupvariable[\itemlevel][#2]%
-% \doifinsetelse\v!continue{#1}% \noexpand, else problems in non-etex with chinese
-% {\edef\@@opsymbol{\noexpand\getvalue{\@@globalitemsymbol\itemlevel}}%
-% \getitemparameter\itemlevel\v!continue}
-% {\edef\@@opsymbol{\noexpand\getitemparameter{\itemlevel}{\c!symbol}}%
-% \global\setitemparameter\itemlevel\v!continue
-% {\dosetupitemgroupconstant[\itemlevel][#1]%
-% \dosetupitemgroupvariable[\itemlevel][#2]}}%
-% \def\docommando##1% \setitemmark resets \docommando
-% {\doifnot{##1}{0}{\setitemmark{##1}}}%
-% % \processcommalist[#1,\@@opsymbol]\docommando
-% \processcommalist[#1]\docommando}% ** preset sequence or provided sequence
-% \ifx\listitem\empty
-% \setitemmark\@@opsymbol % ** default value
-% \ifx\listitem\empty
-% \edef\currentitemsymbol{\itemlevel}% ** fall back
-% \fi
-% \fi
-% \ifconditional\autointrolistitem\ifnum\prevgraf<3
-% \settrue\introlistitem
-% \fi\fi
-% \ifconditional\paragraphlistitem
-% \ifnum\itemlevel>\plusone
-% \letitemparameter\itemlevel\c!inbetween\empty
-% \fi
-% \else\ifconditional\packlistitem
-% \letitemparameter\itemlevel\c!inbetween\empty
-% \fi\fi
-% \calculatelistwidth\itemlevel{\dimen0}%
-% \ifdim\dimen0>\zeropoint\relax
-% \ifconditional\inlinelistitem\else
-% \advance\leftskip \dimen0\relax
-% \fi
-% \fi}
-%
-% column code moved so that it obeys packed and such
-
\def\redostartitemgroup[#1][#2]%
{\setfalse\inlinelistitem % new, no indent (leftskip)
\setfalse\concatnextitem % new, concat
@@ -511,16 +374,6 @@
\ifconditional\textlistitem\else\doifnotinset\v!text{#1}\par\fi % suboptimal
\fi
\begingroup
- \ifnum\itemlevel=\plusone % NIEUW
- \doadaptleftskip {\getitemparameter1\c!margin}%
- \doadaptleftskip {\getitemparameter1\c!leftmargin}%
- \doadaptrightskip{\getitemparameter1\c!rightmargin}%
- \fi
- \dosetraggedcommand{\getitemparameter\itemlevel\c!align}\raggedcommand
- \doifsomething{\getitemparameter\itemlevel\c!indenting}
- {% is \expanded needed?
- \expanded{\setupindenting[\getitemparameter\itemlevel\c!indenting]}}%
- % old location of column code
\doifinsetelse\v!intro{#1}{\settrue\introlistitem}{\setfalse\introlistitem}%
% == \doifinsetelse\v!intro{#1}\settrue\setfalse\introlistitem
\doglobal\increment\noflists
@@ -533,8 +386,7 @@
\globallet\somdestination\empty
\let\symsymbol\empty
\the\itemgroupcommands
-%\setitemlevel{#1}% moved from here
- %\getitemparameter\itemlevel\empty
+ % \getitemparameter\itemlevel\empty
\let\listitem\empty % ** start value
\doifelsenothing{#1} % iffirstargument
{\edef\@@opsymbol{\getitemparameter\itemlevel\c!symbol}%
@@ -555,7 +407,18 @@
{\doifnot{##1}{0}{\setitemmark{##1}}}%
% \processcommalist[#1,\@@opsymbol]\docommando
\processcommalist[#1]\docommando}% ** preset sequence or provided sequence
-\setitemlevel{#1}% moved to here
+ % moved to here, after settings
+ \ifnum\itemlevel=\plusone % NIEUW
+ \doadaptleftskip {\getitemparameter1\c!margin}%
+ \doadaptleftskip {\getitemparameter1\c!leftmargin}%
+ \doadaptrightskip{\getitemparameter1\c!rightmargin}%
+ \fi
+ \dosetraggedcommand{\getitemparameter\itemlevel\c!align}\raggedcommand
+ \doifsomething{\getitemparameter\itemlevel\c!indenting}
+ {% is \expanded needed?
+ \expanded{\setupindenting[\getitemparameter\itemlevel\c!indenting]}}%
+ %
+ \setitemlevel{#1}% moved to here
\ifx\listitem\empty
\setitemmark\@@opsymbol % ** default value
\ifx\listitem\empty
@@ -572,7 +435,6 @@
\else\ifconditional\packlistitem
\letitemparameter\itemlevel\c!inbetween\empty
\fi\fi
- % new location of column code
\doifinset\v!columns{#1}%
{\ifinsidecolumns\else\ifnum\itemcolumndepth=\zerocount
\globallet\itemcolumndepth\itemlevel
@@ -585,21 +447,6 @@
\v!four=>\!!counta4\relax,
\v!five=>\!!counta5\relax,
\s!unknown=>\@EA\!!counta\getitemparameter\itemlevel\c!n]%
- %
- % now handled in column routines
- %
- % \edef\columneditemleftskip{\the\leftskip}%
- % \def\postprocesscolumnbox##1%
- % {\scratchdimen\columneditemleftskip
- % \divide\scratchdimen \nofcolumns
- % \hbox{\hskip\columneditemleftskip\hbox{\box##1}}}%
- % \scratchdimen-\columneditemleftskip
- % \multiply\scratchdimen \nofcolumns
- % \advance\scratchdimen \columneditemleftskip
- % \advance\scratchdimen \hsize
- % \edef\columntextwidth{\the\scratchdimen}%
- % \leftskip\zeropoint
- %
\startcolumns
[\c!n=\!!counta, % netter \??op\itemlevel\c!n
\c!height=,
@@ -607,7 +454,6 @@
\c!balance=\v!yes,
\c!align=\v!no]%
\fi\fi}
- % end of column code
\calculatelistwidth\itemlevel{\dimen0}%
\ifdim\dimen0>\zeropoint\relax
\ifconditional\inlinelistitem\else
@@ -721,6 +567,28 @@
\appendtoks \letvalue\v!its \itemgroupitems \to \itemgroupcommands
\appendtoks \letvalue\v!mar \itemgroupmargin \to \itemgroupcommands
+% todo : \startitem .. \stopitem
+
+% quick hack ...
+
+\def\v!item{item}
+
+\appendtoks
+ \letvalue{\e!start\v!item}\itemgroupitem
+ \letvalue{\e!stop \v!item}\endgraf
+\to \itemgroupcommands
+
+\appendtoks
+ \setvalue{\e!start\v!head}#1{\itemgrouphead#1\par}%
+ \letvalue{\e!stop \v!head}\endgraf
+\to \itemgroupcommands
+
+% \startitemize
+% \starthead {xx} test \stophead
+% \startitem test \stopitem
+% \startitem test \stopitem
+% \stopitemize
+
% Sometimes the user demands get pretty weird:
%
% \startitemize
diff --git a/tex/context/base/core-mat.tex b/tex/context/base/core-mat.tex
index 72c4eef79..8624396cc 100644
--- a/tex/context/base/core-mat.tex
+++ b/tex/context/base/core-mat.tex
@@ -137,6 +137,8 @@
\newconditional\handleformulanumber
\newconditional\incrementformulanumber
+\def\formuladistance{\formulaparameter\c!distance}
+
\def\dododoformulanumber#1#2#3#4% (#1,#2)=outer(ref,sub) (#3,#4)=inner(ref,sub)
{\hbox\bgroup
\ifconditional\handleformulanumber
@@ -157,6 +159,7 @@
\fi
\doifsomething{#3}{\rawreference\s!for{#3}{\composedsectionnumber\hetsubnummer}}%
\rm % nodig ?
+ \doif{\formulaparameter\c!location}\v!right{\hskip\formuladistance}%
\@@fmnumbercommand
{\dostartattributes\??fm\c!numberstyle\c!numbercolor
\strut
@@ -166,6 +169,7 @@
{\ignorespaces\preparednumber\ignorespaces\hetsubnummer\unskip}%
\@@fmright
\dostopattributes}%
+ \doif{\formulaparameter\c!location}\v!left{\hskip\formuladistance}%
\fi
\egroup}
@@ -282,6 +286,13 @@
% hm, invoke otr in hmode in order to move skips to mvl, could be an option
+%D \startbuffer
+%D \startformula[9pt] x = 1 \stopformula
+%D \startformula[7pt] x = 1 \stopformula
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+
\def\dodostartformula[#1][#2]% setting leftskip adaption is slow !
{% todo: test first
%
@@ -622,6 +633,7 @@
\hbox to \localhsize \bgroup
\hss
\def\normalstartformula{\vskip-\strutdepth$$}% i hate this
+ \def\normalstartformula{\vskip-\strutdepth$$}% i hate this
\def\normalstopformula {$$}%
\def\startformula{$\vcenter\bgroup\normalstartformula}%
\def\stopformula {\normalstopformula\egroup$\hss}%
@@ -679,7 +691,7 @@
\def\resetdisplaymatheq
{\let\normalleqno\relax \let\leqno\relax
\let\normalreqno\relax \let\eqno \relax
- \let\doplaceformulanumber\relax}
+ \let\doplaceformulanumber\empty}
\let\normaldispl@y\displ@y
@@ -708,8 +720,47 @@
\def\mathhbox
{\iftracemath\ruledhbox\else\hbox\fi}
-\def\startmathbox#1#2%
+% \def\startmathbox#1#2%
+% {\hsize\displaywidth
+% \global\let\@eqno \empty \def\eqno {\gdef\@eqno }%
+% \global\let\@leqno\empty \def\leqno{\gdef\@leqno}%
+% % added
+% \let\normalreqno\eqno
+% \let\normalleqno\leqno
+% % added
+% \doplaceformulanumber
+% \mathhbox to \displaywidth\bgroup
+% \mathinnerstrut
+% $\displaystyle
+% \ifx\@leqno\empty\else \ifcase#2
+% \rlap{\@leqno}%
+% \else
+% \@leqno\hskip\formulaparameter\c!distance
+% \fi \fi
+% #1}
+
+% \def\stopmathbox#1#2%
+% {$#1%
+% \ifx\@eqno\empty\else \ifcase#2
+% \llap{\@eqno}%
+% \else
+% \hskip\formulaparameter\c!distance\@eqno
+% \fi \fi
+% \egroup}
+
+% \defineinnermathhandler\v!right {\startmathbox\empty1}{\stopmathbox\hfill0}
+% \defineinnermathhandler\v!left {\startmathbox\hfill0}{\stopmathbox\empty1}
+% \defineinnermathhandler\v!middle{\startmathbox\hfill0}{\stopmathbox\hfill0}
+
+\chardef\mathraggedstatus=0 % normal left center right
+\chardef\mathnumberstatus=0 % nothing normal shift_right
+\let\mathnumbercorrection\!!zeropoint
+
+\def\startmathbox#1%
{\hsize\displaywidth
+ \global\chardef\mathnumberstatus\plusone
+ \chardef\mathraggedstatus#1\relax
+ \let\mathnumbercorrection\!!zeropoint
\global\let\@eqno \empty \def\eqno {\gdef\@eqno }%
\global\let\@leqno\empty \def\leqno{\gdef\@leqno}%
% added
@@ -717,28 +768,74 @@
\let\normalleqno\leqno
% added
\doplaceformulanumber
- \mathhbox to \displaywidth\bgroup
+ \setbox\scratchbox\mathhbox to \displaywidth\bgroup
\mathinnerstrut
- $\displaystyle
- \ifx\@leqno\empty\else \ifcase#2
- \rlap{\@leqno}%
- \else
- \@leqno\hskip\formulaparameter\c!distance
- \fi \fi
- #1}
-
-\def\stopmathbox#1#2%
- {$#1%
- \ifx\@eqno\empty\else \ifcase#2
+ $%
+ \displaystyle
+ \ifcase\mathraggedstatus\or\hfill\or\hfill\fi}
+
+\def\llappedmathno
+ {\ifcase\mathraggedstatus\or
+ \@eqno
+ \or
+ \llap{\@eqno}%
+ \or
\llap{\@eqno}%
+ \fi}
+
+\def\rlappedmathno
+ {\ifcase\mathraggedstatus\or
+ \rlap{\@leqno}%
+ \or
+ \rlap{\@leqno}%
+ \or
+ \@leqno
+ \fi}
+
+\def\stopmathbox
+ {$%
+ \ifcase\mathraggedstatus\or\or\hfill\or\hfill\fi
+ \egroup
+ \setbox0\hbox{\unhcopy\scratchbox}%
+ \scratchdimen\wd0
+ \ifdim\scratchdimen>\displaywidth
+ \donetrue
\else
- \hskip\formulaparameter\c!distance\@eqno
- \fi \fi
+ \donefalse
+ \fi
+ \hbox to \displaywidth\bgroup
+ \ifcase\mathnumberstatus
+ \box\scratchbox
+ \or
+ \ifx\@leqno\empty
+ \ifx\@eqno\empty
+ \box\scratchbox
+ \else
+ \ifdone
+ \vbox{\box\scratchbox\hbox to \displaywidth{\hss\llappedmathno}}%
+ \else
+ \hss\box\scratchbox\llappedmathno % hss makes room for number
+ \fi
+ \fi
+ \else
+ \ifdone
+ \vbox{\hbox to \displaywidth{\rlappedmathno\hss}\box\scratchbox}%
+ \else
+ \rlappedmathno\box\scratchbox\hss % hss makes room for number
+ \fi
+ \fi
+ \or
+ \hskip\mathnumbercorrection
+ \box\scratchbox
+ \hss
+ \else
+ \box\scratchbox
+ \fi
\egroup}
-\defineinnermathhandler\v!right {\startmathbox\empty1}{\stopmathbox\hfill0}
-\defineinnermathhandler\v!left {\startmathbox\hfill0}{\stopmathbox\empty1}
-\defineinnermathhandler\v!middle{\startmathbox\hfill0}{\stopmathbox\hfill0}
+\defineinnermathhandler\v!left {\startmathbox\plusone }{\stopmathbox}
+\defineinnermathhandler\v!middle{\startmathbox\plustwo }{\stopmathbox}
+\defineinnermathhandler\v!right {\startmathbox\plusthree}{\stopmathbox}
%D [The examples below are in english and don't process in the
%D documentation style, which will be english some day.]
@@ -1538,10 +1635,35 @@
% preamble is scanned for tabskips so we need the span to prevent an error message
-\def\prepareeqalignno
+\chardef\eqalignmode\plusone
+
+% \def\preparereqalignno
+% {\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
+% \!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
+% \!!toksc{\hfil\tabskip\centering&\llap{\span\textineqalign{##}}\tabskip\zeropoint}%
+% \buildeqalign
+% \presetdisplaymath
+% \tabskip\centering}
+
+% \def\prepareleqalignno
+% {\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
+% \!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
+% \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\textineqalign{##}}\tabskip\displaywidth}%
+% \buildeqalign
+% \presetdisplaymath
+% \tabskip\centering}
+
+\def\preparereqalignno
{\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
\!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
- \!!toksc{\hfil\tabskip\centering&\llap{\span\textineqalign{##}}\tabskip\zeropoint}%
+ \ifnum\mathraggedstatus=\plusone
+ \!!toksc{\hfil&\span\textineqalign{##}\tabskip\zeropoint}%
+ \else\ifnum\mathraggedstatus=\plusthree
+ \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\span\textineqalign{##}\tabskip\zeropoint}%
+ \else
+ \!!toksc{\hfil\tabskip\centering&\llap{\span\textineqalign{##}}\tabskip\zeropoint}%
+ \fi\fi
+ \global\chardef\mathnumberstatus\zerocount
\buildeqalign
\presetdisplaymath
\tabskip\centering}
@@ -1549,33 +1671,73 @@
\def\prepareleqalignno
{\!!toksa{\strut\firstineqalign\hfil\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
\!!toksb{&\nextineqalign\leftofeqalign\span\mathineqalign{##}\rightofeqalign\tabskip\zeropoint}%
- \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\textineqalign{##}}\tabskip\displaywidth}%
+ % problem: number is handled after rest and so ends up in the margin
+ \ifnum\mathraggedstatus=\plusone
+ \!!toksc{\hfil&\kern-\displaywidth\rlap{\span\textineqalign{##}}\tabskip\displaywidth}%
+ \else\ifnum\mathraggedstatus=\plusthree
+ \!!toksc{\hfil\tabskip\zeropoint\!!plus 1\!!fill&\kern-\displaywidth\span\mrlap{\span\textineqalign{##}}\tabskip\displaywidth}%
+ \else
+ \!!toksc{\hfil\tabskip\centering&\kern-\displaywidth\rlap{\span\textineqalign{##}}\tabskip\displaywidth}%
+ \fi\fi
+ \global\chardef\mathnumberstatus\zerocount
\buildeqalign
\presetdisplaymath
\tabskip\centering}
-\chardef\eqalignmode=1
-
-\def\eqalignno#1%
- {\prepareeqalignno
- \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the\scratchtoks\crcr#1\crcr}}
+\def\dobotheqalignno#1#2%
+ {\ifmmode
+ \displ@y % \let\doplaceformulanumber\relax % strange hack
+ \vcenter\bgroup
+ \let\finishalignno\egroup
+ \else
+ \let\finishalignno\relax
+ \fi
+ #1%
+ \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the\scratchtoks\crcr#2\crcr}%
+ \finishalignno}
+
+% \def\dobothaligneqalignno#1%
+% {\ifmmode
+% \displ@y % \let\doplaceformulanumber\relax % strange hack
+% \vcenter\bgroup
+% \def\finishalignno{\crcr\egroup\egroup}%
+% \else
+% \def\finishalignno{\crcr\egroup}%
+% \fi
+% #1%
+% \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}
-\def\leqalignno#1%
- {\prepareleqaligno
- \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA {\the\scratchtoks\crcr#1\crcr}}
+\def\mrlap#1%
+ {\setbox\scratchbox\hbox{#1}%
+ \ifdim\wd\scratchbox>\mathnumbercorrection
+ \xdef\mathnumbercorrection{\the\wd\scratchbox}%
+ \fi
+ \box\scratchbox
+ \global\chardef\mathnumberstatus\plustwo}
-\def\aligneqalignno
- {\prepareeqalignno
+\def\dobothaligneqalignno#1%
+ {\ifmmode
+ \displ@y
+ \global\chardef\mathnumberstatus\plusone
+ % we're in a mathbox
+ \vcenter\bgroup
+ \def\finishalignno{\crcr\egroup\egroup}%
+ \else
+ \def\finishalignno{\crcr\egroup}%
+ \fi
+ #1%
\halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}
-\def\alignleqalignno
- {\prepareleqalignno
- \halign \ifcase\eqalignmode \or to \displaywidth \fi \@EA \bgroup\the\scratchtoks\crcr}
+\def\reqalignno {\dobotheqalignno \preparereqalignno}
+\def\leqalignno {\dobotheqalignno \prepareleqalignno}
+\def\alignreqalignno{\dobothaligneqalignno\preparereqalignno}
+\def\alignleqalignno{\dobothaligneqalignno\prepareleqalignno}
+\def\finishalignno {\crcr\egroup}
-\def\finishalignno
- {\crcr\egroup}
+\let \equalignno \reqalignno
+\let\aligneqalignno\alignreqalignno
-%D Here we implement teh user interface part.
+%D Here we implement the user interface part.
\def\setupmathalignment
{\dodoubleempty\dosetupmathalignment}
@@ -1598,7 +1760,7 @@
\c!distance=1em]
\def\numberedeqalign
- {\doifelse\@@fmlocation\v!left\alignleqalignno\aligneqalignno}
+ {\doifelse\@@fmlocation\v!left\alignleqalignno\alignreqalignno}
\def\doxxdoubleempty#1#2%
{\ifx#2[\expandafter\dodoxxdoubleempty\else\expandafter\noxxdoubleempty\fi#1#2}
@@ -1660,7 +1822,9 @@
\doifelse{#2}{*}{\def\\{&\crcr}}{\def\\{&\doalignNR[+][]\crcr}}%
% end of compatibility mode
\eqaligncolumn\zerocount
- \processcommacommand[\mathalignmentparameter\c!align]{\advance\eqaligncolumn\plusone\doseteqaligncolumn}%
+ \processcommacommand
+ [\mathalignmentparameter\c!align]
+ {\advance\eqaligncolumn\plusone\doseteqaligncolumn}% takes argument
% the real action
\global\eqaligncolumn\plusone
\numberedeqalign}
@@ -1907,13 +2071,13 @@
\edef\currentmathcases{#1}%
\doifassignmentelse{#2}{\setupmathcases[#1][#2]}\donothing
\mathcasesparameter\c!left
- \vcenter\bgroup
+ \ruledvcenter\bgroup
\pushmacro\docasesNC
\let\endmath\relax
\def\NC{\docasesNC}%
\def\MC{\docasesNC\ifmmode\else$\def\endmath{$}\fi}%
\global\let\docasesNC\dodocasesNC
- \def\NR{\endmath&\global\let\docasesNC\dodocasesNC\doxxdoubleempty\docasesNR}%
+ \def\NR{\unskip\endmath&\global\let\docasesNC\dodocasesNC\doxxdoubleempty\docasesNR}%
\normalbaselines
\mathsurround\zeropoint
\everycr\emptytoks
@@ -1921,8 +2085,11 @@
\global\eqaligncolumn\plusone
\halign\bgroup
$##$\hfil
- &\hskip\mathcasesparameter\c!distance\relax\popmacro\docasesNC##\hfil
- &\hskip\mathcasesparameter\c!numberdistance\relax\span\textineqalign{##}%
+ &\hskip\mathcasesparameter\c!distance\relax
+ \popmacro\docasesNC##\hfil
+ &\hskip\mathcasesparameter\c!numberdistance\relax
+ \let\formuladistance\!!zeropoint
+ \span\textineqalign{##}%
\crcr} % todo: number
\def\dostopmathcases
diff --git a/tex/context/base/core-not.tex b/tex/context/base/core-not.tex
index 44dbd1fb7..40159c803 100644
--- a/tex/context/base/core-not.tex
+++ b/tex/context/base/core-not.tex
@@ -234,8 +234,15 @@
\def\dosetupnote[#1][#2]%
{\edef\currentnote{#1}%
\ifsecondargument
- \getparameters
- [\??vn\currentnote][#2]%
+\ifcase\localnodemode\or
+ \edef\localnode@n{\noteparameter\c!n}%
+ \edef\localnode@l{\noteparameter\c!location}%
+\fi
+ \getparameters[\??vn\currentnote][#2]%
+\ifcase\localnodemode\or
+ \letvalue{\??vn\currentnote\c!n }\localnode@n
+ \letvalue{\??vn\currentnote\c!location}\localnode@l
+\fi
\processaction
[\noteparameter\c!rule]
[ \v!on=>\letvalue{\??vn\c!rule:\currentnote}\normalnoterule,
@@ -274,7 +281,7 @@
{\chardef\clevernotes\zerocount}}%
\ifcase\clevernotes\relax
% notes not in column areas
- \ifnum\noteparameter\c!n=\zerocount
+ \ifnum\noteparameter\c!n=\zerocount % no ifcase
\settextnotes
\scratchcounter\plusone
\else
@@ -291,7 +298,7 @@
\global\bottomnotestrue}% not: \postponenotes, else global
\else
% notes in column areas
- \ifnum\@@kln=\zerocount % brrr dependency on \??kl
+ \ifnum\@@kln=\zerocount % no ifcase / brrr dependency on \??kl
\scratchcounter\plusone
\else
\scratchcounter\footnoteparameter\c!n\relax % **
@@ -393,19 +400,41 @@
\ifvbox0\unvbox\else\box\fi0}%
\rigidcolumnbalance0\egroup}}
+% \def\settextnotes
+% {\def\startpushnote {\startvboxtohbox
+% \dostartattributes{\??vn\currentnote}\c!style\c!color\empty}%
+% \def\stoppushnote {\hskip\noteparameter\c!columndistance % plus.5em minus.5em
+% \dostopattributes
+% \stopvboxtohbox}%
+% \def\startpopnotes {\vbox\bgroup
+% \doifnotinset{\noteparameter\c!width}{\v!fit,\v!broad}\setnotehsize
+% \beginofshapebox}%
+% \def\stoppopnotes {\endofshapebox
+% \reshapebox{\ifhbox\shapebox\unhbox\else\box\fi\shapebox\endgraf}%
+% \flushshapebox
+% \egroup}}
+%
+% this was wrong (for ages)
+
\def\settextnotes
{\def\startpushnote {\startvboxtohbox
\dostartattributes{\??vn\currentnote}\c!style\c!color\empty}%
\def\stoppushnote {\hskip\noteparameter\c!columndistance % plus.5em minus.5em
\dostopattributes
\stopvboxtohbox}%
+% \def\startpopnotes {\vbox\bgroup
+% \doifnotinset{\noteparameter\c!width}{\v!fit,\v!broad}\setnotehsize}
+% \def\stoppopnotes {\convertvboxtohbox
+% \egroup}%
\def\startpopnotes {\vbox\bgroup
\doifnotinset{\noteparameter\c!width}{\v!fit,\v!broad}\setnotehsize
\beginofshapebox}%
\def\stoppopnotes {\endofshapebox
- \reshapebox{\ifhbox\shapebox\unhbox\else\box\fi\shapebox\endgraf}%
- \flushshapebox
- \egroup}}
+ \doreshapebox{\box\shapebox}{}{}{}% get rid of penalties etc
+ \innerflushshapebox
+ \convertvboxtohbox
+ \egroup}%
+ }
%D The formatting depends on the width of the table, so we
%D have to set \type {n} to zero.
@@ -473,6 +502,7 @@
\def\dosetnote[#1][#2][#3]%
{\unskip
\def\currentnote{#2}%
+ \dochecknote % sometimes needed for local notes
\ifcase#1\relax
\global\notesymbolfalse
\else
@@ -622,7 +652,7 @@
\splitmaxdepth\strutdp % not actually needed here
\leftmargindistance\noteparameter\c!margindistance
\rightmargindistance\leftmargindistance
- \ifcase\noteparameter\c!n\relax % new 31-07-99 ; always ?
+ \ifnum\noteparameter\c!n=\zerocount % no ifcase new 31-07-99 ; always ?
\doifnotinset{\noteparameter\c!width}{\v!fit,\v!broad}\setnotehsize
\fi
\startpushnote
@@ -761,11 +791,13 @@
\setnotebodyfont
% % this should be checked, smells like a mix-up
% % does not split: \ifcase\noteparameter\c!n\unvbox\else\box\fi\currentnoteins
-% \ifcase\noteparameter\c!n
+ \ifnum\noteparameter\c!n=\zerocount % no ifcase
+ \unvbox\currentnoteins
+ \or
\box\currentnoteins
-% \else
-% \unvbox\currentnoteins
-% \fi
+ \else
+ \unvbox\currentnoteins
+ \fi
% this is too ugly actually
\stoppopnotes}%
\setbox2\hbox
@@ -936,7 +968,10 @@
\startpopnotes % make sure that fake height is killed
\unvbox#1\endgraf
\stoppopnotes
- \setbox0=\lastbox \ifvbox0 \unvbox0\else\box0\fi % enable columns
+ % weird
+ \ifhmode
+ \setbox0=\lastbox \ifvbox0 \unvbox0\else\box0\fi % enable columns
+ \fi
\noteparameter\c!after
\fi}
@@ -970,9 +1005,12 @@
{\bgroup % here because we support \vbox\startlocalnotes
\dosingleempty\dostartlocalnotes}
+\chardef\localnodemode\zerocount
+
\def\dostartlocalnotes[#1]%
{\let\autopostponenotes\postponenotes
\let\postponenotes\collectlocalnotes
+ \chardef\localnodemode\plusone % new
\def\defaultnotewidth{\ifdim\hsize<\makeupwidth\hsize\else\makeupwidth\fi}%
\processnotes
{\doifsomething{#1}{\setupnote[\currentnote][#1]}%
@@ -990,12 +1028,17 @@
\def\doplacelocalnotes[#1][#2]%
{\bgroup
+ \chardef\localnodemode\plusone % new
\dolocalsetupnotes{#1}{#2}%
- \processnotes
- {\ExpandBothAfter\doifinsetelse\v!none{\noteparameter\c!location}
- \placenotesasnone\placenotesintext\localpostponednotes}%
+ \processnotes\dodoplacelocalnotes
\egroup
- \checknotes}
+ \checknotes} % probably not needed
+
+\def\dodoplacelocalnotes
+ {\dochecknote
+ \expanded{\doifinsetelse{\v!none}{\noteparameter\c!location}}
+ \placenotesasnone\placenotesintext
+ \localpostponednotes}
%D These commands can be used like:
%D
diff --git a/tex/context/base/core-ntb.tex b/tex/context/base/core-ntb.tex
index ba861eec2..914b55e65 100644
--- a/tex/context/base/core-ntb.tex
+++ b/tex/context/base/core-ntb.tex
@@ -67,6 +67,7 @@
\def\eTBLCELL
{\ifhmode
\delayedendstrut
+ \par % added 13/4/2006
\else
\par
\ifdim\prevdepth<\zeropoint % =-1000pt ?
@@ -138,6 +139,7 @@
\let\popTBLparameters \relax
\newif\ifsqueezeTBLspan \squeezeTBLspantrue % spans one column cell over multi column par cells
+\newif\ifautosqueezeTBLspan \autosqueezeTBLspantrue % unless explicit widths are given
\newif\ifautoTBLspread \autoTBLspreadfalse
\newif\ifautoTBLhsize \autoTBLhsizetrue
\newif\ifautoTBLrowspan \autoTBLrowspantrue
@@ -224,48 +226,113 @@
\let\setupTBLsection\relax
+% \def\setupTBLcell#1#2% cell over col over row
+% {\setupTBLsection % already forgotten
+% \getvalue{\@@tblprefix\v!each\v!each}%
+% \getvalue{\@@tblprefix\c!y\v!each}%
+% \getvalue{\@@tblprefix\c!x\v!each}%
+% \getvalue{\@@tblprefix\c!y\v!oddeven{#1}}%
+% \getvalue{\@@tblprefix\c!x\v!oddeven{#2}}%
+% \getvalue{\@@tblprefix\c!x\v!oddeven{#2}\c!y\v!oddeven{#1}}%
+% \ifnum#1=\plusone
+% \getvalue{\@@tblprefix\c!y\v!first}%
+% \executeifdefined{\@@tblprefix\c!x#2\c!y\v!first}\donothing
+% \fi
+% \ifnum#2=\plusone
+% \getvalue{\@@tblprefix\c!x\v!first}%
+% \executeifdefined{\@@tblprefix\c!x\v!first\c!y#1}\donothing
+% \fi
+% \ifnum#1=\maximumrow\relax
+% \getvalue{\@@tblprefix\c!y\v!last}%
+% \executeifdefined{\@@tblprefix\c!x#2\c!y\v!last}\donothing
+% \fi
+% \ifnum#2=\maximumcol\relax
+% \getvalue{\@@tblprefix\c!x\v!last}%
+% \executeifdefined{\@@tblprefix\c!x\v!last\c!y#1}\donothing
+% \fi
+% \ifnum#1=\maximumrow\relax\ifnum#2=\maximumcol\relax
+% \getvalue{\@@tblprefix\c!x\v!last\c!y\v!last}%
+% \fi\fi
+% \ifnum#1=\plusone \ifnum#2=\plusone
+% \getvalue{\@@tblprefix\c!x\v!first\c!y\v!first}%
+% \fi\fi
+% \ifnum#1>\noftblhdnxlines\else
+% \executeifdefined{\@@tblprefix\v!header\v!each}\donothing
+% \executeifdefined{\@@tblprefix\v!header#2}\donothing
+% \fi
+% \executeifdefined{\@@tblprefix\c!y#1}\donothing
+% \getvalue{\@@tbl\@@tbl\c!extras}\letvalue{\@@tbl\@@tbl\c!extras}\relax % new, see x-fo
+% \executeifdefined{\@@tblprefix\c!x#2}\donothing
+% \getvalue{\@@tbl\@@tbl\c!extras}\letvalue{\@@tbl\@@tbl\c!extras}\relax % new, see x-fo
+% \executeifdefined{\@@tblprefix\c!x#2\c!y#1}\donothing
+% \global\letcscsname\@@tblsplitafter\csname\@@tbl\@@tbl\c!after\endcsname
+% \relax}
+
+
\def\setupTBLcell#1#2% cell over col over row
{\setupTBLsection % already forgotten
-\getvalue{\@@tblprefix\v!each\v!each}%
+\edef\positiverow{\number#1}%
+\edef\positivecol{\number#2}%
+\scratchcounter-\maximumrow\advance\scratchcounter#1\advance\scratchcounter\minusone
+\edef\negativerow{\number\scratchcounter}%
+\scratchcounter-\maximumcol\advance\scratchcounter#2\advance\scratchcounter\minusone
+\edef\negativecol{\number\scratchcounter}%
+ \getvalue{\@@tblprefix\v!each\v!each}%
\getvalue{\@@tblprefix\c!y\v!each}%
\getvalue{\@@tblprefix\c!x\v!each}%
- \getvalue{\@@tblprefix\c!y\v!oddeven{#1}}%
- \getvalue{\@@tblprefix\c!x\v!oddeven{#2}}%
- \getvalue{\@@tblprefix\c!x\v!oddeven{#2}\c!y\v!oddeven{#1}}%
- \ifnum#1=\plusone
+ \getvalue{\@@tblprefix\c!y\v!oddeven\positiverow}%
+ \getvalue{\@@tblprefix\c!x\v!oddeven\positivecol}%
+ \getvalue{\@@tblprefix\c!x\v!oddeven\positivecol\c!y\v!oddeven\positiverow}%
+ \ifnum\positiverow=\plusone
\getvalue{\@@tblprefix\c!y\v!first}%
- \executeifdefined{\@@tblprefix\c!x#2\c!y\v!first}\donothing
+ \executeifdefined{\@@tblprefix\c!x\positivecol\c!y\v!first}\donothing
\fi
- \ifnum#2=\plusone
+ \ifnum\positivecol=\plusone
\getvalue{\@@tblprefix\c!x\v!first}%
- \executeifdefined{\@@tblprefix\c!x\v!first\c!y#1}\donothing
+ \executeifdefined{\@@tblprefix\c!x\v!first\c!y\positiverow}\donothing
\fi
- \ifnum#1=\maximumrow\relax
+ \ifnum\positiverow=\maximumrow\relax
\getvalue{\@@tblprefix\c!y\v!last}%
- \executeifdefined{\@@tblprefix\c!x#2\c!y\v!last}\donothing
+ \executeifdefined{\@@tblprefix\c!x\positivecol\c!y\v!last}\donothing
\fi
- \ifnum#2=\maximumcol\relax
+ \ifnum\positivecol=\maximumcol\relax
\getvalue{\@@tblprefix\c!x\v!last}%
- \executeifdefined{\@@tblprefix\c!x\v!last\c!y#1}\donothing
+ \executeifdefined{\@@tblprefix\c!x\v!last\c!y\positiverow}\donothing
\fi
- \ifnum#1=\maximumrow\relax\ifnum#2=\maximumcol\relax
+ \ifnum\positiverow=\maximumrow\relax\ifnum\positivecol=\maximumcol\relax
\getvalue{\@@tblprefix\c!x\v!last\c!y\v!last}%
\fi\fi
- \ifnum#1=\plusone \ifnum#2=\plusone
+ \ifnum\positiverow=\plusone \ifnum\positivecol=\plusone
\getvalue{\@@tblprefix\c!x\v!first\c!y\v!first}%
\fi\fi
\ifnum#1>\noftblhdnxlines\else
\executeifdefined{\@@tblprefix\v!header\v!each}\donothing
- \executeifdefined{\@@tblprefix\v!header#2}\donothing
+ \executeifdefined{\@@tblprefix\v!header\positivecol}\donothing
\fi
- \executeifdefined{\@@tblprefix\c!y#1}\donothing
+ \executeifdefined{\@@tblprefix\c!y\positiverow}\donothing
+\executeifdefined{\@@tblprefix\c!y\negativerow}\donothing
\getvalue{\@@tbl\@@tbl\c!extras}\letvalue{\@@tbl\@@tbl\c!extras}\relax % new, see x-fo
- \executeifdefined{\@@tblprefix\c!x#2}\donothing
+ \executeifdefined{\@@tblprefix\c!x\positivecol}\donothing
+\executeifdefined{\@@tblprefix\c!x\negativecol}\donothing
\getvalue{\@@tbl\@@tbl\c!extras}\letvalue{\@@tbl\@@tbl\c!extras}\relax % new, see x-fo
- \executeifdefined{\@@tblprefix\c!x#2\c!y#1}\donothing
+ \executeifdefined{\@@tblprefix\c!x\positivecol\c!y\positiverow}\donothing
+\executeifdefined{\@@tblprefix\c!x\negativecol\c!y\negativerow}\donothing
\global\letcscsname\@@tblsplitafter\csname\@@tbl\@@tbl\c!after\endcsname
\relax}
+% we cannot use +n (checking on number/last/first would slow down too much)
+%
+% \setupTABLE[r] [2][color=red]
+% \setupTABLE[r] [-2][color=red]
+% \setupTABLE[c] [2][color=green]
+% \setupTABLE[c] [-2][color=green]
+% \setupTABLE[4] [4][color=blue]
+% \setupTABLE[-4][-4][color=blue]
+%
+% \bTABLE
+% \dorecurse{10}{\bTR \dorecurse{6}{\bTD xxx \eTD} \eTR}
+% \eTABLE
+
\globallet\@@tblsplitafter\relax
% split + page:
@@ -289,11 +356,13 @@
{\getparameters[\@@tbl][\c!ny=\tblnr,\c!nx=\tblnc,nc=1,nr=1,\c!n=\currentcol,\c!m=,#1]%
% goto first cell % NEW, n/m=cellnumber
\increment\currentcolpos
- \doifvaluesomething{\@@tbl\c!n}
+ \doifelsevaluenothing{\@@tbl\c!n}
+ {\increment(\spnTBL,\tblnx)\relax}
{\ifnum\getvalue{\@@tbl\c!n}=\currentcol\else
\scratchcounter\getvalue{\@@tbl\c!n}%
\advance\scratchcounter-\currentcol
\advance\scratchcounter\minusone
+\advance\scratchcounter-\spnTBL
\ifnum\scratchcounter>\zerocount
\expanded{\parseTD[\c!nx=\the\scratchcounter,\c!n=,\c!m=,*sq=\v!no][]}\eTD
\fi
@@ -304,6 +373,7 @@
\scratchcounter\getvalue{\@@tbl\c!m}%
\advance\scratchcounter-\currentcol
\advance\scratchcounter\minusone
+% \advance\scratchcounter-\spnTBL
\dorecurse\scratchcounter{\expanded{\parseTD[\c!n=,\c!m=][]}\eTD}%
\getparameters[\@@tbl][\c!ny=\tblnr,\c!nx=\tblnc,nc=1,nr=1,#1,\c!n=,\c!m=]%
\fi}%
@@ -356,6 +426,21 @@
%D \stopbuffer
%D
%D \typebuffer \getbuffer
+%D
+%D \startbuffer
+%D \bTABLE[frame=on]
+%D \bTR \bTH[nc=3] One \eTH \bTH[m=4] Four \eTH\eTR
+%D \bTR \bTD a \eTD\bTD b \eTD\bTD c \eTD\bTD d \eTD\eTR
+%D \eTABLE
+%D
+%D \bTABLE[frame=on]
+%D \bTR \bTH[nr=2] One \eTH \bTH[m=3] Three \eTH\eTR
+%D \bTR \bTD[m=3] a \eTD\bTD b \eTD\bTD c \eTD\bTD d \eTD\eTR
+%D \bTR \bTD[m=3] a \eTD\bTD b \eTD\bTD c \eTD\bTD d \eTD\eTR
+%D \eTABLE
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
\long\def\parseTH[#1]#2\eTH
{\parseTD[#1,\c!color=\tbltblheadcolor,\c!style=\tbltblheadstyle,\c!aligncharacter=\v!no]#2\eTD}
@@ -626,9 +711,14 @@
\def\spantblcol
{\span}
+\newcounter\rowTBL
+\newcounter\colTBL
+\newcounter\spnTBL
+
\def\begintblrow
{\noalign
- {\doglobal\increment\rowTBL
+ {\doglobal\increment \rowTBL
+ \doglobal\newcounter\spnTBL
\doglobal\newcounter\colTBL}%
\nexttblcol
\kern\tbltblleftmargindistance
@@ -663,6 +753,7 @@
\def\begintbl
{\doglobal\newcounter\colTBL
\doglobal\newcounter\rowTBL
+ \doglobal\newcounter\spnTBL
\doglobal\decrement\rowTBL
\tabskip\zeropoint
\halign\bgroup
@@ -687,6 +778,7 @@
\def\begTBL
{\doglobal\newcounter\rowTBL
\doglobal\newcounter\colTBL
+ \doglobal\newcounter\spnTBL
\chardef\TBLpass\zerocount
\tbltoks\emptytoks
\appendtoks
@@ -744,8 +836,11 @@
\fi
\else\ifautoTBLrowspan\ifnum\maximumrowspan>1 % max ?
% added jan 2002 because nx=* did no longer work
+\edef\savedhsize{\the\hsize}%
+\hsize\wd0\relax % new per 17/04/2006
\checktblwidthsone % trial run
\checktblwidthstwo % real run
+\hsize\savedhsize
%
\let\handleTBLcell\dohandleTBLcellC
\setbox\scratchbox\vbox{\trialtypesettingtrue \the\tbltoks}%
@@ -855,11 +950,25 @@
\box\finaltblbox
\afterTABLEbox}
+% \def\splittblbox#1%
+% {\ifinsidefloat
+% \notsplittblbox{#1}%
+% \else
+% \executeifdefined{splittblbox\tbltblsplitmethod}\splittblboxa{#1}%
+% \fi}
+
\def\splittblbox#1%
- {\ifinsidefloat
- \notsplittblbox{#1}%
+ {\ifinsidesplitfloat
+ \donetrue
+ \else\ifinsidefloat
+ \donefalse
\else
+ \donetrue
+ \fi\fi
+ \ifdone
\executeifdefined{splittblbox\tbltblsplitmethod}\splittblboxa{#1}%
+ \else
+ \notsplittblbox{#1}%
\fi}
\newbox\TABLEsplitbox % public, don't change
@@ -1248,10 +1357,10 @@
\long\def\dohandleTBLcellA#1#2[#3]#4%
{\setbox\scratchbox\hbox
{\setupTBLcell{#1}{#2}%
-\scratchdimen\tbltbldistance\relax
-\ifdim\scratchdimen>\gettbldis{#2}\relax
- \settbldis{#2}{\the\scratchdimen}%
-\fi
+ \scratchdimen\tbltbldistance\relax
+ \ifdim\scratchdimen>\gettbldis{#2}\relax
+ \settbldis{#2}{\the\scratchdimen}%
+ \fi
\localframed
[\@@tbl\@@tbl]
[#3,\c!background=,\c!frame=\v!off]% 25% faster
@@ -1259,12 +1368,21 @@
\scratchdimen\gettblwid\colTBL\relax
\ifdim\wd\scratchbox>\scratchdimen
\ifsqueezeTBLspan
-\doifnotvalue{\@@tbl*sq}\v!no{%
+% \doifinset\tbltblwidth{\v!fit,\v!fixed,\v!broad,\v!local}{%
+% \ifnum0\number\gettblcol{#1}{#2}>1\relax \settblspn\colTBL \fi
+% }%
+\ifautosqueezeTBLspan
+\doifinsetelse\tbltblwidth{\v!fit,\v!fixed,\v!broad,\v!local}
+ \donetrue \donefalse
+\else
+ \donetrue
+\fi
+\ifdone
\ifnum0\number\gettblcol{#1}{#2}>1\relax \settblspn\colTBL \fi
-}%
+\fi
\fi
\doifelsetblspn\colTBL
- \donothing{\settblwid\colTBL{\the\wd\scratchbox}}% auto set
+ \donothing{\ifdim\gettblwid\colTBL<\wd\scratchbox\settblwid\colTBL{\the\wd\scratchbox}\fi}% auto set
\fi
\let\rowTBLx\rowTBL\increment\rowTBLx
\scratchdimen\gettblhei\rowTBLx\relax
diff --git a/tex/context/base/core-num.tex b/tex/context/base/core-num.tex
index 1054c4e19..1f89b06cb 100644
--- a/tex/context/base/core-num.tex
+++ b/tex/context/base/core-num.tex
@@ -74,6 +74,7 @@
\c!start=0,
#2]%
\makecounter{\@@thenumber{#1}}%
+ \setxvalue{\@@thenumber{#1}\c!n}{\countervalue{\@@thenumber{#1}}}%
\setcounter{\@@thenumber{#1}}{\numberparameter{#1}\c!start}}
\def\setnumber[#1]#2%
@@ -82,9 +83,6 @@
\def\resetnumber[#1]%
{\setcounter{\@@thenumber{#1}}{0\numberparameter{#1}\c!start}}
-\def\dodoreset#1%
- {\getvalue{\s!reset#1}}%
-
\def\savenumber[#1]%
{\savecounter{\@@thenumber{#1}}}
@@ -97,13 +95,16 @@
\def\doreset[#1]%
{\processcommalist[#1]\dodoreset}
+\def\dodoreset#1%
+ {\getvalue{\s!reset#1}}%
+
\def\reset
{\dosingleargument\doreset}
% nieuw, maar kan dit (i.v.m. (sub)page?)
% \def\incrementnumber[#1]%
-% {\checknummer{#1}%
+% {\checknumber[#1]%
% \doifelse\@@nrstatus\v!start
% {\pluscounter{\@@thenumber{#1}}}
% {\setcounter{\@@thenumber{#1}}{0\csname\@@thenumber{#1}\c!start\endcsname}}}
@@ -112,7 +113,7 @@
{\doifelse{\numberparameter{#1}\c!way}{\v!by\v!page}
{\checkpagechange{#1}%
\ifpagechanged\resetcounter{\@@thenumber{#1}}\fi}
- {\checknummer{#1}}%
+ {\checknumber[#1]}%
\doifelse\@@nrstate\v!start % only here
{\pluscounter{\@@thenumber{#1}}}
{\setcounter{\@@thenumber{#1}}{0\numberparameter{#1}\c!start}}}
@@ -132,9 +133,12 @@
\def\rawnumber[#1]%
{\countervalue{\@@thenumber{#1}}}
+\def\accumulatednumber[#1]%
+ {\getvalue{\@@thenumber{#1}\c!n}}
+
\let\getnumber\convertednumber
-\ifx\checknummer\undefined \let\checknummer\gobbleoneargument \fi
+\ifx\checknumber\undefined \def\checknumber[#1]{} \fi
% ook de pag nummers hierheen halen ivm \@@nrwijze
diff --git a/tex/context/base/core-pgr.tex b/tex/context/base/core-pgr.tex
new file mode 100644
index 000000000..832135434
--- /dev/null
+++ b/tex/context/base/core-pgr.tex
@@ -0,0 +1,1651 @@
+%D \module
+%D [ file=core-pgr, % split off core-pos
+%D version=1999.08.01,
+%D title=\CONTEXT\ Core Macros,
+%D subtitle=Positioning Support,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{Context Positioning Grapics}
+
+%D Before we come to graphics support, we have to make sure of
+%D the reference point on the page. The next macro does so and
+%D is hooked into the page building routine.
+
+\unprotect
+
+% in the future, the depth of tail will reflect page depth
+
+\def\textanchor{text:\realfolio}
+
+\ifx\textheight\undefined \def\textheight{\vsize} \fi
+
+\def\placepositionanchors % todo : depth pagebox
+ {\ifpositioning
+ \setbox\scratchbox\vbox to \textheight
+ {\simpletopskipcorrection
+ \hbox{\strut\dopositionaction\headanchor}%
+ \vfill
+ \hbox{\strut\dopositionaction\tailanchor}}%
+ \dp\scratchbox\zeropoint
+ \wd\scratchbox\makeupwidth % not \zeropoint, else wrong text backgrounds
+ \hpos\textanchor{\box\scratchbox}%
+ \else
+ \vskip\textheight
+ \fi}
+
+%D The first version of this module implemented head and tail
+%D anchors. Currently we stick to just one anchor and derive
+%D the head and tail anchors from this one.
+
+\def\headanchor{head:\realfolio} % virtual position
+\def\tailanchor{tail:\realfolio} % virtual position
+
+\def\presetpositionanchors% compatibility hack (still needed?)
+ {\ifpositioning
+ \dopresetpositionanchors
+ \fi}
+
+\def\dopresetpositionanchors
+ {\bgroup
+ \!!dimena\ifdim\topskip>\strutht\topskip\else\strutht\fi
+ \!!dimenb\MPy\textanchor
+ \!!dimenc\!!dimenb
+ \advance\!!dimenb \MPh\textanchor % space is essential
+ \advance\!!dimenb -\!!dimena
+ \advance\!!dimenc \strutdp
+ \!!dimend\MPx\textanchor
+ \!!dimene\MPw\textanchor
+ \setxvalue{\POSprefix\headanchor}%
+ {\realfolio,\withoutpt\the\!!dimend,\withoutpt\the\!!dimenb,%
+ \withoutpt\the\!!dimene,\withoutpt\the\!!dimena,\withoutpt\the\strutdp}%
+ \setxvalue{\POSprefix\tailanchor}%
+ {\realfolio,\withoutpt\the\!!dimend,\withoutpt\the\!!dimenc,%
+ \withoutpt\the\!!dimene,\withoutpt\the\strutht,\withoutpt\the\strutdp}%
+ %\showanchor\textanchor\showanchor\headanchor\showanchor\tailanchor\wait
+ \egroup}
+
+\def\showanchor#1%
+ {\expanded{\writestatus{#1}
+ {\MPp{#1}\string|\MPx{#1}\string|\MPy{#1}\string|%
+ \MPw{#1}\string|\MPh{#1}\string|\MPd{#1}}}}
+
+%D We set these anchors before and after each page.
+
+\appendtoks \presetpositionanchors \to \beforeeverypage
+\appendtoks \presetpositionanchors \to \aftereverypage
+
+%D \macros
+%D {positionoverlay,startpositionoverlay}
+%D
+%D As long as we're dealing with graphics it makes much sense
+%D to use the available overlay mechanism. For this purpose, we
+%D define some dedicated overlay extensions.
+%D
+%D \startbuffer[sample]
+%D \defineoverlay [sample] [\positionoverlay{sample}]
+%D
+%D \startpositionoverlay{sample}
+%D \setMPpositiongraphic{A-1}{connectcenter}{from=A-1,to=A-2}
+%D \stoppositionoverlay
+%D \stopbuffer
+%D
+%D \typebuffer[sample]
+%D
+%D \startbuffer[graphic]
+%D \startMPpositiongraphic{connectcenter}
+%D path pa, pb ; pair ca, cb ;
+%D initialize_box(\MPpos{\MPvar{from}}) ; pa := pxy ; ca := cxy ;
+%D initialize_box(\MPpos{\MPvar{to}}) ; pb := pxy ; cb := cxy ;
+%D draw pa withcolor red ;
+%D draw pb withcolor red ;
+%D draw ca -- cb withcolor blue ;
+%D anchor_box(\MPanchor{\MPvar{from}}) ;
+%D \stopMPpositiongraphic
+%D \stopbuffer
+%D
+%D We can best demonstrate this in an example, say:
+%D
+%D \startbuffer[text]
+%D \framed
+%D [backgroundachtergrond=sample,align=middle,width=7cm]
+%D {We want to connect \hpos {A-1} {this} word with its
+%D grammatical cousin \hpos {A-2} {that}.}
+%D \stopbuffer
+%D
+%D \typebuffer[text]
+%D
+%D \startlinecorrection
+%D %\getbuffer[graphic,sample,text]
+%D \stoplinecorrection
+%D
+%D The graphic is defined in the following way, using some
+%D macros defined in an auxiliary \METAPOST\ module that is
+%D preloaded.
+%D
+%D \typebuffer[graphic]
+
+\def\MPanchoridentifier{mpa} % {mp-anchor}
+\def\MPoverlayposprefix{MO::}
+
+% obsolete and wrong anyway
+%
+% \long\def\defineMPpositiongraphic#1%
+% {\long\setvalue{\MPoverlayposprefix#1}}
+
+%D The rest of the definitions concerning such overlays may
+%D look complicated,
+
+\let\currentpositionoverlay\empty
+
+%D Position actions are automatically executed when a position
+%D is set.
+
+\let\MPanchornumber\realfolio
+
+\def\positionoverlay#1% the test prevents too many redundant positions
+ {\ifpositioning % in (not used) text* position layers
+ \vbox to \overlayheight
+ {\doifpositionactionelse{#1::\MPanchoridentifier}%
+ {\edef\MPanchorid{#1::\MPanchoridentifier:\MPanchornumber}%
+ \edef\MPanchor##1{\MPpos{\MPanchorid}}%
+ \the\everyinsertpositionaction
+ \copyposition{#1::\MPanchoridentifier}{#1::\MPanchoridentifier:\MPanchornumber}%
+ \hpos
+ {#1::\MPanchoridentifier:\MPanchornumber}%
+ % this is ok
+ %{\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}}}%
+ % but this one prevents cyclic runs due to
+ % rounding errors
+ {\setbox\scratchbox\hbox to \overlaywidth
+ {\dopositionaction{#1::\MPanchoridentifier}\hss}%
+ \ht\scratchbox\overlayheight
+ \dp\scratchbox\zeropoint
+ \box\scratchbox}}%
+ {\hbox to \overlaywidth{\hss}}%
+ \vfill}%
+ \fi}
+
+\def\startpositionoverlay#1%
+ {\iftrialtypesetting % we don't want redundant entries in the list
+ \@EA\gobbleuntil\@EA\stoppositionoverlay
+ \else
+ \def\currentpositionoverlay{#1}%
+ \fi}
+
+\def\stoppositionoverlay
+ {\let\currentpositionoverlay\empty}
+
+\def\resetpositionoverlay#1%
+ {\dosetpositionaction{#1::\MPanchoridentifier::}{}}
+
+%D Here the complication has to do with collecting actions
+%D for later execution. This collection is especially handy
+%D when we want to move actions to a specific layer.
+%D Such series of actions are stored in a macro (the one
+%D with the funny \type {++}) which is cleaned up after each
+%D invocation.
+
+\newtoks\everycleanpositionaction
+\newtoks\everyinsertpositionaction
+
+\def\cleanuppositionaction#1% not in trialtypesetting
+ {\ifundefined{\POSactionprefix#1++}\else
+ \the\everycleanpositionaction
+ \iflocalpositioning
+ \letgvalue{\POSactionprefix#1++}\empty
+ \else
+ \setxvalue{\POSactionprefix#1++}{\getvalue{\POSactionprefix#1++}}%
+ \fi
+ \fi}
+
+\def\handlepositionaction#1\with#2\on#3%
+ {\bgroup
+ \ifx\currentpositionoverlay\empty
+ \edef\!!stringa{#3}% no layer, just pos itself as anchor
+ \else
+ \edef\!!stringa{\currentpositionoverlay::\MPanchoridentifier}%
+ \fi
+ \edef\!!stringc{\POSactionprefix\!!stringa++}%
+ \expanded{\dosetpositionaction{\!!stringa}{\noexpand\getvalue{\!!stringc}}}%
+ \global\let#1\relax
+ \edef\!!stringb{\executeifdefined\!!stringc\empty}%
+ \setxvalue\!!stringc{\!!stringb#1#2}%
+ \egroup}
+
+%D The indirectness enables us redefine macros for special
+%D purposes, like a cleanup.
+
+\def\handlepositionboxes#1#2#3%
+ {\handlepositionaction\dohandlepositionboxes\with{#1}{#2}{#3}\on{#2}}
+
+\def\doinsertpositionboxes#1#2#3% pos tag setups
+ {\ifnum\MPp{#1}=\realpageno\relax
+ % \doifdefined{\MPoverlayposprefix#1}
+ % {\getvalue{\MPoverlayposprefix#1}{#1}{#2}{#3}}%
+ \executeifdefined{\MPoverlayposprefix#1}%
+ \gobblethreearguments{#1}{#2}{#3}%
+ \fi}
+
+\appendtoks
+ \let\dohandlepositionboxes\doinsertpositionboxes % was handle ?
+\to \everyinsertpositionaction
+
+\def\docleanpositionboxes#1#2#3% pos tag setups
+ {\ifnum\MPp{#1}<\realpageno \else
+ \noexpand \dohandlepositionboxes{#1}{#2}{#3}% reinsert
+ \fi}
+
+\appendtoks
+ \let\dohandlepositionboxes\docleanpositionboxes
+\to \everycleanpositionaction
+
+%D A position graphic is a normal (non||reused) \METAPOST\
+%D graphic, used immediately, with zero dimensions, so that a
+%D sequence of them does not harm.
+
+\newbox\positiongraphicbox
+
+\def\startMPpositiongraphic % id setups
+ {\dodoublegroupempty\dostartMPpositiongraphic}
+
+\long\def\dostartMPpositiongraphic#1#2#3\stopMPpositiongraphic
+ {\long\setgvalue{MPG:#1}% tag list mpcode
+ {\useMPpositiongraphic{#1}{#2}{#3}}}
+
+\def\prepareMPpositionvariables
+ {\ifundefined{\@@meta self}\setvalue{\@@meta self}{\currentposition}\fi
+ \ifundefined{\@@meta from}\setvalue{\@@meta from}{\currentposition}\fi}
+
+\newif\ifcollectMPpositiongraphics \collectMPpositiongraphicstrue
+
+\long\def\useMPpositiongraphic#1#2#3%
+ {\bgroup
+ \prepareMPvariables{#2}%
+ \prepareMPpositionvariables
+ \enableincludeMPgraphics
+ \ifcollectMPpositiongraphics
+ \expanded{\startMPdrawing#3\noexpand\stopMPdrawing}%
+ \global\MPdrawingdonetrue
+ \else
+ \startMPgraphic#3\stopMPgraphic
+ \loadMPgraphic{\MPgraphicfile.\the\currentMPgraphic}{}%
+ \deallocateMPslot\currentMPgraphic
+ \placeMPgraphic
+ \fi
+ \egroup}
+
+% Now we need a adapted action handler:
+
+\def\dopositionaction#1% test saves hash entry in etex
+ {\ifundefined{\POSactionprefix#1::}\else
+ \ifnum\MPp{#1}>\zerocount % new
+ \bgroup
+ \setbox\scratchbox\hbox
+ \bgroup
+ \traceposstring\clap\red{<#1>}%
+ \the\everyinsertpositionaction
+ \the\everypositionaction
+ \ifcollectMPpositiongraphics
+ % can save a lot of run time
+ \pushMPdrawing
+ \MPshiftdrawingtrue
+ \resetMPdrawing
+ \getvalue{\POSactionprefix#1::}%
+ \ifMPdrawingdone
+ \getMPdrawing
+ \fi
+ \resetMPdrawing
+ \popMPdrawing
+ \else
+ \getvalue{\POSactionprefix#1::}%
+ \fi
+ \cleanuppositionaction{#1}%
+ \egroup % smashed is really needed else
+ \smashedbox\scratchbox % we get problems with too big
+ \egroup % overlays (s-pre-0x.tex)
+ \else
+ % shouldn't happen too often
+ \traceposstring\clap\cyan{<#1>}%
+ \fi
+ \fi}
+
+\def\MPpositiongraphic
+ {\dodoublegroupempty\doMPpositiongraphic}
+
+\def\doMPpositiongraphic#1#2% tag setups
+ {\bgroup
+ \def\@@meta{#1:}%
+ \setupMPvariables[#2]%
+ \prepareMPpositionvariables
+ \MPshiftdrawingtrue
+ \def\doMPpositiongraphic##1##2%
+ {{% new, see (techniek)
+ \def\@@meta{##1:}%
+ \setupMPvariables[#2,##2]%
+ \prepareMPpositionvariables
+ % and needed
+ \getvalue{MPG:##1}}}% temp hack
+ \setbox\positiongraphicbox\hbox
+ {\ignorespaces
+ \executeifdefined{MPM:#1}{\executeifdefined{MPG:#1}\donothing}%
+ \removelastspace}%
+ \smashbox\positiongraphicbox
+ \box\positiongraphicbox
+ \egroup}
+
+\long\def\startMPpositionmethod#1#2\stopMPpositionmethod
+ {\long\setgvalue{MPM:#1}{#2}} % todo: var list here
+
+%D Simple one position graphics.
+
+\def\setMPpositiongraphic
+ {\dotriplegroupempty\dosetMPpositiongraphic}
+
+\def\dosetMPpositiongraphic#1#2#3% pos tag vars
+ {\ifx\currentpositionoverlay\empty
+ \dosetpositionaction{#1}{\MPpositiongraphic{#2}{#3}}%
+ \else % silly can be one
+ \handlepositiongraphics{#1}{#2}{#3}%
+ \fi}
+
+\def\handlepositiongraphics#1#2#3% combine with boxes
+ {\handlepositionaction\dohandleMPpositiongraphic\with{#1}{#2}{#3}\on{#2}}
+
+\def\doinsertMPpositiongraphic#1#2#3% pos tag setups
+ {\ifnum\MPp{#1}=\realpageno\relax % extra saveguard
+ \def\currentposition{#1}\MPpositiongraphic{#2}{#3}%
+ \fi}
+
+\appendtoks
+ \let\dohandleMPpositiongraphic\doinsertMPpositiongraphic
+\to \everyinsertpositionaction
+
+\def\docleanMPpositiongraphic#1#2#3% pos tag setups
+ {\ifnum\MPp{#1}<\realpageno \else
+ \noexpand \dohandleMPpositiongraphic{#1}{#2}{#3}%
+ \fi}
+
+\appendtoks
+ \let\dohandleMPpositiongraphic\docleanMPpositiongraphic
+\to \everycleanpositionaction
+
+%D Graphics that span two positions.
+
+\def\setMPpositiongraphicrange
+ {\doquadruplegroupempty\dosetMPpositiongraphicrange}
+
+\def\dosetMPpositiongraphicrange#1#2#3#4% bpos epos tag vars
+ {\ifx\currentpositionoverlay\empty
+ \dosetpositionaction{#1}{\MPpositiongraphic{#3}{#4}}%
+ \else
+ \handlepositiongraphicsrange{#1}{#2}{#3}{#4}%
+ \fi}
+
+\def\handlepositiongraphicsrange#1#2#3#4%
+ {\handlepositionaction\dohandleMPpositiongraphicrange\with{#1}{#2}{#3}{#4}\on{#2}}
+
+\def\doinsertMPpositiongraphicrange#1#2#3#4% pos pos tag setups
+ {\ifnum\MPp{#1}\MPp{#2}>\zerocount
+ \iflocalpositioning
+ \donetrue
+ \else
+ \donefalse
+ \ifnum\MPp{#1}=\realpageno
+ \donetrue
+ \else\ifnum\MPp{#2}=\realpageno
+ \donetrue
+ \else\ifnum\MPp{#1}<\realpageno\relax\ifnum\MPp{#2}>\realpageno
+ \donetrue
+ \fi\fi\fi\fi
+ \fi
+ \ifdone
+ \def\currentposition{#1}\MPpositiongraphic{#3}{#4}%
+ \fi
+ \fi}
+
+\appendtoks
+ \let\dohandleMPpositiongraphicrange\doinsertMPpositiongraphicrange
+\to \everyinsertpositionaction
+
+\def\docleanMPpositiongraphicrange#1#2#3#4% pos tag setups
+ {\ifnum\MPp{#2}<\realpageno \else
+ \noexpand \dohandleMPpositiongraphicrange{#1}{#2}{#3}{#4}%
+ \fi}
+
+\appendtoks
+ \let\dohandleMPpositiongraphicrange\docleanMPpositiongraphicrange
+\to \everycleanpositionaction
+
+% will be overloaded, and/or code below moved to core-box
+
+\defineoverlay[\v!text-2][\positionoverlay{\v!text-2}]
+\defineoverlay[\v!text-1][\positionoverlay{\v!text-1}]
+\defineoverlay[\v!text+1][\positionoverlay{\v!text+1}]
+\defineoverlay[\v!text+2][\positionoverlay{\v!text+2}]
+
+%D The auxiliary \METAPOST\ macros are defined by default,
+%D by saying:
+
+\appendtoks
+ if unknown context_core : input mp-core.mp ; fi ;
+\to \MPextensions
+
+%D Some of these macros are pretty clever but too complicated
+%D to be nice. When things are kind of stable I'll clean up
+%D this mess.
+
+%D THIS NEEDS A CLEANUP
+
+\setupMPvariables
+ [mpos:box]
+ [linecolor=blue,
+ linewidth=\linewidth,
+ fillcolor=lightgray,
+ filloffset=\!!zeropoint]
+
+\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth}
+ initialize_box(\MPpos{\MPvar{self}}) ;
+ boxfillcolor := \MPvar{fillcolor} ;
+ boxlinecolor := \MPvar{linecolor} ;
+ boxlinewidth := \MPvar{linewidth} ;
+ boxfilloffset := \MPvar{filloffset} ;
+ draw_box ;
+ anchor_box(\MPanchor{\MPvar{self}}) ;
+\stopMPpositiongraphic
+
+\setupMPvariables
+ [mpos:area]
+ [linecolor=blue,
+ linewidth=\linewidth,
+ fillcolor=lightgray,
+ filloffset=\!!zeropoint]
+
+\startMPpositiongraphic{mpos:area}{fillcolor,linecolor,linewidth}
+ initialize_area(\MPpos{b:\MPvar{self}},\MPpos{e:\MPvar{self}}) ;
+ boxfillcolor := \MPvar{fillcolor} ;
+ boxlinecolor := \MPvar{linecolor} ;
+ boxlinewidth := \MPvar{linewidth} ;
+ boxfilloffset := \MPvar{filloffset} ;
+ draw_area ;
+ anchor_area(\MPanchor{b:\MPvar{self}}) ;
+\stopMPpositiongraphic
+
+%D This is already cleaned up.
+
+% gridtype = 1 => baseline
+% gridtype = 2 => betweenline
+
+\setupMPvariables
+ [mpos:par]
+ [mp=mpos:par:shape,
+ gridtype=0,
+ linetype=1,
+ filltype=1,
+ %snaptops=true, % not that nice: true/false
+ gridcolor=red,
+ linecolor=blue,
+ fillcolor=lightgray,
+ filloffset=\!!zeropoint,
+ linewidth=\linewidth,
+ gridwidth=\linewidth,
+ lineradius=.5\bodyfontsize]
+
+\startuseMPgraphic{mpos:par:shape}
+ \iftracepositions show_par \else draw_par \fi ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{mpos:par:setup}
+ boxgridtype := \MPvar{gridtype} ;
+ boxlinetype := \MPvar{linetype} ;
+ boxfilltype := \MPvar{filltype} ;
+ boxgridcolor := \MPvar{gridcolor} ;
+ boxlinecolor := \MPvar{linecolor} ;
+ boxfillcolor := \MPvar{fillcolor} ;
+ boxfilloffset := \MPvar{filloffset} ;
+ boxlinewidth := \MPvar{linewidth} ;
+ boxgridwidth := \MPvar{gridwidth} ;
+ boxlineradius := \MPvar{lineradius} ;
+ %snap_multi_par_tops := \MPvar{snaptops} ;
+\stopuseMPgraphic
+
+\startuseMPgraphic{mpos:par:extra}
+ % user stuff, like:
+ % snap_multi_par_tops := false ;
+\stopuseMPgraphic
+
+% \startMPpositionmethod{mpos:par}
+% \doifpositionelse{w:\MPvar{self}}
+% {\startMPpositiongraphic{mpos:par}%
+% {fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,lineradius}
+% initialize_area_par(\MPpos{b:\MPvar{self}},
+% \MPpos{e:\MPvar{self}},
+% \MPpos{w:\MPvar{self}}) ;
+% \includeMPgraphic{mpos:par:setup} ;
+% \includeMPgraphic{mpos:par:extra} ;
+% \includeMPgraphic{\MPvar{mp}} ; % \includeMPgraphic{mpos:par:shape} ;
+% anchor_par(\MPanchor{b:\MPvar{self}}) ;
+% \stopMPpositiongraphic}
+% {\startMPpositiongraphic{mpos:par}%
+% {fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,lineradius}
+% initialize_par(\MPpos{b:\MPvar{self}},
+% \MPpos{e:\MPvar{self}},
+% \MPpos{text:\realfolio},
+% \MPpos{p:\MPparcounter},
+% \MPvv {p:\MPparcounter}{0,0,0,0,0,0}) ;
+% \includeMPgraphic{mpos:par:setup} ;
+% \includeMPgraphic{mpos:par:extra} ;
+% \includeMPgraphic{\MPvar{mp}} ; % \includeMPgraphic{mpos:par:shape} ;
+% anchor_par(\MPanchor{b:\MPvar{self}}) ;
+% \stopMPpositiongraphic}%
+% \MPpositiongraphic{mpos:par}{}%
+% \stopMPpositionmethod
+
+%D Less readable but shorter.
+
+\ifx\MPparcounter\undefined \newcounter\MPparcounter \fi
+
+\def\MPself {\MPvar{self}}
+\def\MPbself {b:\MPself}
+\def\MPeself {e:\MPself}
+\def\MPwself {w:\MPself}
+\def\MPparanchor{p:\MPparcounter}
+
+\def\MPl#1{\MPplus{#1}20}
+\def\MPr#1{\MPplus{#1}30}
+
+\startMPpositionmethod{mpos:par} %%%%%%%%%%% will become obsolete
+ \edef\MPparcounter{\MPv\MPbself{1}{0}}%
+ \doifpositionelse\MPwself
+ {\startMPpositiongraphic{mpos:par}%
+ {fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,lineradius}
+ initialize_area_par(\MPpos\MPbself,
+ \MPpos\MPeself,
+ \MPpos\MPwself) ;
+ \includeMPgraphic{mpos:par:setup} ;
+ \includeMPgraphic{mpos:par:extra} ;
+ \includeMPgraphic{\MPvar{mp}} ;
+ anchor_par(\MPanchor\MPbself) ;
+ \stopMPpositiongraphic}
+ {\startMPpositiongraphic{mpos:par}%
+ {fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,lineradius}
+ initialize_par(\MPpos\MPbself,
+ \MPpos\MPeself,
+ \MPpos\textanchor,
+ \MPpos\MPparanchor,
+ \MPvv \MPparanchor{0,0,0,0,0,0}) ;
+ \includeMPgraphic{mpos:par:setup} ;
+ \includeMPgraphic{mpos:par:extra} ;
+ \includeMPgraphic{\MPvar{mp}} ;
+ anchor_par(\MPanchor\MPbself) ;
+ \stopMPpositiongraphic}%
+ \MPpositiongraphic{mpos:par}{}%
+\stopMPpositionmethod
+
+%D The next alternative works in columnsets :
+
+% \iftracepositions show\else draw\fi_multi_pars ;
+
+\startuseMPgraphic{mpos:par:columnset}
+ \iftracepositions show_multi_pars \else draw_multi_pars \fi ;
+\stopuseMPgraphic
+
+\startMPpositionmethod{mpos:par:columnset}
+ \edef\MPparcounter{\MPv\MPbself{1}{0}}%
+ \startMPpositiongraphic{mpos:par}%
+ {fillcolor,filloffset,linecolor,gridcolor,%
+ linewidth,gridwidth,lineradius}
+ \includeMPgraphic{mpos:par:setup} ;
+ \includeMPgraphic{mpos:par:extra} ;
+ prepare_multi_pars(\MPpos\MPbself,\MPpos\MPeself,\MPpos\MPwself,
+ \MPpos\MPparanchor,\MPvv\MPparanchor{0,0,0,0,0,0}) ;
+ relocate_multipars(-\MPxy\MPanchorid) ; % inside layerpos
+ \includeMPgraphic{\MPvar{mp}} ;
+ \stopMPpositiongraphic
+ \MPpositiongraphic{mpos:par}{}%
+\stopMPpositionmethod
+
+%D \starttyping
+%D \setupbackground
+%D [test]
+%D [mp=mpos:par:columnset,
+%D methodmethode=mpos:par:columnset]
+%D \stoptyping
+
+%D We need to treat floats in a special way.
+
+\appendtoks
+ local_multi_par_area:=\iflocalpositioning true\else false\fi;
+\to \MPinitializations
+
+\def\textbackgroundoverlay#1%
+ {\iflocalpositioning\v!local\else\v!text\fi#1}
+
+\newcounter\localpositionnumber
+
+\def\MPanchornumber
+ {\iflocalpositioning\localpositionnumber\else\realfolio\fi}
+
+%D So far for the trickery.
+
+\newcounter\textbackgrounddepth
+
+\appendtoks
+ \savecurrentvalue\totalnofparbackgrounds\nofparbackgrounds
+\to \everybye
+
+\appendtoks
+ \initializeparbackgrounds
+\to \everystarttext
+
+\ifx\totalnofparbackgrounds\undefined \newcounter\totalnofparbackgrounds \fi
+\ifx\nofparbackgrounds \undefined \newcounter\nofparbackgrounds \fi
+
+\def\initializeparbackgrounds
+ {\ifcase\totalnofparbackgrounds\else
+ \global\positioningtrue
+ \global\positioningpartrue
+ \fi}
+
+\unexpanded\def\starttextbackground
+ {\bgroup
+ \increment\textbackgrounddepth
+ \dodoubleempty\dostarttextbackground}
+
+\let\dodostarttextbackground\relax
+\let\dodostoptextbackground \relax
+
+\def\currentparbackground{pbg:0}
+\def\nextparbackground {pbg:1}
+
+\def\btbanchor{b:\currentparbackground}
+\def\etbanchor{e:\currentparbackground}
+
+\def\nextbtbanchor{b:\nextparbackground}
+\def\nextetbanchor{e:\nextparbackground}
+
+\def\backgroundvariable#1%
+ {\csname\??td\currenttextbackground#1\endcsname}
+
+% \definetextbackground[more][state=start,backgroundcolor=red] % location=paragraph
+% \definetextbackground[test][state=start,backgroundcolor=green]
+%
+% \page \placefigure[left]{}{}
+%
+% \starttextbackground[test]
+% \readfile{ward}{}{}
+% \starttextbackground[more]
+% \readfile{ward}{}{}
+% \stoptextbackground
+% \readfile{ward}{}{}
+% \stoptextbackground
+%
+% \page \placefigure[right]{}{}
+%
+% \starttextbackground[test]
+% \readfile{ward}{}{}
+% \starttextbackground[more]
+% \readfile{ward}{}{}
+% \stoptextbackground
+% \readfile{ward}{}{}
+% \stoptextbackground
+
+\def\dostarttextbackground[#1][#2]%
+ {\checktextbackgrounds
+ \def\currenttextbackground{#1}%
+ \doglobal\increment\nofparbackgrounds
+ %\edef\currentparbackground{background:\nofparbackgrounds}%
+ \edef\currentparbackground{pbg:\nofparbackgrounds}%
+ \bgroup
+ \increment\nofparbackgrounds
+ %\xdef\nextparbackground{background:\nofparbackgrounds}%
+ \xdef\nextparbackground{pbg:\nofparbackgrounds}%
+ \egroup
+ % todo : \synchonizepositionpage{b:\currentparbackground}{s:\currentparbackground}%
+ \setuptextbackground[#1][#2]%
+ \let\dodostarttextbackground\relax
+ \let\dodostoptextbackground \relax
+ \doifvalue{\??td#1\c!state}\v!start
+ {\dopresettextbackground{#1}}%
+ \dodostarttextbackground}
+
+% todo \backgroundvariable\c!variant
+
+\def\dopresettextbackground#1% todo: \backgroundparameter
+ {\ExpandFirstAfter\processaction % \EFA niet echt nodig
+ [\getvalue{\??td#1\c!location}]
+ [ \v!text=>\let\dodostarttextbackground\dostarttextbackgroundtxt
+ \let\dodostoptextbackground \dostoptextbackgroundtxt,
+ \v!paragraph=>\let\dodostarttextbackground\dostarttextbackgroundpar
+ \let\dodostoptextbackground \dostoptextbackgroundpar,
+ \v!none=>\let\dodostarttextbackground\relax
+ \let\dodostoptextbackground \relax]%
+ \ifx\dodostarttextbackground\dostarttextbackgroundpar % untested
+ \ifnum\textbackgrounddepth>\plusone % new
+ \let\dodostarttextbackground\dostarttextbackgroundtxt
+ \let\dodostoptextbackground \dostoptextbackgroundtxt
+ \fi
+ \fi
+ \doifelsevalue{\??td#1\c!frame}\v!on
+ {\doifelsevalue{\??td#1\c!corner}\v!round
+ {\setvalue{\??td#1\c!frame}{2}}
+ {\setvalue{\??td#1\c!frame}{1}}}
+ {\setvalue{\??td#1\c!frame}{0}}%
+ \doifelsevalue{\??td#1\c!background}\v!color
+ {\setvalue{\??td#1\c!background}{1}}
+ {\setvalue{\??td#1\c!background}{0}}%
+ %\startpositionoverlay{\v!text\getvalue{\??td#1\c!level}}%
+ \startpositionoverlay{\textbackgroundoverlay{\getvalue{\??td#1\c!level}}}%
+ \expanded
+ {\setMPpositiongraphicrange % moet veel efficienter
+ {\btbanchor}% {b:\currentparbackground}%
+ {\etbanchor}% {e:\currentparbackground}%
+ {\getvalue{\??td#1\c!method}}%
+ {self=\currentparbackground,
+ mp=\getvalue{\??td#1\c!mp},
+ gridtype=\getvalue{\??td#1\c!alternative},
+ filltype=\getvalue{\??td#1\c!background},
+ linetype=\getvalue{\??td#1\c!frame},
+ gridcolor=\getvalue{\??td#1\c!framecolor},
+ linecolor=\getvalue{\??td#1\c!framecolor},
+ fillcolor=\getvalue{\??td#1\c!backgroundcolor},
+ filloffset=\getvalue{\??td#1\c!backgroundoffset},
+ gridwidth=\getvalue{\??td#1\c!rulethickness},
+ linewidth=\getvalue{\??td#1\c!rulethickness},
+ lineradius=\getvalue{\??td#1\c!radius}}}%
+ \stoppositionoverlay}
+
+\def\stoptextbackground
+ {\dodostoptextbackground
+ \carryoverpar\egroup}
+
+\def\starttextbackgroundmanual
+ {\dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
+ \fpos\currentparbackground\ignorespaces}
+
+\def\stoptextbackgroundmanual
+ {\tpos\currentparbackground
+ \dostopattributes}
+
+\def\dostarttextbackgroundtxt
+ {\ifvmode \leavevmode \fi
+ \dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
+ \fpos\currentparbackground\ignorespaces}
+
+\def\dostoptextbackgroundtxt
+ {\tpos\currentparbackground
+ \dostopattributes}
+
+% keep this simple one, it's used in prikkels and alike
+%
+% \def\dostarttextbackgroundpar
+% {\endgraf % new
+% \getvalue{\??td\currenttextbackground\c!before}%
+% \noindent\fpos\currentparbackground\ignorespaces
+% \bgroup
+% \nobreak \vskip-\lineheight \nobreak
+% \doassignsomeskip\getvalue{\??td\currenttextbackground\c!topoffset}\to\scratchskip
+% \kern\scratchskip\nobreak
+% \dosetleftskipadaption{\getvalue{\??td\currenttextbackground\c!leftoffset}}%
+% \advance\leftskip\leftskipadaption
+% \dosetleftskipadaption{\getvalue{\??td\currenttextbackground\c!rightoffset}}%
+% \advance\rightskip\leftskipadaption
+% \dostartattributes{\??td\currenttextbackground}\c!style\c!color{}%
+% \nowhitespace
+% \seteffectivehsize
+% \par}
+%
+% \def\dostoptextbackgroundpar
+% {\par
+% \dostopattributes
+% \doassignsomeskip\getvalue{\??td\currenttextbackground\c!bottomoffset}\to\scratchskip
+% \kern\scratchskip\nobreak
+% \nobreak \vskip-\lineheight \nobreak
+% \nowhitespace
+% \egroup
+% \nobreak \noindent \strut \hfill \kern\zeropoint \tpos\currentparbackground
+% \endgraf % new
+% \getvalue{\??td\currenttextbackground\c!after}}
+
+\def\dostarttextbackgroundpar
+ {\endgraf % new
+ \getvalue{\??td\currenttextbackground\c!before}%
+ \doassignsomeskip\getvalue{\??td\currenttextbackground\c!topoffset}\to\scratchskip
+ \xdef\textbackgroundskip{\the\scratchskip}%
+ \noindent
+ \ifgridsnapping
+ \ifdim\textbackgroundskip>\zeropoint
+ \struttedbox{\hbox{\raise\textbackgroundskip\hbox{\fpos\currentparbackground}}}%
+ \else
+ \fpos\currentparbackground
+ \fi
+ \else
+ \fpos\currentparbackground
+ \fi
+ \bgroup
+ \endgraf % we need a vertical nobreak - 29/06/2004
+ \nobreak \vskip-\lineheight \nobreak
+ \doassignsomeskip\getvalue{\??td\currenttextbackground\c!topoffset}\to\scratchskip
+ \ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint
+ \kern\textbackgroundskip\nobreak
+ \fi \fi
+ \dosetleftskipadaption{\getvalue{\??td\currenttextbackground\c!leftoffset}}%
+ \advance\leftskip\leftskipadaption
+ \dosetleftskipadaption{\getvalue{\??td\currenttextbackground\c!rightoffset}}%
+ \advance\rightskip\leftskipadaption
+ % new
+ \dosetraggedcommand{\getvalue{\??td\currenttextbackground\c!align}}%
+ \raggedcommand
+ %
+ \dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
+ \nowhitespace
+ \seteffectivehsize
+ \doinhibitblank % \blank[\v!disable]% new
+ \par}
+
+\def\dostoptextbackgroundpar
+ {\par
+ \removelastskip % new
+ \dostopattributes
+ \doassignsomeskip\getvalue{\??td\currenttextbackground\c!bottomoffset}\to\scratchskip
+ \ifdim\lastskip>\zeropoint
+ \advance\scratchskip-\lastskip
+ \fi
+ \xdef\textbackgroundskip{\the\scratchskip}%
+ \ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint
+ \kern\scratchskip\nobreak
+ \fi \fi
+ \nobreak \vskip-\lineheight \nobreak
+ \nowhitespace
+ \egroup
+\bgroup \forgeteverypar % NOT REALLY NEEDED, SAVES HASH/MEM
+ \nobreak \noindent \strut \hfill \kern\zeropoint
+ \ifgridsnapping % experimental, pascal (todo: topoffset in same way)
+ \ifdim\textbackgroundskip>\zeropoint
+ \struttedbox{\hbox{\lower\textbackgroundskip\hbox{\tpos\currentparbackground}}}%
+ \else
+ \tpos\currentparbackground
+ \fi
+ \else
+ \tpos\currentparbackground
+ \fi
+\egroup
+ \endgraf % new
+ \getvalue{\??td\currenttextbackground\c!after}}
+
+\let\textparpages \!!zeropoint
+\let\textparheight\!!zeropoint
+\let\textparwidth \!!zeropoint
+
+\def\calculatetextpardimensions
+ {\docalculatetextpardimensions\btbanchor \etbanchor \MPparanchor}
+
+\def\calculatenexttextpardimensions
+ {\docalculatetextpardimensions\nextbtbanchor\nextetbanchor\relax}
+
+\def\docalculatetextpardimensions#1#2#3%
+ {\scratchcounter\MPp#2%\etbanchor
+ \advance\scratchcounter-\MPp#1%\btanchor
+ \edef\textparpages{\the\scratchcounter}%
+ \ifcase\scratchcounter
+ % one page
+ \scratchdimen \MPy#1%\btanchor
+ \advance\scratchdimen-\MPy#2%\etbanchor
+ \else
+ % two or more pages
+ \scratchdimen \MPy#1%\btanchor
+ \advance\scratchdimen-\MPy#2%\etbanchor
+ \advance\scratchdimen-\MPy\textanchor
+ \advance\scratchdimen \MPy\textanchor
+ \advance\scratchdimen \MPh\textanchor\relax
+ \ifcase\scratchcounter>2 \ifnum\scratchcounter<5
+ % more pages
+ \scratchdimen\textheight
+ \advance\scratchcounter \minusone
+ \multiply\scratchdimen \scratchcounter
+ \else
+ % keep'm small
+ \scratchdimen5\textheight
+ \fi \fi
+ \fi
+ \edef\textparheight{\the\scratchdimen}%
+ \ifcase\scratchcounter
+ % one page
+ \scratchdimen \MPx#2%\etbanchor
+ \advance\scratchdimen-\MPx#1%\btanchor
+ \else
+ % two or more pages / maybe also hang
+ \ifx#3\relax
+ \scratchdimen\makeupwidth % \textwidth
+ \else
+ \scratchdimen\MPw\MPparanchor
+ \advance\scratchdimen-\MPl\MPparanchor
+ \advance\scratchdimen-\MPr\MPparanchor
+ \fi
+ \fi
+ \edef\textparwidth{\the\scratchdimen}}
+
+\def\mintextparheight{4\lineheight}
+
+\def\dontsplitnexttextbackground % dangerous but useful
+ {\ifdim\pagetotal>\textheight \else
+ \ifdim\pagegoal=\maxdimen \else
+ \calculatenexttextpardimensions
+ % too tricky
+ % \scratchdimen=\textparheight
+ % \advance\scratchdimen\pagetotal\relax
+ % \ifdim\scratchdimen>\pagegoal
+ % \page
+ % \fi
+ \ifdim\textparheight>\zeropoint
+ \ifdim\textparheight>\mintextparheight\else
+ \page % option
+ \fi
+ \fi
+ \fi
+ \fi}
+
+\def\definetextbackground
+ {\dodoubleempty\dodefinetextbackground}
+
+\def\dodefinetextbackground[#1][#2]%
+ {\ifsecondargument % why ?
+ \copyparameters[\??td#1][\??td]
+ [\c!state,\c!location,\c!alternative,\c!mp,\c!method,
+ \c!background,\c!backgroundcolor,\c!corner,\c!level,
+ \c!backgroundoffset,\c!before,\c!after,\c!align,
+ \c!radius,\c!frame,\c!framecolor,\c!rulethickness,
+ \c!leftoffset,\c!rightoffset,\c!topoffset,\c!bottomoffset]%
+ \getparameters[\??td#1][#2]%
+ \doifvalue{\??td#1\c!state}\v!start\checktextbackgrounds
+ \unexpanded\setvalue{#1}%
+ {\groupedcommand{\starttextbackground[#1]}{\stoptextbackground}}%
+ \setvalue{\e!start#1}{\starttextbackground[#1]}%
+ \setvalue{\e!stop #1}{\stoptextbackground}%
+ \fi}
+
+\def\setuptextbackground
+ {\dodoubleargument\dosetuptextbackground}
+
+\def\dosetuptextbackground[#1][#2]%
+ {\ifsecondargument
+ \doifelsenothing{#1}
+ {\dodosetuptextbackground{#2}\empty}
+ {\processcommalist[#1]{\dodosetuptextbackground{#2}}}%
+ \else
+ \dodosetuptextbackground{#1}\empty
+ \fi}
+
+\def\dodosetuptextbackground#1#2%
+ {\getparameters[\??td#2][#1]%
+ \def\currenttextbackground{#2}%
+ \doifvalue{\??td#2\c!state}\v!start\checktextbackgrounds}
+
+\let\currenttextbackground\empty
+
+\def\checktextbackgrounds
+ {\ifproductionrun
+ \enabletextarearegistration
+ \enablehiddenbackground
+ \fi}
+
+\setuptextbackground
+ [\c!mp=mpos:par:columnset, % buggy: mpos:par:shape
+ \c!method=mpos:par:columnset, %
+ \c!state=\v!start,
+ \c!location=\v!text,
+ \c!leftoffset=\!!zeropoint, % 1em,
+ \c!rightoffset=\getvalue{\??td\currenttextbackground\c!leftoffset},
+ \c!topoffset=\!!zeropoint, % \v!medium,
+ \c!bottomoffset=\getvalue{\??td\currenttextbackground\c!topoffset},
+ \c!level=-1,
+ \c!alternative=0,
+ \c!align=,
+ \c!background=\v!color,
+ \c!backgroundcolor=lightgray,
+ \c!backgroundoffset=\!!zeropoint,
+ \c!corner=\v!rectangular,
+ \c!radius=.5\bodyfontsize,
+ \c!frame=\v!on,
+ \c!framecolor=blue,
+ \c!rulethickness=\linewidth]
+
+%D As an example we define a grid background:
+
+\definetextbackground
+ [\v!grid]
+ [\c!state=\v!stop,
+ \c!location=\v!paragraph,
+ \c!frame=\v!off,
+ \c!framecolor=red,
+ \c!background=,
+ \c!alternative=1]
+
+\ifx\basegrid\undefined \else \letvalue\v!grid=\basegrid \fi
+
+% lelijk, aanpassen, opties
+
+\setupMPvariables
+ [mpos:connect]
+ [linecolor=red,
+ linewidth=1pt]
+
+\setupMPvariables
+ [mpos:encircle]
+ [fillcolor=lightgray,
+ filloffset=\!!zeropoint,
+ linecolor=blue,
+ linewidth=1pt]
+
+\startuseMPgraphic{mpos:common:ec}
+ path pa ; pair ca ; color lc ; numeric lw ;
+ lw := \MPvar{linewidth} ;
+ lc := \MPvar{linecolor} ;
+ initialize_box(\MPpos{\MPvar{self}}) ;
+ pa := pxy ; ca := cxy ; pa := boundingbox pa enlarged 2lw ;
+ pa := llcorner pa...lrcorner pa...urcorner pa...ulcorner pa...cycle ;
+ drawoptions (withpen pencircle scaled lw withcolor lc) ;
+\stopuseMPgraphic
+
+\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth}
+ \includeMPgraphic{mpos:common:ec}
+ fill pa withcolor \MPvar{fillcolor} ; draw pa ;
+ anchor_box(\MPanchor{\MPvar{self}}) ;
+\stopMPpositiongraphic
+
+\startMPpositiongraphic{mpos:connect}{linecolor,linewidth}
+ path pb, pc ; pair cb, cc ;
+ \includeMPgraphic{mpos:common:ec}
+ initialize_box(\MPpos{\MPvar{to}}) ;
+ pb := pxy ; cb := cxy ; pb := boundingbox pb enlarged 2lw ;
+ pb := llcorner pb...lrcorner pb...urcorner pb...ulcorner pb...cycle ;
+ pc := ca {up} .. {down} cb ;
+ cc := (pc intersection_point pa) ;
+ if intersection_found :
+ pc := pc cutbefore cc ;
+ cc := (pc intersection_point pb) ;
+ if intersection_found :
+ pc := pc cutafter cc ;
+ drawarrow pc ; drawarrow reverse pc ;
+ fi ;
+ fi ;
+ anchor_box(\MPanchor{\MPvar{self}}) ;
+\stopMPpositiongraphic
+
+%D \macros
+%D {stackposdown, stackposup, stackposleft,stackposright}
+%D
+%D A non graphic example of the use of positioning, is to stack
+%D text in for instance the margin.
+%D
+%D \stackposdown \inleft {some text}The text \type {some text}
+%D goes into the left margin, and \stackposdown \inleft {some
+%D more}\type {some more} as well. When they overlap, they
+%D will not touch.
+%D
+%D Here we said \type {\stackposdown \inleft{some text}}. Instead
+%D of \stackposleft \inleft {one}stacking \stackposleft \inleft
+%D {two}vertically, one can stack horizontally by \stackposleft
+%D \inleft {three}using \type {\stackposleft}.
+%D
+%D We can go in all four directions, using \type {\stackposdown},
+%D \type {\stackposup}, \type {\stackposleft} and \type
+%D {\stackposright}.
+
+\def\stackposdistance{.5em}
+
+\newcounter\currentautopos
+
+\def\POSstackprefix{stack:}
+
+\def\dostackposbox#1#2%
+ {\dowithnextbox
+ {#2{\let\previousautopos\currentautopos
+ \doglobal\increment\currentautopos
+ \hpos{\POSstackprefix\currentautopos}
+ {\doifoverlappingelse{\POSstackprefix\currentautopos}{\POSstackprefix\previousautopos}
+ {#1}
+ {\flushnextbox}}}}%
+ \hbox}
+
+\def\stackposup {\dostackposbox{\raise\lineheight\flushnextbox}}
+\def\stackposdown {\dostackposbox{\lower\lineheight\flushnextbox}}
+\def\stackposleft {\dostackposbox{\copy\nextbox\hskip\nextboxwd\hskip\stackposdistance}}
+\def\stackposright{\dostackposbox{\hskip\stackposdistance\hskip\nextboxwd\flushnextbox}}
+
+%D \macros
+%D {stackeddown}
+%D
+%D However, a better implementation is possible with the
+%D following macro. We now have an extra key \type {stack} for
+%D margin settings. When set to \type {yes}, this macro comes
+%D into action.
+
+% \def\stackeddown
+% {\dowithnextbox
+% {\doglobal\increment\currentautopos
+% \hpos{\POSstackprefix\currentautopos}
+% {\edef\next
+% {\nextboxht\the\nextboxht
+% \nextboxdp\the\nextboxdp
+% \nextboxwd\the\nextboxwd}%
+% \let\previousautopos\currentautopos
+% \scratchdimen\zeropoint
+% \doloop
+% {\decrement\previousautopos
+% \doifoverlappingelse{\POSstackprefix\currentautopos}{\POSstackprefix\previousautopos}
+% {\advance\scratchdimen\MPh{\POSstackprefix\previousautopos}%
+% \advance\scratchdimen\MPd{\POSstackprefix\previousautopos}}%
+% \exitloop
+% \ifnum\previousautopos<\zerocount\exitloop\fi}%
+% % \ifdim\scratchdimen>\zeropoint
+% \setbox\nextbox\iftracepositions\@EA\ruledhbox\else\@EA\hbox\fi
+% {\lower\scratchdimen\flushnextbox}%
+% \next
+% % \fi
+% \flushnextbox}}}
+
+% Because there can be many stacked items in a line and successive lines, we
+% play dirty and adapt the position and height of the current node so that
+% this becomes visible to a next pass.
+%
+% \startbuffer
+% \inleft {test 1} test 1 \inleft {test 2} test 2 \endgraf
+% \inleft {test 3} test 3
+% \stopbuffer
+% \getbuffer \typebuffer \flushstatus \page
+%
+% \startbuffer
+% \inleft {test 1} test 1 \inleft {test 2} test 2 \inleft {test 3} test 3 \endgraf
+% \inleft {test 4} test 4
+% \stopbuffer
+% \getbuffer \typebuffer \flushstatus \page
+%
+% \startbuffer
+% \inleft {test 1} test 1 \endgraf
+% \inleft {test 2} test 2 \endgraf
+% \inleft {test 3} test 3
+% \stopbuffer
+% \getbuffer \typebuffer \flushstatus \page
+%
+% \startbuffer
+% \inleft {test 1\\test 1} test 1 \inleft {test 2} test 2 \endgraf
+% \inleft {test 3} test 3
+% \stopbuffer
+% \getbuffer \typebuffer \flushstatus \page
+%
+% \startbuffer
+% \inleft {test 1\\test 1\\test 1\\test 1\\test 1} test 1 \endgraf
+% test 2 \endgraf
+% \inleft {test 3} test 3
+% \stopbuffer
+% \getbuffer \typebuffer \flushstatus \page
+%
+% \startbuffer
+% \inleft{test 1} test \inleft{test 2} test \inleft{test 3\\test 3} test
+% \stopbuffer
+% \getbuffer \typebuffer \flushstatus \page
+%
+% \startbuffer
+% \inleft{test 1\\test 1\\test 1} test \inleft{test 2\\test 2} test \inleft{test 3\\test 3\\test 3} test \endgraf
+% \inleft{test 1\\test 1\\test 1} test \inleft{test 2\\test 2} test \inleft{test 3\\test 3\\test 3} test
+% \stopbuffer
+% \getbuffer \typebuffer \flushstatus \page
+
+\newdimen\laststackvmove
+
+\def\stackeddown
+ {\bgroup
+ % this macro assumes a few things and is meant to work for margin notes
+ \dowithnextbox
+ {\doglobal\increment\currentautopos
+ \global\laststackvmove\zeropoint
+ \hpos{\POSstackprefix\currentautopos}
+ {\edef\next
+ {\nextboxht\the\nextboxht
+ \nextboxdp\the\nextboxdp
+ \nextboxwd\the\nextboxwd}%
+ \let\previousautopos\currentautopos
+ \scratchdimen\zeropoint
+ \scratchcounter\zerocount
+ \doloop
+ {\decrement\previousautopos\relax
+ \edef\currentposition {\POSstackprefix\currentautopos}%
+ \edef\previousposition{\POSstackprefix\previousautopos}%
+ \ifnum\MPp\currentposition=\MPp\previousposition\relax
+ %\registerstatus{doing \currentautopos/\previousautopos}%
+ \doifoverlappingelse\currentposition\previousposition
+ {\scratchskip \MPy\currentposition
+ \advance\scratchskip-\MPy\previousposition
+ \advance\scratchskip-\MPd\currentposition % untested
+ \advance\scratchskip \MPd\previousposition % untested
+ \advance\scratchskip \MPh\currentposition
+ % todo: also take depth into account
+ \relax
+ \ifdim\scratchskip<\scratchdimen
+ %\registerstatus{no \the\scratchskip}%
+ \else
+ %\registerstatus{yes \the\scratchskip}%
+ \scratchdimen\scratchskip
+ \fi}%
+ \donothing % {\registerstatus{next}}%
+ \ifnum\previousautopos<\zerocount\exitloop\fi
+ \else
+ \exitloop
+ \fi}%
+ \ifdim\scratchdimen=\zeropoint \else
+ \bgroup
+ \edef\currentposition{\POSstackprefix\currentautopos}%
+ \scratchskip\scratchdimen
+ \advance\scratchskip\MPh\currentposition
+ \scratchdimen-\scratchdimen
+ \advance\scratchdimen\MPy\currentposition
+ %\registerstatus{old \currentautopos: \MPy\currentposition/\MPh\currentposition}%
+ \expanded{\replacepospxywhd
+ {\currentposition}{\MPp\currentposition}{\MPx\currentposition}{\the\scratchdimen}%
+ {\MPw\currentposition}{\the\scratchskip}{\MPd\currentposition}}%
+ %\registerstatus{new \currentautopos: \MPy\currentposition/\MPh\currentposition}%
+ \egroup
+ \global\laststackvmove\scratchdimen % new
+ \setbox\nextbox\iftracepositions\@EA\ruledhbox\else\@EA\hbox\fi
+ {\lower\scratchdimen\flushnextbox}%
+ \next
+ %\registerstatus{\strut}%
+ \fi
+ \flushnextbox}%
+ \egroup}}
+
+%D The next hack make sure that margin texts near faulty
+%D strutted lines are handled ok.
+
+\newif\ifrepositionmarginbox % \repositionmarginboxtrue
+
+\newcounter\currentmarginpos
+
+% \def\dopositionmarginbox#1%
+% {\bgroup
+% \ifrepositionmarginbox
+% \doglobal\increment\currentmarginpos
+% \setposition{\s!margin:\currentmarginpos}%
+% \scratchdimen=\MPy{\s!margin:\currentmarginpos}%
+% \doglobal\increment\currentmarginpos
+% \advance\scratchdimen by -\MPy{\s!margin:\currentmarginpos}%
+% \advance\scratchdimen by -\strutdp
+% \setbox#1=\hbox
+% {\setposition{\s!margin:\currentmarginpos}\raise\scratchdimen\box#1}%
+% \dp#1=\!!zeropoint
+% \ht#1=\!!zeropoint
+% \fi
+% \vadjust{\box#1}%
+% \egroup}
+
+\def\dopositionmarginbox#1% how about page boundaries !
+ {\bgroup
+ \ifrepositionmarginbox
+ \doglobal\increment\currentmarginpos
+ \setposition{\s!margin:\currentmarginpos}%
+ \scratchdimen\MPy{\s!margin:\currentmarginpos}%
+ \doglobal\increment\currentmarginpos
+ \advance\scratchdimen -\MPy{\s!margin:\currentmarginpos}%
+ \advance\scratchdimen -\strutdp
+ % new
+ \setbox#1\hbox
+ {\hskip-\MPx{\s!margin:\currentmarginpos}%
+ \hskip\MPx{head:\realfolio}%
+ \box#1}%
+ % so far
+ \setbox#1\hbox
+ {\setposition{\s!margin:\currentmarginpos}%
+ \raise\scratchdimen\box#1}%
+ \dp#1\zeropoint
+ \ht#1\zeropoint
+ \fi
+ \graphicvadjust{\box#1}%
+ \egroup}
+
+%D For a right menu, a sequence of calls to \type
+%D {right_menu_button} is generated.
+%D
+%D \starttyping
+%D right_menu_button (n, p, s=0/1/2, x, y, w, h, d) ;
+%D \stoptyping
+%D
+%D Here, n is the number of the button, s a status variable,
+%D while the rest is positional info. The status variable is
+%D 0, 1 or~2: not found, found and found but current page.
+
+% 0=not found 1=found 2=current page
+
+% geen leeg
+
+\newtoks\MPmenutoks
+
+\def\MPmenubuttons#1{\the\MPmenutoks}
+
+\appendtoks \global\MPmenutoks\emptytoks \to \everyshipout
+
+% 0=notfound 1=found 2=currentpage
+
+\def\do@@amposition#1#2#3%
+ {\doifelsevalue{\??am#1\c!position}\v!yes
+ {\doglobal\increment\currentamposition
+ \doifnumberelse{#2}
+ {\docheckrealreferencepage{#2}%
+ \global\chardef\currentamrealpage\ifrealreferencepage2\else1\fi}
+ {\doifreferencefoundelse{#2}
+ {\global\chardef\currentamrealpage\ifrealreferencepage2\else1\fi}
+ {\global\chardef\currentamrealpage0}}% % not found
+ \expanded
+ {\doglobal\noexpand\appendtoks
+ #1_menu_button(\currentamposition,\the\currentamrealpage,\noexpand\MPpos{#1:\currentamposition}) ;
+ \to \MPmenutoks}%
+ \hpos{#1:\currentamposition}{#3}}
+ {#3}}
+
+\def\do@@ammenuposition#1%
+ {\ifnum\currentamposition>0
+ \dowithnextbox{\hpos{menu:#1:\realfolio}{\flushnextbox}}\hbox
+ \fi}
+
+%D \macros
+%D {GFC, GTC, GSC}
+%D
+%D The next macros extend tables and tabulation with
+%D backgrounds and position related features. Areas are
+%D specified with symbolic names, and symbolic references to
+%D the graphics involved. Each table has its own namespace.
+
+\newcounter\noftabpositions
+\newtoks \posXCtoks
+
+\def\tbPOSprefix
+ {tbp:\noftabpositions:}
+
+\def\tablepos
+ {\scratchtoks\posXCtoks
+ \global\posXCtoks\emptytoks
+ \the\scratchtoks}
+
+\let\tabulatepos\tablepos
+
+\def\dodododoGSC[#1:#2]%
+ {\remappositionframed{#2}{\tbPOSprefix#1}%
+ \bpos{\tbPOSprefix#1}%
+ \doglobal\appendtoks\@EA\epos\@EA{\tbPOSprefix#1}\to\posXCtoks}
+
+\def\dododoGSC[#1:#2:#3]%
+ {\doglobal\appendtoks\dodododoGSC[#1:#2]\to\posXCtoks\NC}
+
+\def\dodoGSC[#1]%
+ {\def\docommando##1{\dododoGSC[##1:##1]}%
+ \processcommalist[#1]\docommando}
+
+\def\dodododoGFC[#1:#2:#3]%
+ {\remappositionframed{#2}{\tbPOSprefix#1}%
+ \bpos{\tbPOSprefix#1}}
+
+\def\dododoGFC[#1]%
+ {\def\docommando##1{\dodododoGFC[##1:##1]}%
+ \processcommalist[#1]\docommando}
+
+\def\dodoGFC[#1]%
+ {\doglobal\appendtoks\dododoGFC[#1]\to\posXCtoks\NC}
+
+\def\dododododoGTC[#1:#2]%
+ {\epos{\tbPOSprefix#1}}
+
+\def\dodododoGTC[#1]%
+ {\def\docommando##1{\dododododoGTC[##1:##1]}%
+ \processcommalist[#1]\docommando}
+
+\def\dododoGTC[#1]%
+ {\doglobal\appendtoks\dodododoGTC[#1]\to\posXCtoks}
+
+\def\dodoGTC[#1]%
+ {\doglobal\appendtoks\dododoGTC[#1]\to\posXCtoks\NC}
+
+\def\dodododoXC[#1#2]%
+ {\if#1>\dodoGFC [#2:#2]\else
+ \if#1+\dodoGFC [#2:#2]\else
+ \if#1<\dodoGTC [#2:#2]\else
+ \if#1-\dodoGTC [#2:#2]\else
+ \if#1=\dodoGSC [#2:#2]\else
+ \dodoGSC[#1#2:#1#2]\fi\fi\fi\fi\fi}
+
+\def\dododoXC#1%
+ {\dodododoXC[#1]}
+
+\def\dodoXC[#1]%
+ {{\let\NC\relax\processcommalist[#1]\dododoXC}}
+
+\def\doGSC[#1]{\iffirstargument\dodoGSC[#1]\else\expandafter\NC\fi}
+\def\doGFC[#1]{\iffirstargument\dodoGFC[#1]\else\expandafter\NC\fi}
+\def\doGTC[#1]{\iffirstargument\dodoGTC[#1]\else\expandafter\NC\fi}
+\def\doXC [#1]{\iffirstargument\dodoXC [#1]\else\expandafter\fi\NC}
+
+\def\tbGSC{\dosingleempty\doGSC}
+\def\tbGFC{\dosingleempty\doGFC}
+\def\tbGTC{\dosingleempty\doGTC}
+\def\tbXC {\dosingleempty\doXC }
+
+%D The amount of code to support tables and tabulation is
+%D rather minimalistic.
+
+\let\tabulatepos\tablepos
+
+\def\tabulatenormalpos
+ {\hss\tabulatepos\hss}
+
+\def\tabulateequalpos
+ {\setbox\scratchbox\hbox{\tabulateEQ}%
+ \hbox to \wd\scratchbox{\hss\kern\zeropoint\tabulatepos\hss}%
+ \hskip-\wd\scratchbox
+ \box\scratchbox}
+
+\def\tabulatenormalcolumn#1% overloaded
+ {&\iftabulateequal\tabulateequalpos\else\tabulatenormalpos\fi
+ &\global\chardef\tabulatetype#1&}
+
+\def\tabulateequalcolumn#1% overloaded
+ {&\tabulateequalpos
+ &\global\chardef\tabulatetype#1&}
+
+\appendtoks
+ \doglobal\increment\noftabpositions
+\to \everytabulate
+
+%D In order to prevent potential clashes with abbreviations,
+%D postpone the mapping.
+
+\appendtoks
+ \let\GSC\tbGSC \let\GFC\tbGFC \let\GTC\tbGTC \let\XC\tbXC
+\to \everytabulate
+
+%D \macros
+%D {definepositionframed}
+%D
+%D The next example show how to provide backgrounds to table
+%D cells. First we define some framed backgrounds.
+%D
+%D \startbuffer
+%D \definepositionframed[x][background=color,backgroundcolor=red]
+%D \definepositionframed[y][background=color,backgroundcolor=green]
+%D \definepositionframed[z][background=color,backgroundcolor=blue]
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D % \getbuffer
+%D
+%D \startbuffer
+%D \starttabulate[|c|c|c|]
+%D \GFC[f:x] this is a small \NC table \NC in which we \NC \FR
+%D \NC will demonstrate \GFC[g:z] that this \GTC[g] positioning \NC \MR
+%D \GSC[e:y] mechanism also \GTC[f] works quite well \NC in tables \NC \LR
+%D \stoptabulate
+%D \stopbuffer
+%D
+%D The table itself defines three areas (a, b and~c) using
+%D these frames.
+%D
+%D \typebuffer
+%D % \getbuffer
+%D
+%D Tables (based on \TABLE) are supported by:
+
+\def\normalTABLEsimplebar {\unskip\!ttRightGlue&\tablepos&} % |
+\def\normalTABLEcomplexbar{\unskip\!ttRightGlue&\omit\tablepos\!ttAlternateVrule} % \|
+\def\normalTABLEquote {\unskip\!ttRightGlue&\omit\tablepos&} % "
+
+\appendtoks
+ \doglobal\increment\noftabpositions
+\to \everytable
+
+%D Since we don't want nameclashes:
+
+\appendtoks
+ \let\GSC\tbGSC \let\GFC\tbGFC \let\GTC\tbGTC \let\XC\tbXC
+\to \everytable
+
+%D In the previous example, we could have provided an overlay to
+%D the framed definition. A more direct approach is demonstrated
+%D below:
+%D
+%D \startbuffer
+%D \def\cw#1{\color[white]{#1}}
+%D
+%D \startMPpositiongraphic{tableshade}
+%D initialize_area(\MPpos{\MPvar{from}},\MPpos{\MPvar{to}}) ;
+%D color c ; c := \MPvar{color} ;
+%D linear_shade(pxy,0,.4c,.9c) ;
+%D anchor_area(\MPanchor{\MPvar{from}}) ;
+%D \stopMPpositiongraphic
+%D
+%D \setMPpositiongraphic{b:x}{tableshade}{from=b:x,to=e:x,color=red}
+%D \setMPpositiongraphic{b:y}{tableshade}{from=b:y,to=e:y,color=green}
+%D \setMPpositiongraphic{b:z}{tableshade}{from=b:z,to=e:z,color=blue}
+%D \stopbuffer
+%D
+%D \typebuffer \getbuffer
+%D
+%D The definition of the table looks about the same as the
+%D previous one:
+%D
+%D \startbuffer
+%D \starttable[|c|c|c|]
+%D \GFC[b:z] \cw{this is a small} \NC \cw{table} \NC in which we \NC \FR
+%D \NC \cw{will demonstrate} \GFC[c:y] \cw{that this} \GTC[c] \cw{positioning} \NC \MR
+%D \GSC[a:x] \cw{mechanism also} \GTC[b] \cw{works quite well} \NC in tables \NC \LR
+%D \stoptable
+%D \stopbuffer
+%D
+%D \typebuffer
+%D
+%D \getbuffer
+
+% \definepositionframed[w][background=color,backgroundcolor=yellow]
+% \definepositionframed[x][background=color,backgroundcolor=red]
+% \definepositionframed[y][background=color,backgroundcolor=green]
+% \definepositionframed[z][background=color,backgroundcolor=blue]
+%
+% \starttabulate[|c|c|c|]
+% \NC this is a small \NC table \NC in which we \NC \FR
+% \NC will demonstrate \NC that this \NC positioning \NC \MR
+% \NC mechanism also \NC works quite well \NC in tables \NC \LR
+% \stoptabulate
+%
+% \starttabulate[|c|c|c|]
+% \GFC[f:x] this is a small \GTC table \NC in which we \NC \FR
+% \NC will demonstrate \GFC[g:z] that this \GTC[g] positioning \NC \MR
+% \GSC[e:y] mechanism also \GTC[f] works quite well \NC in tables \NC \LR
+% \stoptabulate
+%
+% \starttabulate[|c|c|c|]
+% \GFC[f:x,d:w] this is a small \GTC[d] table \NC in which we \NC \FR
+% \NC will demonstrate \GFC[g:z] that this \GTC[g] positioning \NC \MR
+% \GSC[e:y] mechanism also \GTC[f] works quite well \NC in tables \NC \LR
+% \stoptabulate
+%
+% \starttabulate[|c|c|c|]
+% \XC[+f:x] this is a small \XC table \NC in which we \NC \FR
+% \NC will demonstrate \XC[+g:z] that this \XC[-g] positioning \NC \MR
+% \XC[=e:y] mechanism also \XC[-f] works quite well \NC in tables \NC \LR
+% \stoptabulate
+%
+% \starttabulate[|c|c|c|]
+% \XC[+f:x,+d:w] this is a small \XC[-d] table \NC in which we \NC \FR
+% \NC will demonstrate \XC[+g:z] that this \XC[-g] positioning \NC \MR
+% \XC[=e:y] mechanism also \XC[-f] works quite well \NC in tables \NC \LR
+% \stoptabulate
+
+% evt [b:x]
+%
+% \definepositionframed[x][background=color,fillcolor=red]
+% \definepositionframed[y][background=color,fillcolor=green]
+% \definepositionframed[z][background=color,fillcolor=blue]
+
+\def\remappositionframed#1#2% from to
+ {\copyposition{b:#1}{b:#2}%
+ \copyposition{e:#1}{e:#2}%
+ \dosetpositionaction{b:#2}{\dopositionaction{b:#1}}}
+
+\def\definepositionframed
+ {\dodoubleargument\dodefinepositionframed}
+
+\def\dodefinepositionframed[#1][#2]%
+ {\dosetpositionaction{b:#1}{\dopositionframed[#1][#2]}}
+
+\def\positionframed
+ {\dodoubleempty\dopositionframed}
+
+\def\dopositionframed[#1][#2]%
+ {\bgroup
+ \setbox\scratchbox\hbox
+ {\dimen0=\MPx{e:#1}%
+ \advance\dimen0 -\MPx{b:#1}%
+ \dimen2=\MPy{b:#1}%
+ \advance\dimen2 -\MPy{e:#1}%
+ \advance\dimen2 \MPd{e:#1}%
+ \lower\dimen2\hbox
+ {\advance\dimen2 \MPh{b:#1}%
+ \framed
+ [\c!width=\dimen0,\c!height=\dimen2,
+ \c!offset=\v!overlay,#2]{}}}%
+ \smashedbox\scratchbox
+ \egroup}
+
+% \def\sethdistances#1%
+% {\hbox{\lpos{ml:#1}\hpos{mh:#1}{\strut}\rpos{mr:#1}}}
+%
+% \def\gethdistances#1%
+% {\scratchdimen\MPx{mh:#1}%
+% \advance\scratchdimen -\MPx{ml#1}%
+% \edef\lefthdistance{\the\scratchdimen}%
+% \scratchdimen\MPx{mr:#1}%
+% \advance\scratchdimen -\MPx{mh:#1}%
+% \edef\righthdistance{\the\scratchdimen}}
+
+\protect \endinput
+
+% todo 1: shift down option
+
+\startuseMPgraphic{mpos:par:columnset}
+ \iftracepositions show_multi_pars \else draw_multi_pars \fi ;
+ path p ; p := boundingbox currentpicture ;
+ currentpicture := currentpicture shifted (0,-StrutDepth/2) ;
+ setbounds currentpicture to p ;
+\stopuseMPgraphic
+
+\setupcolors[state=start]
+
+\definetextbackground[underline][location=text,alternative=1,background=,frame=off,distance=2pt]
+
+\definestartstop
+ [underline]
+ [before={\starttextbackground[underline]},
+ after=\stoptextbackground]
diff --git a/tex/context/base/core-pos.tex b/tex/context/base/core-pos.tex
index 429aefeec..0324e522c 100644
--- a/tex/context/base/core-pos.tex
+++ b/tex/context/base/core-pos.tex
@@ -11,7 +11,8 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-% needs a cleanup, things may change
+% needs a cleanup, things may change; we also need to move the mp
+% related code to meta-pos
% shorter tags, ..:achtergrond:.. etc in pos actions
@@ -812,6 +813,107 @@
% \appendtoks \registerparoptions \to \everypar
+%D Eperimental code, don't use this yet: (must be sped up anyway)
+
+\def\@@noden{node:n:}
+\def\@@nodeo{node:o:}
+\def\@@nodep{node:p:}
+
+\def\nextnodelocation#1%
+ {\pluscounter{\@@noden#1}}
+
+\def\newnodelocation#1%
+ {\ifundefined{\@@noden#1}%
+ \setcounter{\@@noden#1}\zerocount
+ \letgvalue {\@@nodeo#1}\!!zerocount
+ \fi}
+
+\def\tagnodelocation#1%
+ {\xypos{\@@nodep#1:\countervalue{\@@noden#1}}}
+
+\def\getnodelocationp#1{\MPp{\@@nodep#1:\countervalue{\@@noden#1}}}
+\def\getnodelocationx#1{\MPx{\@@nodep#1:\countervalue{\@@noden#1}}}
+\def\getnodelocationy#1{\MPy{\@@nodep#1:\countervalue{\@@noden#1}}}
+
+\def\numnodelocationp#1#2{\MPp{\@@nodep#1:\number#2}}
+\def\numnodelocationx#1#2{\MPx{\@@nodep#1:\number#2}}
+\def\numnodelocationy#1#2{\MPy{\@@nodep#1:\number#2}}
+
+\def\getnodelocationn#1{\countervalue{\@@noden#1}}
+\def\getnodelocationo#1{\getvalue {\@@nodeo#1}}
+
+\chardef\nodelocationmode\plusone
+
+\def\analyzenodelocation#1%
+ {\doanalyzenodelocation{#1}{\getnodelocationn{#1}}\zerocount}
+
+\def\doanalyzenodelocation#1#2#3% class n default
+ {\begingroup
+ \donefalse
+ \ifcase\nodelocationmode
+ % do nothing
+ \else
+ \edef\nodelocationselfn{#2}%
+ \edef\nodelocationselfp{\numnodelocationp{#1}\nodelocationselfn}%
+ \edef\nodelocationselfx{\numnodelocationx{#1}\nodelocationselfn}%
+ \edef\nodelocationselfy{\numnodelocationy{#1}\nodelocationselfn}%
+ \scratchcounter\plusone
+ \doloop
+ {\ifnum\recurselevel=\nodelocationselfn\relax
+ \donetrue
+ \else
+ \edef\nodelocationotherp{\numnodelocationp{#1}\recurselevel}%
+ \edef\nodelocationotherx{\numnodelocationx{#1}\recurselevel}%
+ \edef\nodelocationothery{\numnodelocationy{#1}\recurselevel}%
+ \ifcase\nodelocationmode
+ \or
+ % ok for single column
+ \ifcase\nodelocationotherp\relax
+ \exitloop
+ \else\ifnum\nodelocationotherp<\nodelocationselfp\relax
+ \donetrue \advance\scratchcounter\plusone
+ \else\ifnum\nodelocationotherp>\nodelocationselfp\relax
+ % skip
+ \else\ifdim\nodelocationothery>\nodelocationselfy\relax
+ \donetrue \advance\scratchcounter\plusone
+ \else\ifdim\nodelocationothery<\nodelocationselfy\relax
+ % skip
+ \else\ifdim\nodelocationotherx<\nodelocationselfx\relax
+ \donetrue \advance\scratchcounter\plusone
+ \fi\fi\fi\fi\fi\fi
+ \or
+ % acceptable for double column
+ \ifcase\nodelocationotherp\relax
+ \exitloop
+ \else\ifnum\nodelocationotherp<\nodelocationselfp\relax
+ \donetrue \advance\scratchcounter\plusone
+ \else\ifnum\nodelocationotherp>\nodelocationselfp\relax
+ % skip
+ \else\ifnum\recurselevel>\nodelocationselfn\relax
+ \donetrue \exitloop
+ \else
+ \donetrue \advance\scratchcounter\plusone
+ \fi\fi\fi\fi
+ \else
+ \exitloop
+ \fi
+ \fi}%
+ \fi
+ \ifdone \else
+ \scratchcounter#3\relax
+ \fi
+ \setxvalue{\@@nodeo#1}{\the\scratchcounter}%
+ \endgroup}
+
+\unexpanded\def\shownodelocation#1%
+ {\analyzenodelocation{#1}%
+ (#1,%
+ n:\getnodelocationn{#1},%
+ p:\getnodelocationp{#1},%
+ x:\getnodelocationx{#1},%
+ y:\getnodelocationy{#1},%
+ o:\getnodelocationo{#1})}
+
%D \macros
%D {doifoverlappingelse}
%D
@@ -824,37 +926,6 @@
%D {action when not overlapping}
%D \stoptyping
-% \def\doifoverlappingelse#1#2#3#4%
-% {\relax\ifnum\MPp{#1}=\MPp{#2}\relax
-% \bgroup
-% \donefalse
-% \def\check##1##2%
-% {\ifdone\else
-% \ifdim\dimen1##1<\dimen0 \else \ifdim\dimen1##1>\dimen2 \else
-% \ifdim\dimen1##2<\dimen4 \else \ifdim\dimen1##2>\dimen6 \else
-% \donetrue
-% \fi\fi
-% \fi\fi
-% \fi}%
-% \dimen 0=\MPx{#1}%
-% \dimen 2=\MPx{#1}\advance\dimen 2 \MPw{#1}%
-% \dimen 4=\MPy{#1}\advance\dimen 4 -\MPd{#1}%
-% \dimen 6=\MPy{#1}\advance\dimen 6 \MPh{#1}%
-% \dimen10=\MPx{#2}%
-% \dimen12=\MPx{#2}\advance\dimen12 \MPw{#2}%
-% \dimen14=\MPy{#2}\advance\dimen14 -\MPd{#2}%
-% \dimen16=\MPy{#2}\advance\dimen16 \MPh{#2}%
-% %\message{\the\dimen 0-\the\dimen 2,\the\dimen 4-\the\dimen 6}\wait
-% %\message{\the\dimen10-\the\dimen12,\the\dimen14-\the\dimen16}\wait
-% \check04\check24\check26\check06\ifdone\egroup#3\else\egroup#4\fi
-% \else
-% #4%
-% \fi}
-
-% \newdimen\overlappingmargin \overlappingmargin\zeropoint
-%
-% \overlappingmargin-2sp % better
-
\def\overlappingmargin{-2\scaledpoint}
\def\doifoverlappingelse#1#2%
@@ -936,1796 +1007,10 @@
\rawprocesscommalist[#2]\docommando
\ifdone\egroup#3\else\egroup#4\fi}
-\def\doifpositionsonsamepageelse%
+\def\doifpositionsonsamepageelse
{\dodoifpositionsonsamepageelse{0}}
\def\doifpositionsonthispageelse#1#2#3%
{\dodoifpositionsonsamepageelse\realfolio}
-%D Before we come to graphics support, we have to make sure of
-%D the reference point on the page. The next macro does so and
-%D is hooked into the page building routine.
-
-% in the future, the depth of tail will reflect page depth
-
-\def\textanchor{text:\realfolio}
-
-% \def\placepositionanchors % todo : depth pagebox
-% {\ifpositioning
-% \setbox\scratchbox\vbox to \teksthoogte
-% {\topskipcorrection
-% \hbox{\strut\dopositionaction\headanchor}%
-% \vfill
-% \hbox{\strut\dopositionaction\tailanchor}}%
-% \dp\scratchbox\zeropoint
-% \wd\scratchbox\zetbreedte % not \zeropoint, else wrong text backgrounds
-% \hpos\textanchor{\box\scratchbox}%
-% \else
-% \vskip\teksthoogte
-% \fi}
-
-\def\placepositionanchors % todo : depth pagebox
- {\ifpositioning
- \setbox\scratchbox\vbox to \textheight
- {\simpletopskipcorrection
- \hbox{\strut\dopositionaction\headanchor}%
- \vfill
- \hbox{\strut\dopositionaction\tailanchor}}%
- \dp\scratchbox\zeropoint
- \wd\scratchbox\makeupwidth % not \zeropoint, else wrong text backgrounds
- \hpos\textanchor{\box\scratchbox}%
- \else
- \vskip\textheight
- \fi}
-
-%D The first version of this module implemented head and tail
-%D anchors. Currently we stick to just one anchor and derive
-%D the head and tail anchors from this one.
-
-\def\headanchor{head:\realfolio} % virtual position
-\def\tailanchor{tail:\realfolio} % virtual position
-
-\def\presetpositionanchors% compatibility hack (still needed?)
- {\ifpositioning
- \dopresetpositionanchors
- \fi}
-
-% \def\dopresetpositionanchors
-% {\bgroup
-% \dimen0=\ifdim\topskip>\strutht\topskip\else\strutht\fi
-% \dimen2=\MPy\textanchor
-% \dimen4=\dimen2
-% \advance\dimen2 \MPh\textanchor % space is essential
-% \advance\dimen2 -\dimen0
-% \advance\dimen4 \strutdp
-% \dimen6=\MPx\textanchor
-% \dimen8=\MPw\textanchor
-% \setxvalue{\POSprefix\headanchor}%
-% {\realfolio,\withoutpt\the\dimen6,\withoutpt\the\dimen2,%
-% \withoutpt\the\dimen8,\withoutpt\the\dimen0,\withoutpt\the\strutdp}%
-% \setxvalue{\POSprefix\tailanchor}%
-% {\realfolio,\withoutpt\the\dimen6,\withoutpt\the\dimen4,%
-% \withoutpt\the\dimen8,\withoutpt\the\strutht,\withoutpt\the\strutdp}%
-% %\showanchor\textanchor\showanchor\headanchor\showanchor\tailanchor\wait
-% \egroup}
-
-\def\dopresetpositionanchors
- {\bgroup
- \!!dimena\ifdim\topskip>\strutht\topskip\else\strutht\fi
- \!!dimenb\MPy\textanchor
- \!!dimenc\!!dimenb
- \advance\!!dimenb \MPh\textanchor % space is essential
- \advance\!!dimenb -\!!dimena
- \advance\!!dimenc \strutdp
- \!!dimend\MPx\textanchor
- \!!dimene\MPw\textanchor
- \setxvalue{\POSprefix\headanchor}%
- {\realfolio,\withoutpt\the\!!dimend,\withoutpt\the\!!dimenb,%
- \withoutpt\the\!!dimene,\withoutpt\the\!!dimena,\withoutpt\the\strutdp}%
- \setxvalue{\POSprefix\tailanchor}%
- {\realfolio,\withoutpt\the\!!dimend,\withoutpt\the\!!dimenc,%
- \withoutpt\the\!!dimene,\withoutpt\the\strutht,\withoutpt\the\strutdp}%
- %\showanchor\textanchor\showanchor\headanchor\showanchor\tailanchor\wait
- \egroup}
-
-\def\showanchor#1%
- {\expanded{\writestatus{#1}
- {\MPp{#1}\string|\MPx{#1}\string|\MPy{#1}\string|%
- \MPw{#1}\string|\MPh{#1}\string|\MPd{#1}}}}
-
-%D We set these anchors before and after each page.
-
-\appendtoks \presetpositionanchors \to \beforeeverypage
-\appendtoks \presetpositionanchors \to \aftereverypage
-
-%D \macros
-%D {positionoverlay,startpositionoverlay}
-%D
-%D As long as we're dealing with graphics it makes much sense
-%D to use the available overlay mechanism. For this purpose, we
-%D define some dedicated overlay extensions.
-%D
-%D \startbuffer[sample]
-%D \defineoverlay [sample] [\positionoverlay{sample}]
-%D
-%D \startpositionoverlay{sample}
-%D \setMPpositiongraphic{A-1}{connectcenter}{from=A-1,to=A-2}
-%D \stoppositionoverlay
-%D \stopbuffer
-%D
-%D \typebuffer[sample]
-%D
-%D \startbuffer[graphic]
-%D \startMPpositiongraphic{connectcenter}
-%D path pa, pb ; pair ca, cb ;
-%D initialize_box(\MPpos{\MPvar{from}}) ; pa := pxy ; ca := cxy ;
-%D initialize_box(\MPpos{\MPvar{to}}) ; pb := pxy ; cb := cxy ;
-%D draw pa withcolor red ;
-%D draw pb withcolor red ;
-%D draw ca -- cb withcolor blue ;
-%D anchor_box(\MPanchor{\MPvar{from}}) ;
-%D \stopMPpositiongraphic
-%D \stopbuffer
-%D
-%D We can best demonstrate this in an example, say:
-%D
-%D \startbuffer[text]
-%D \framed
-%D [backgroundachtergrond=sample,align=middle,width=7cm]
-%D {We want to connect \hpos {A-1} {this} word with its
-%D grammatical cousin \hpos {A-2} {that}.}
-%D \stopbuffer
-%D
-%D \typebuffer[text]
-%D
-%D \startlinecorrection
-%D %\getbuffer[graphic,sample,text]
-%D \stoplinecorrection
-%D
-%D The graphic is defined in the following way, using some
-%D macros defined in an auxiliary \METAPOST\ module that is
-%D preloaded.
-%D
-%D \typebuffer[graphic]
-
-\def\MPanchoridentifier{mpa} % {mp-anchor}
-\def\MPoverlayposprefix{MO::}
-
-% obsolete and wrong anyway
-%
-% \long\def\defineMPpositiongraphic#1%
-% {\long\setvalue{\MPoverlayposprefix#1}}
-
-%D The rest of the definitions concerning such overlays may
-%D look complicated,
-
-\let\currentpositionoverlay\empty
-
-%D Position actions are automatically executed when a position
-%D is set.
-
-% \def\positionoverlay#1%
-% {\ifpositioning
-% \vbox to \overlayheight
-% {\edef\MPanchor##1{\MPpos{#1::\MPanchoridentifier:\realfolio}}%
-% \the\everyinsertpositionaction
-% \copyposition{#1::\MPanchoridentifier}{#1::\MPanchoridentifier:\realfolio}%
-% \hpos
-% {#1::\MPanchoridentifier:\realfolio}
-% {\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}}%
-% \vfill}%
-% \fi}
-
-\let\MPanchornumber\realfolio
-
-% \def\positionoverlay#1%
-% {\ifpositioning
-% \vbox to \overlayheight
-% {\edef\MPanchorid{#1::\MPanchoridentifier:\MPanchornumber}%
-% \edef\MPanchor##1{\MPpos{\MPanchorid}}%
-% \the\everyinsertpositionaction
-% \copyposition{#1::\MPanchoridentifier}{#1::\MPanchoridentifier:\MPanchornumber}%
-% \hpos
-% {#1::\MPanchoridentifier:\MPanchornumber}
-% {\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}}%
-% \vfill}%
-% \fi}
-
-% \def\positionoverlay#1% the test prevents too many redundant positions
-% {\ifpositioning % in (not used) text* position layers
-% \vbox to \overlayheight
-% {\doifpositionactionelse{#1::\MPanchoridentifier}%
-% {\edef\MPanchorid{#1::\MPanchoridentifier:\MPanchornumber}%
-% \edef\MPanchor##1{\MPpos{\MPanchorid}}%
-% \the\everyinsertpositionaction
-% \copyposition{#1::\MPanchoridentifier}{#1::\MPanchoridentifier:\MPanchornumber}%
-% \hpos
-% {#1::\MPanchoridentifier:\MPanchornumber}%
-% {\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}}}%
-% {\hbox to \overlaywidth{\hss}}%
-% \vfill}%
-% \fi}
-
-\def\positionoverlay#1% the test prevents too many redundant positions
- {\ifpositioning % in (not used) text* position layers
- \vbox to \overlayheight
- {\doifpositionactionelse{#1::\MPanchoridentifier}%
- {\edef\MPanchorid{#1::\MPanchoridentifier:\MPanchornumber}%
- \edef\MPanchor##1{\MPpos{\MPanchorid}}%
- \the\everyinsertpositionaction
- \copyposition{#1::\MPanchoridentifier}{#1::\MPanchoridentifier:\MPanchornumber}%
- \hpos
- {#1::\MPanchoridentifier:\MPanchornumber}%
- % this is ok
- %{\hbox to \overlaywidth{\dopositionaction{#1::\MPanchoridentifier}\hss}}}%
- % but this one prevents cyclic runs due to
- % rounding errors
- {\setbox\scratchbox\hbox to \overlaywidth
- {\dopositionaction{#1::\MPanchoridentifier}\hss}%
- \ht\scratchbox\overlayheight
- \dp\scratchbox\zeropoint
- \box\scratchbox}}%
- {\hbox to \overlaywidth{\hss}}%
- \vfill}%
- \fi}
-
-\def\startpositionoverlay#1%
- {\iftrialtypesetting % we don't want redundant entries in the list
- \@EA\gobbleuntil\@EA\stoppositionoverlay
- \else
- \def\currentpositionoverlay{#1}%
- \fi}
-
-\def\stoppositionoverlay
- {\let\currentpositionoverlay\empty}
-
-\def\resetpositionoverlay#1%
- {\dosetpositionaction{#1::\MPanchoridentifier::}{}}
-
-%D Here the complication has to do with collecting actions
-%D for later execution. This collection is especially handy
-%D when we want to move actions to a specific layer.
-%D Such series of actions are stored in a macro (the one
-%D with the funny \type {++}) which is cleaned up after each
-%D invocation.
-
-\newtoks\everycleanpositionaction
-\newtoks\everyinsertpositionaction
-
-%\def\cleanuppositionaction#1%
-% {\doifdefined{\POSactionprefix#1++}
-% {\the\everycleanpositionaction
-% \setxvalue{\POSactionprefix#1++}{\getvalue{\POSactionprefix#1++}}}}
-
-%\def\cleanuppositionaction#1%
-% {\ifundefined{\POSactionprefix#1++}\else
-% \the\everycleanpositionaction
-% \setxvalue{\POSactionprefix#1++}{\getvalue{\POSactionprefix#1++}}%
-% \fi}
-
-\def\cleanuppositionaction#1% not in trialtypesetting
- {\ifundefined{\POSactionprefix#1++}\else
- \the\everycleanpositionaction
- \iflocalpositioning
- \letgvalue{\POSactionprefix#1++}\empty
- \else
- \setxvalue{\POSactionprefix#1++}{\getvalue{\POSactionprefix#1++}}%
- \fi
- \fi}
-
-\def\handlepositionaction#1\with#2\on#3%
- {\bgroup
- \ifx\currentpositionoverlay\empty
- \edef\!!stringa{#3}% no layer, just pos itself as anchor
- \else
- \edef\!!stringa{\currentpositionoverlay::\MPanchoridentifier}%
- \fi
- \edef\!!stringc{\POSactionprefix\!!stringa++}%
- \expanded{\dosetpositionaction{\!!stringa}{\noexpand\getvalue{\!!stringc}}}%
- \global\let#1\relax
- \edef\!!stringb{\executeifdefined\!!stringc\empty}%
- \setxvalue\!!stringc{\!!stringb#1#2}%
- \egroup}
-
-%D The indirectness enables us redefine macros for special
-%D purposes, like a cleanup.
-
-\def\handlepositionboxes#1#2#3%
- {\handlepositionaction\dohandlepositionboxes\with{#1}{#2}{#3}\on{#2}}
-
-\def\doinsertpositionboxes#1#2#3% pos tag setups
- {\ifnum\MPp{#1}=\realpageno\relax
- % \doifdefined{\MPoverlayposprefix#1}
- % {\getvalue{\MPoverlayposprefix#1}{#1}{#2}{#3}}%
- \executeifdefined{\MPoverlayposprefix#1}%
- \gobblethreearguments{#1}{#2}{#3}%
- \fi}
-
-\appendtoks
- \let\dohandlepositionboxes\doinsertpositionboxes % was handle ?
-\to \everyinsertpositionaction
-
-\def\docleanpositionboxes#1#2#3% pos tag setups
- {\ifnum\MPp{#1}<\realpageno \else
- \noexpand \dohandlepositionboxes{#1}{#2}{#3}% reinsert
- \fi}
-
-\appendtoks
- \let\dohandlepositionboxes\docleanpositionboxes
-\to \everycleanpositionaction
-
-%D A position graphic is a normal (non||reused) \METAPOST\
-%D graphic, used immediately, with zero dimensions, so that a
-%D sequence of them does not harm.
-
-\newbox\positiongraphicbox
-
-\def\startMPpositiongraphic % id setups
- {\dodoublegroupempty\dostartMPpositiongraphic}
-
-\long\def\dostartMPpositiongraphic#1#2#3\stopMPpositiongraphic
- {\long\setgvalue{MPG:#1}% tag list mpcode
- {\useMPpositiongraphic{#1}{#2}{#3}}}
-
-%\def\prepareMPpositionvariables
-% {\doifundefined{\@@meta self}{\setvalue{\@@meta self}{\currentposition}}%
-% \doifundefined{\@@meta from}{\setvalue{\@@meta from}{\currentposition}}}
-
-\def\prepareMPpositionvariables
- {\ifundefined{\@@meta self}\setvalue{\@@meta self}{\currentposition}\fi
- \ifundefined{\@@meta from}\setvalue{\@@meta from}{\currentposition}\fi}
-
-% \long\def\useMPpositiongraphic#1#2#3%
-% {\bgroup
-% \prepareMPvariables{#2}%
-% \prepareMPpositionvariables
-% \enableincludeMPgraphics
-% \startMPgraphic#3\stopMPgraphic
-% \loadMPgraphic{\MPgraphicfile.\the\currentMPgraphic}{}%
-% \deallocateMPslot\currentMPgraphic
-% \placeMPgraphic
-% \egroup}
-
-\newif\ifcollectMPpositiongraphics \collectMPpositiongraphicstrue
-
-\long\def\useMPpositiongraphic#1#2#3%
- {\bgroup
- \prepareMPvariables{#2}%
- \prepareMPpositionvariables
- \enableincludeMPgraphics
- \ifcollectMPpositiongraphics
- \expanded{\startMPdrawing#3\noexpand\stopMPdrawing}%
- \global\MPdrawingdonetrue
- \else
- \startMPgraphic#3\stopMPgraphic
- \loadMPgraphic{\MPgraphicfile.\the\currentMPgraphic}{}%
- \deallocateMPslot\currentMPgraphic
- \placeMPgraphic
- \fi
- \egroup}
-
-% Now we need a adapted action handler:
-
-% \def\dopositionaction#1% test saves hash entry in etex
-% {\ifundefined{\POSactionprefix#1::}\else
-% \ifnum\MPp{#1}>\zerocount % new
-% \bgroup
-% \traceposstring\clap\red{<#1>}%
-% \the\everyinsertpositionaction
-% \the\everypositionaction
-% \ifcollectMPpositiongraphics
-% % can save a lot of run time
-% \pushMPdrawing
-% \MPshiftdrawingtrue
-% \resetMPdrawing
-% \getvalue{\POSactionprefix#1::}%
-% \ifMPdrawingdone
-% \getMPdrawing
-% \fi
-% \resetMPdrawing
-% \popMPdrawing
-% \else
-% \getvalue{\POSactionprefix#1::}%
-% \fi
-% \cleanuppositionaction{#1}%
-% \egroup
-% \else
-% % shouldn't happen too often
-% \traceposstring\clap\cyan{<#1>}%
-% \fi
-% \fi}
-
-\def\dopositionaction#1% test saves hash entry in etex
- {\ifundefined{\POSactionprefix#1::}\else
- \ifnum\MPp{#1}>\zerocount % new
- \bgroup
- \setbox\scratchbox\hbox
- \bgroup
- \traceposstring\clap\red{<#1>}%
- \the\everyinsertpositionaction
- \the\everypositionaction
- \ifcollectMPpositiongraphics
- % can save a lot of run time
- \pushMPdrawing
- \MPshiftdrawingtrue
- \resetMPdrawing
- \getvalue{\POSactionprefix#1::}%
- \ifMPdrawingdone
- \getMPdrawing
- \fi
- \resetMPdrawing
- \popMPdrawing
- \else
- \getvalue{\POSactionprefix#1::}%
- \fi
- \cleanuppositionaction{#1}%
- \egroup % smashed is really needed else
- \smashedbox\scratchbox % we get problems with too big
- \egroup % overlays (s-pre-0x.tex)
- \else
- % shouldn't happen too often
- \traceposstring\clap\cyan{<#1>}%
- \fi
- \fi}
-
-\def\MPpositiongraphic
- {\dodoublegroupempty\doMPpositiongraphic}
-
-% \def\doMPpositiongraphic#1#2% tag setups
-% {\bgroup
-% \def\@@meta{#1:}%
-% \setupMPvariables[#2]%
-% \prepareMPpositionvariables
-% \MPshiftdrawingtrue
-% \def\doMPpositiongraphic##1##2{\getvalue{MPG:##1}}% temp hack
-% \setbox\positiongraphicbox\hbox
-% {\ignorespaces
-% \executeifdefined{MPM:#1}{\executeifdefined{MPG:#1}\donothing}%
-% \removelastspace}%
-% \smashbox\positiongraphicbox
-% \box\positiongraphicbox
-% \egroup}
-
-\def\doMPpositiongraphic#1#2% tag setups
- {\bgroup
- \def\@@meta{#1:}%
- \setupMPvariables[#2]%
- \prepareMPpositionvariables
- \MPshiftdrawingtrue
- \def\doMPpositiongraphic##1##2%
- {{% new, see (techniek)
- \def\@@meta{##1:}%
- \setupMPvariables[#2,##2]%
- \prepareMPpositionvariables
- % and needed
- \getvalue{MPG:##1}}}% temp hack
- \setbox\positiongraphicbox\hbox
- {\ignorespaces
- \executeifdefined{MPM:#1}{\executeifdefined{MPG:#1}\donothing}%
- \removelastspace}%
- \smashbox\positiongraphicbox
- \box\positiongraphicbox
- \egroup}
-
-\long\def\startMPpositionmethod#1#2\stopMPpositionmethod
- {\long\setgvalue{MPM:#1}{#2}} % todo: var list here
-
-%D Simple one position graphics.
-
-\def\setMPpositiongraphic
- {\dotriplegroupempty\dosetMPpositiongraphic}
-
-\def\dosetMPpositiongraphic#1#2#3% pos tag vars
- {\ifx\currentpositionoverlay\empty
- \dosetpositionaction{#1}{\MPpositiongraphic{#2}{#3}}%
- \else % silly can be one
- \handlepositiongraphics{#1}{#2}{#3}%
- \fi}
-
-\def\handlepositiongraphics#1#2#3% combine with boxes
- {\handlepositionaction\dohandleMPpositiongraphic\with{#1}{#2}{#3}\on{#2}}
-
-\def\doinsertMPpositiongraphic#1#2#3% pos tag setups
- {\ifnum\MPp{#1}=\realpageno\relax % extra saveguard
- \def\currentposition{#1}\MPpositiongraphic{#2}{#3}%
- \fi}
-
-\appendtoks
- \let\dohandleMPpositiongraphic\doinsertMPpositiongraphic
-\to \everyinsertpositionaction
-
-\def\docleanMPpositiongraphic#1#2#3% pos tag setups
- {\ifnum\MPp{#1}<\realpageno \else
- \noexpand \dohandleMPpositiongraphic{#1}{#2}{#3}%
- \fi}
-
-\appendtoks
- \let\dohandleMPpositiongraphic\docleanMPpositiongraphic
-\to \everycleanpositionaction
-
-%D Graphics that span two positions.
-
-\def\setMPpositiongraphicrange
- {\doquadruplegroupempty\dosetMPpositiongraphicrange}
-
-\def\dosetMPpositiongraphicrange#1#2#3#4% bpos epos tag vars
- {\ifx\currentpositionoverlay\empty
- \dosetpositionaction{#1}{\MPpositiongraphic{#3}{#4}}%
- \else
- \handlepositiongraphicsrange{#1}{#2}{#3}{#4}%
- \fi}
-
-\def\handlepositiongraphicsrange#1#2#3#4%
- {\handlepositionaction\dohandleMPpositiongraphicrange\with{#1}{#2}{#3}{#4}\on{#2}}
-
-% \def\doinsertMPpositiongraphicrange#1#2#3#4% pos pos tag setups
-% {\donefalse
-% \ifnum\MPp{#1}=\realpageno\relax \donetrue
-% \else\ifnum\MPp{#2}=\realpageno\relax \donetrue
-% \else\ifnum\MPp{#1}<\realpageno\relax\ifnum\MPp{#2}>\realpageno\donetrue
-% \fi\fi\fi\fi \ifdone
-% \def\currentposition{#1}\MPpositiongraphic{#3}{#4}%
-% \fi}
-
-\def\doinsertMPpositiongraphicrange#1#2#3#4% pos pos tag setups
- {\ifnum\MPp{#1}\MPp{#2}>\zerocount
- \iflocalpositioning
- \donetrue
- \else
- \donefalse
- \ifnum\MPp{#1}=\realpageno
- \donetrue
- \else\ifnum\MPp{#2}=\realpageno
- \donetrue
- \else\ifnum\MPp{#1}<\realpageno\relax\ifnum\MPp{#2}>\realpageno
- \donetrue
- \fi\fi\fi\fi
- \fi
- \ifdone
- \def\currentposition{#1}\MPpositiongraphic{#3}{#4}%
- \fi
- \fi}
-
-\appendtoks
- \let\dohandleMPpositiongraphicrange\doinsertMPpositiongraphicrange
-\to \everyinsertpositionaction
-
-\def\docleanMPpositiongraphicrange#1#2#3#4% pos tag setups
- {\ifnum\MPp{#2}<\realpageno \else
- \noexpand \dohandleMPpositiongraphicrange{#1}{#2}{#3}{#4}%
- \fi}
-
-\appendtoks
- \let\dohandleMPpositiongraphicrange\docleanMPpositiongraphicrange
-\to \everycleanpositionaction
-
-% will be overloaded, and/or code below moved to core-box
-
-\defineoverlay[\v!text-2][\positionoverlay{\v!text-2}]
-\defineoverlay[\v!text-1][\positionoverlay{\v!text-1}]
-\defineoverlay[\v!text+1][\positionoverlay{\v!text+1}]
-\defineoverlay[\v!text+2][\positionoverlay{\v!text+2}]
-
-%D The auxiliary \METAPOST\ macros are defined by default,
-%D by saying:
-
-\appendtoks
- if unknown context_core : input mp-core.mp ; fi ;
-\to \MPextensions
-
-%D Some of these macros are pretty clever but too complicated
-%D to be nice. When things are kind of stable I'll clean up
-%D this mess.
-
-%D THIS NEEDS A CLEANUP
-
-\setupMPvariables
- [mpos:box]
- [linecolor=blue,
- linewidth=\linewidth,
- fillcolor=lightgray,
- filloffset=\!!zeropoint]
-
-\startMPpositiongraphic{mpos:box}{fillcolor,linecolor,linewidth}
- initialize_box(\MPpos{\MPvar{self}}) ;
- boxfillcolor := \MPvar{fillcolor} ;
- boxlinecolor := \MPvar{linecolor} ;
- boxlinewidth := \MPvar{linewidth} ;
- boxfilloffset := \MPvar{filloffset} ;
- draw_box ;
- anchor_box(\MPanchor{\MPvar{self}}) ;
-\stopMPpositiongraphic
-
-\setupMPvariables
- [mpos:area]
- [linecolor=blue,
- linewidth=\linewidth,
- fillcolor=lightgray,
- filloffset=\!!zeropoint]
-
-\startMPpositiongraphic{mpos:area}{fillcolor,linecolor,linewidth}
- initialize_area(\MPpos{b:\MPvar{self}},\MPpos{e:\MPvar{self}}) ;
- boxfillcolor := \MPvar{fillcolor} ;
- boxlinecolor := \MPvar{linecolor} ;
- boxlinewidth := \MPvar{linewidth} ;
- boxfilloffset := \MPvar{filloffset} ;
- draw_area ;
- anchor_area(\MPanchor{b:\MPvar{self}}) ;
-\stopMPpositiongraphic
-
-%D This is already cleaned up.
-
-% gridtype = 1 => baseline
-% gridtype = 2 => betweenline
-
-\setupMPvariables
- [mpos:par]
- [mp=mpos:par:shape,
- gridtype=0,
- linetype=1,
- filltype=1,
- %snaptops=true, % not that nice: true/false
- gridcolor=red,
- linecolor=blue,
- fillcolor=lightgray,
- filloffset=\!!zeropoint,
- linewidth=\linewidth,
- gridwidth=\linewidth,
- lineradius=.5\bodyfontsize]
-
-\startuseMPgraphic{mpos:par:shape}
- \iftracepositions show_par \else draw_par \fi ;
-\stopuseMPgraphic
-
-\startuseMPgraphic{mpos:par:setup}
- boxgridtype := \MPvar{gridtype} ;
- boxlinetype := \MPvar{linetype} ;
- boxfilltype := \MPvar{filltype} ;
- boxgridcolor := \MPvar{gridcolor} ;
- boxlinecolor := \MPvar{linecolor} ;
- boxfillcolor := \MPvar{fillcolor} ;
- boxfilloffset := \MPvar{filloffset} ;
- boxlinewidth := \MPvar{linewidth} ;
- boxgridwidth := \MPvar{gridwidth} ;
- boxlineradius := \MPvar{lineradius} ;
- %snap_multi_par_tops := \MPvar{snaptops} ;
-\stopuseMPgraphic
-
-\startuseMPgraphic{mpos:par:extra}
- % user stuff, like:
- % snap_multi_par_tops := false ;
-\stopuseMPgraphic
-
-% \startMPpositionmethod{mpos:par}
-% \doifpositionelse{w:\MPvar{self}}
-% {\startMPpositiongraphic{mpos:par}%
-% {fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,lineradius}
-% initialize_area_par(\MPpos{b:\MPvar{self}},
-% \MPpos{e:\MPvar{self}},
-% \MPpos{w:\MPvar{self}}) ;
-% \includeMPgraphic{mpos:par:setup} ;
-% \includeMPgraphic{mpos:par:extra} ;
-% \includeMPgraphic{\MPvar{mp}} ; % \includeMPgraphic{mpos:par:shape} ;
-% anchor_par(\MPanchor{b:\MPvar{self}}) ;
-% \stopMPpositiongraphic}
-% {\startMPpositiongraphic{mpos:par}%
-% {fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,lineradius}
-% initialize_par(\MPpos{b:\MPvar{self}},
-% \MPpos{e:\MPvar{self}},
-% \MPpos{text:\realfolio},
-% \MPpos{p:\MPparcounter},
-% \MPvv {p:\MPparcounter}{0,0,0,0,0,0}) ;
-% \includeMPgraphic{mpos:par:setup} ;
-% \includeMPgraphic{mpos:par:extra} ;
-% \includeMPgraphic{\MPvar{mp}} ; % \includeMPgraphic{mpos:par:shape} ;
-% anchor_par(\MPanchor{b:\MPvar{self}}) ;
-% \stopMPpositiongraphic}%
-% \MPpositiongraphic{mpos:par}{}%
-% \stopMPpositionmethod
-
-%D Less readable but shorter.
-
-\ifx\MPparcounter\undefined \newcounter\MPparcounter \fi
-
-\def\MPself {\MPvar{self}}
-\def\MPbself {b:\MPself}
-\def\MPeself {e:\MPself}
-\def\MPwself {w:\MPself}
-\def\MPparanchor{p:\MPparcounter}
-
-\def\MPl#1{\MPplus{#1}20}
-\def\MPr#1{\MPplus{#1}30}
-
-\startMPpositionmethod{mpos:par} %%%%%%%%%%% will become obsolete
- \edef\MPparcounter{\MPv\MPbself{1}{0}}%
- \doifpositionelse\MPwself
- {\startMPpositiongraphic{mpos:par}%
- {fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,lineradius}
- initialize_area_par(\MPpos\MPbself,
- \MPpos\MPeself,
- \MPpos\MPwself) ;
- \includeMPgraphic{mpos:par:setup} ;
- \includeMPgraphic{mpos:par:extra} ;
- \includeMPgraphic{\MPvar{mp}} ;
- anchor_par(\MPanchor\MPbself) ;
- \stopMPpositiongraphic}
- {\startMPpositiongraphic{mpos:par}%
- {fillcolor,filloffset,linecolor,gridcolor,linewidth,gridwidth,lineradius}
- initialize_par(\MPpos\MPbself,
- \MPpos\MPeself,
- \MPpos\textanchor,
- \MPpos\MPparanchor,
- \MPvv \MPparanchor{0,0,0,0,0,0}) ;
- \includeMPgraphic{mpos:par:setup} ;
- \includeMPgraphic{mpos:par:extra} ;
- \includeMPgraphic{\MPvar{mp}} ;
- anchor_par(\MPanchor\MPbself) ;
- \stopMPpositiongraphic}%
- \MPpositiongraphic{mpos:par}{}%
-\stopMPpositionmethod
-
-%D The next alternative works in columnsets :
-
-% \iftracepositions show\else draw\fi_multi_pars ;
-
-\startuseMPgraphic{mpos:par:columnset}
- \iftracepositions show_multi_pars \else draw_multi_pars \fi ;
-\stopuseMPgraphic
-
-\startMPpositionmethod{mpos:par:columnset}
- \edef\MPparcounter{\MPv\MPbself{1}{0}}%
- \startMPpositiongraphic{mpos:par}%
- {fillcolor,filloffset,linecolor,gridcolor,%
- linewidth,gridwidth,lineradius}
- \includeMPgraphic{mpos:par:setup} ;
- \includeMPgraphic{mpos:par:extra} ;
- prepare_multi_pars(\MPpos\MPbself,\MPpos\MPeself,\MPpos\MPwself,
- \MPpos\MPparanchor,\MPvv\MPparanchor{0,0,0,0,0,0}) ;
- relocate_multipars(-\MPxy\MPanchorid) ; % inside layerpos
- \includeMPgraphic{\MPvar{mp}} ;
- \stopMPpositiongraphic
- \MPpositiongraphic{mpos:par}{}%
-\stopMPpositionmethod
-
-%D \starttyping
-%D \setupbackground
-%D [test]
-%D [mp=mpos:par:columnset,
-%D methodmethode=mpos:par:columnset]
-%D \stoptyping
-
-%D We need to treat floats in a special way.
-
-\appendtoks
- local_multi_par_area:=\iflocalpositioning true\else false\fi;
-\to \MPinitializations
-
-\def\textbackgroundoverlay#1%
- {\iflocalpositioning\v!local\else\v!text\fi#1}
-
-\newcounter\localpositionnumber
-
-\def\MPanchornumber
- {\iflocalpositioning\localpositionnumber\else\realfolio\fi}
-
-%D So far for the trickery.
-
-\newcounter\textbackgrounddepth
-
-\appendtoks
- \savecurrentvalue\totalnofparbackgrounds\nofparbackgrounds
-\to \everybye
-
-\appendtoks
- \initializeparbackgrounds
-\to \everystarttext
-
-\ifx\totalnofparbackgrounds\undefined \newcounter\totalnofparbackgrounds \fi
-\ifx\nofparbackgrounds \undefined \newcounter\nofparbackgrounds \fi
-
-\def\initializeparbackgrounds
- {\ifcase\totalnofparbackgrounds\else
- \global\positioningtrue
- \global\positioningpartrue
- \fi}
-
-\unexpanded\def\starttextbackground
- {\bgroup
- \increment\textbackgrounddepth
- \dodoubleempty\dostarttextbackground}
-
-\let\dodostarttextbackground\relax
-\let\dodostoptextbackground \relax
-
-% \def\currentparbackground{background:0}
-% \def\nextparbackground {background:1}
-
-\def\currentparbackground{pbg:0}
-\def\nextparbackground {pbg:1}
-
-\def\btbanchor{b:\currentparbackground}
-\def\etbanchor{e:\currentparbackground}
-
-\def\nextbtbanchor{b:\nextparbackground}
-\def\nextetbanchor{e:\nextparbackground}
-
-\def\backgroundvariable#1%
- {\csname\??td\currenttextbackground#1\endcsname}
-
-% \definetextbackground[more][state=start,backgroundcolor=red] % location=paragraph
-% \definetextbackground[test][state=start,backgroundcolor=green]
-%
-% \page \placefigure[left]{}{}
-%
-% \starttextbackground[test]
-% \readfile{ward}{}{}
-% \starttextbackground[more]
-% \readfile{ward}{}{}
-% \stoptextbackground
-% \readfile{ward}{}{}
-% \stoptextbackground
-%
-% \page \placefigure[right]{}{}
-%
-% \starttextbackground[test]
-% \readfile{ward}{}{}
-% \starttextbackground[more]
-% \readfile{ward}{}{}
-% \stoptextbackground
-% \readfile{ward}{}{}
-% \stoptextbackground
-
-\def\dostarttextbackground[#1][#2]%
- {\checktextbackgrounds
- \def\currenttextbackground{#1}%
- \doglobal\increment\nofparbackgrounds
- %\edef\currentparbackground{background:\nofparbackgrounds}%
- \edef\currentparbackground{pbg:\nofparbackgrounds}%
- \bgroup
- \increment\nofparbackgrounds
- %\xdef\nextparbackground{background:\nofparbackgrounds}%
- \xdef\nextparbackground{pbg:\nofparbackgrounds}%
- \egroup
- % todo : \synchonizepositionpage{b:\currentparbackground}{s:\currentparbackground}%
- \setuptextbackground[#1][#2]%
- \let\dodostarttextbackground\relax
- \let\dodostoptextbackground \relax
- \doifvalue{\??td#1\c!state}\v!start
- {\dopresettextbackground{#1}}%
- \dodostarttextbackground}
-
-% todo \backgroundvariable\c!variant
-
-\def\dopresettextbackground#1% todo: \backgroundparameter
- {\ExpandFirstAfter\processaction % \EFA niet echt nodig
- [\getvalue{\??td#1\c!location}]
- [ \v!text=>\let\dodostarttextbackground\dostarttextbackgroundtxt
- \let\dodostoptextbackground \dostoptextbackgroundtxt,
- \v!paragraph=>\let\dodostarttextbackground\dostarttextbackgroundpar
- \let\dodostoptextbackground \dostoptextbackgroundpar,
- \v!none=>\let\dodostarttextbackground\relax
- \let\dodostoptextbackground \relax]%
- \ifx\dodostarttextbackground\dostarttextbackgroundpar % untested
- \ifnum\textbackgrounddepth>\plusone % new
- \let\dodostarttextbackground\dostarttextbackgroundtxt
- \let\dodostoptextbackground \dostoptextbackgroundtxt
- \fi
- \fi
- \doifelsevalue{\??td#1\c!frame}\v!on
- {\doifelsevalue{\??td#1\c!corner}\v!round
- {\setvalue{\??td#1\c!frame}{2}}
- {\setvalue{\??td#1\c!frame}{1}}}
- {\setvalue{\??td#1\c!frame}{0}}%
- \doifelsevalue{\??td#1\c!background}\v!color
- {\setvalue{\??td#1\c!background}{1}}
- {\setvalue{\??td#1\c!background}{0}}%
- %\startpositionoverlay{\v!text\getvalue{\??td#1\c!level}}%
- \startpositionoverlay{\textbackgroundoverlay{\getvalue{\??td#1\c!level}}}%
- \expanded
- {\setMPpositiongraphicrange % moet veel efficienter
- {\btbanchor}% {b:\currentparbackground}%
- {\etbanchor}% {e:\currentparbackground}%
- {\getvalue{\??td#1\c!method}}%
- {self=\currentparbackground,
- mp=\getvalue{\??td#1\c!mp},
- gridtype=\getvalue{\??td#1\c!alternative},
- filltype=\getvalue{\??td#1\c!background},
- linetype=\getvalue{\??td#1\c!frame},
- gridcolor=\getvalue{\??td#1\c!framecolor},
- linecolor=\getvalue{\??td#1\c!framecolor},
- fillcolor=\getvalue{\??td#1\c!backgroundcolor},
- filloffset=\getvalue{\??td#1\c!backgroundoffset},
- gridwidth=\getvalue{\??td#1\c!rulethickness},
- linewidth=\getvalue{\??td#1\c!rulethickness},
- lineradius=\getvalue{\??td#1\c!radius}}}%
- \stoppositionoverlay}
-
-\def\stoptextbackground
- {\dodostoptextbackground
- \carryoverpar\egroup}
-
-\def\starttextbackgroundmanual
- {\dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
- \fpos\currentparbackground\ignorespaces}
-
-\def\stoptextbackgroundmanual
- {\tpos\currentparbackground
- \dostopattributes}
-
-\def\dostarttextbackgroundtxt
- {\ifvmode \leavevmode \fi
- \dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
- \fpos\currentparbackground\ignorespaces}
-
-\def\dostoptextbackgroundtxt
- {\tpos\currentparbackground
- \dostopattributes}
-
-% keep this simple one, it's used in prikkels and alike
-%
-% \def\dostarttextbackgroundpar
-% {\endgraf % new
-% \getvalue{\??td\currenttextbackground\c!before}%
-% \noindent\fpos\currentparbackground\ignorespaces
-% \bgroup
-% \nobreak \vskip-\lineheight \nobreak
-% \doassignsomeskip\getvalue{\??td\currenttextbackground\c!topoffset}\to\scratchskip
-% \kern\scratchskip\nobreak
-% \dosetleftskipadaption{\getvalue{\??td\currenttextbackground\c!leftoffset}}%
-% \advance\leftskip\leftskipadaption
-% \dosetleftskipadaption{\getvalue{\??td\currenttextbackground\c!rightoffset}}%
-% \advance\rightskip\leftskipadaption
-% \dostartattributes{\??td\currenttextbackground}\c!style\c!color{}%
-% \nowhitespace
-% \seteffectivehsize
-% \par}
-%
-% \def\dostoptextbackgroundpar
-% {\par
-% \dostopattributes
-% \doassignsomeskip\getvalue{\??td\currenttextbackground\c!bottomoffset}\to\scratchskip
-% \kern\scratchskip\nobreak
-% \nobreak \vskip-\lineheight \nobreak
-% \nowhitespace
-% \egroup
-% \nobreak \noindent \strut \hfill \kern\zeropoint \tpos\currentparbackground
-% \endgraf % new
-% \getvalue{\??td\currenttextbackground\c!after}}
-
-\def\dostarttextbackgroundpar
- {\endgraf % new
- \getvalue{\??td\currenttextbackground\c!before}%
- \doassignsomeskip\getvalue{\??td\currenttextbackground\c!topoffset}\to\scratchskip
- \xdef\textbackgroundskip{\the\scratchskip}%
- \noindent
- \ifgridsnapping
- \ifdim\textbackgroundskip>\zeropoint
- \struttedbox{\hbox{\raise\textbackgroundskip\hbox{\fpos\currentparbackground}}}%
- \else
- \fpos\currentparbackground
- \fi
- \else
- \fpos\currentparbackground
- \fi
- \bgroup
- \endgraf % we need a vertical nobreak - 29/06/2004
- \nobreak \vskip-\lineheight \nobreak
- \doassignsomeskip\getvalue{\??td\currenttextbackground\c!topoffset}\to\scratchskip
- \ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint
- \kern\textbackgroundskip\nobreak
- \fi \fi
- \dosetleftskipadaption{\getvalue{\??td\currenttextbackground\c!leftoffset}}%
- \advance\leftskip\leftskipadaption
- \dosetleftskipadaption{\getvalue{\??td\currenttextbackground\c!rightoffset}}%
- \advance\rightskip\leftskipadaption
- % new
- \dosetraggedcommand{\getvalue{\??td\currenttextbackground\c!align}}%
- \raggedcommand
- %
- \dostartattributes{\??td\currenttextbackground}\c!style\c!color\empty
- \nowhitespace
- \seteffectivehsize
- \doinhibitblank % \blank[\v!disable]% new
- \par}
-
-\def\dostoptextbackgroundpar
- {\par
- \removelastskip % new
- \dostopattributes
- \doassignsomeskip\getvalue{\??td\currenttextbackground\c!bottomoffset}\to\scratchskip
- \ifdim\lastskip>\zeropoint
- \advance\scratchskip-\lastskip
- \fi
- \xdef\textbackgroundskip{\the\scratchskip}%
- \ifgridsnapping \else \ifdim\textbackgroundskip>\zeropoint
- \kern\scratchskip\nobreak
- \fi \fi
- \nobreak \vskip-\lineheight \nobreak
- \nowhitespace
- \egroup
-\bgroup \forgeteverypar % NOT REALLY NEEDED, SAVES HASH/MEM
- \nobreak \noindent \strut \hfill \kern\zeropoint
- \ifgridsnapping % experimental, pascal (todo: topoffset in same way)
- \ifdim\textbackgroundskip>\zeropoint
- \struttedbox{\hbox{\lower\textbackgroundskip\hbox{\tpos\currentparbackground}}}%
- \else
- \tpos\currentparbackground
- \fi
- \else
- \tpos\currentparbackground
- \fi
-\egroup
- \endgraf % new
- \getvalue{\??td\currenttextbackground\c!after}}
-
-\let\textparpages \!!zeropoint
-\let\textparheight\!!zeropoint
-\let\textparwidth \!!zeropoint
-
-\def\calculatetextpardimensions
- {\docalculatetextpardimensions\btbanchor \etbanchor \MPparanchor}
-
-\def\calculatenexttextpardimensions
- {\docalculatetextpardimensions\nextbtbanchor\nextetbanchor\relax}
-
-\def\docalculatetextpardimensions#1#2#3%
- {\scratchcounter\MPp#2%\etbanchor
- \advance\scratchcounter-\MPp#1%\btanchor
- \edef\textparpages{\the\scratchcounter}%
- \ifcase\scratchcounter
- % one page
- \scratchdimen \MPy#1%\btanchor
- \advance\scratchdimen-\MPy#2%\etbanchor
- \else
- % two or more pages
- \scratchdimen \MPy#1%\btanchor
- \advance\scratchdimen-\MPy#2%\etbanchor
- \advance\scratchdimen-\MPy\textanchor
- \advance\scratchdimen \MPy\textanchor
- \advance\scratchdimen \MPh\textanchor\relax
- \ifcase\scratchcounter>2 \ifnum\scratchcounter<5
- % more pages
- \scratchdimen\textheight
- \advance\scratchcounter \minusone
- \multiply\scratchdimen \scratchcounter
- \else
- % keep'm small
- \scratchdimen5\textheight
- \fi \fi
- \fi
- \edef\textparheight{\the\scratchdimen}%
- \ifcase\scratchcounter
- % one page
- \scratchdimen \MPx#2%\etbanchor
- \advance\scratchdimen-\MPx#1%\btanchor
- \else
- % two or more pages / maybe also hang
- \ifx#3\relax
- \scratchdimen\makeupwidth % \textwidth
- \else
- \scratchdimen\MPw\MPparanchor
- \advance\scratchdimen-\MPl\MPparanchor
- \advance\scratchdimen-\MPr\MPparanchor
- \fi
- \fi
- \edef\textparwidth{\the\scratchdimen}}
-
-\def\mintextparheight{4\lineheight}
-
-\def\dontsplitnexttextbackground % dangerous but useful
- {\ifdim\pagetotal>\textheight \else
- \ifdim\pagegoal=\maxdimen \else
- \calculatenexttextpardimensions
- % too tricky
- % \scratchdimen=\textparheight
- % \advance\scratchdimen\pagetotal\relax
- % \ifdim\scratchdimen>\pagegoal
- % \page
- % \fi
- \ifdim\textparheight>\zeropoint
- \ifdim\textparheight>\mintextparheight\else
- \page % option
- \fi
- \fi
- \fi
- \fi}
-
-\def\definetextbackground
- {\dodoubleempty\dodefinetextbackground}
-
-\def\dodefinetextbackground[#1][#2]%
- {\ifsecondargument % why ?
- \copyparameters[\??td#1][\??td]
- [\c!state,\c!location,\c!alternative,\c!mp,\c!method,
- \c!background,\c!backgroundcolor,\c!corner,\c!level,
- \c!backgroundoffset,\c!before,\c!after,\c!align,
- \c!radius,\c!frame,\c!framecolor,\c!rulethickness,
- \c!leftoffset,\c!rightoffset,\c!topoffset,\c!bottomoffset]%
- \getparameters[\??td#1][#2]%
- \doifvalue{\??td#1\c!state}\v!start\checktextbackgrounds
- \unexpanded\setvalue{#1}%
- {\groupedcommand{\starttextbackground[#1]}{\stoptextbackground}}%
- \setvalue{\e!start#1}{\starttextbackground[#1]}%
- \setvalue{\e!stop #1}{\stoptextbackground}%
- \fi}
-
-\def\setuptextbackground
- {\dodoubleargument\dosetuptextbackground}
-
-\def\dosetuptextbackground[#1][#2]%
- {\ifsecondargument
- \doifelsenothing{#1}
- {\dodosetuptextbackground{#2}\empty}
- {\processcommalist[#1]{\dodosetuptextbackground{#2}}}%
- \else
- \dodosetuptextbackground{#1}\empty
- \fi}
-
-\def\dodosetuptextbackground#1#2%
- {\getparameters[\??td#2][#1]%
- \def\currenttextbackground{#2}%
- \doifvalue{\??td#2\c!state}\v!start\checktextbackgrounds}
-
-\let\currenttextbackground\empty
-
-\def\checktextbackgrounds
- {\ifproductionrun
- \enabletextarearegistration
- \enablehiddenbackground
- \fi}
-
-\setuptextbackground
- [\c!mp=mpos:par:columnset, % buggy: mpos:par:shape
- \c!method=mpos:par:columnset, %
- \c!state=\v!start,
- \c!location=\v!text,
- \c!leftoffset=\!!zeropoint, % 1em,
- \c!rightoffset=\getvalue{\??td\currenttextbackground\c!leftoffset},
- \c!topoffset=\!!zeropoint, % \v!medium,
- \c!bottomoffset=\getvalue{\??td\currenttextbackground\c!topoffset},
- \c!level=-1,
- \c!alternative=0,
- \c!align=,
- \c!background=\v!color,
- \c!backgroundcolor=lightgray,
- \c!backgroundoffset=\!!zeropoint,
- \c!corner=\v!rectangular,
- \c!radius=.5\bodyfontsize,
- \c!frame=\v!on,
- \c!framecolor=blue,
- \c!rulethickness=\linewidth]
-
-%D As an example we define a grid background:
-
-\definetextbackground
- [\v!grid]
- [\c!state=\v!stop,
- \c!location=\v!paragraph,
- \c!frame=\v!off,
- \c!framecolor=red,
- \c!background=,
- \c!alternative=1]
-
-\ifx\basegrid\undefined \else \letvalue\v!grid=\basegrid \fi
-
-% lelijk, aanpassen, opties
-
-\setupMPvariables
- [mpos:connect]
- [linecolor=red,
- linewidth=1pt]
-
-\setupMPvariables
- [mpos:encircle]
- [fillcolor=lightgray,
- filloffset=\!!zeropoint,
- linecolor=blue,
- linewidth=1pt]
-
-\startuseMPgraphic{mpos:common:ec}
- path pa ; pair ca ; color lc ; numeric lw ;
- lw := \MPvar{linewidth} ;
- lc := \MPvar{linecolor} ;
- initialize_box(\MPpos{\MPvar{self}}) ;
- pa := pxy ; ca := cxy ; pa := boundingbox pa enlarged 2lw ;
- pa := llcorner pa...lrcorner pa...urcorner pa...ulcorner pa...cycle ;
- drawoptions (withpen pencircle scaled lw withcolor lc) ;
-\stopuseMPgraphic
-
-\startMPpositiongraphic{mpos:encircle}{linecolor,fillcolor,linewidth}
- \includeMPgraphic{mpos:common:ec}
- fill pa withcolor \MPvar{fillcolor} ; draw pa ;
- anchor_box(\MPanchor{\MPvar{self}}) ;
-\stopMPpositiongraphic
-
-\startMPpositiongraphic{mpos:connect}{linecolor,linewidth}
- path pb, pc ; pair cb, cc ;
- \includeMPgraphic{mpos:common:ec}
- initialize_box(\MPpos{\MPvar{to}}) ;
- pb := pxy ; cb := cxy ; pb := boundingbox pb enlarged 2lw ;
- pb := llcorner pb...lrcorner pb...urcorner pb...ulcorner pb...cycle ;
- pc := ca {up} .. {down} cb ;
- cc := (pc intersection_point pa) ;
- if intersection_found :
- pc := pc cutbefore cc ;
- cc := (pc intersection_point pb) ;
- if intersection_found :
- pc := pc cutafter cc ;
- drawarrow pc ; drawarrow reverse pc ;
- fi ;
- fi ;
- anchor_box(\MPanchor{\MPvar{self}}) ;
-\stopMPpositiongraphic
-
-%D \macros
-%D {stackposdown, stackposup, stackposleft,stackposright}
-%D
-%D A non graphic example of the use of positioning, is to stack
-%D text in for instance the margin.
-%D
-%D \stackposdown \inleft {some text}The text \type {some text}
-%D goes into the left margin, and \stackposdown \inleft {some
-%D more}\type {some more} as well. When they overlap, they
-%D will not touch.
-%D
-%D Here we said \type {\stackposdown \inleft{some text}}. Instead
-%D of \stackposleft \inleft {one}stacking \stackposleft \inleft
-%D {two}vertically, one can stack horizontally by \stackposleft
-%D \inleft {three}using \type {\stackposleft}.
-%D
-%D We can go in all four directions, using \type {\stackposdown},
-%D \type {\stackposup}, \type {\stackposleft} and \type
-%D {\stackposright}.
-
-\def\stackposdistance{.5em}
-
-\newcounter\currentautopos
-
-\def\POSstackprefix{stack:}
-
-\def\dostackposbox#1#2%
- {\dowithnextbox
- {#2{\let\previousautopos\currentautopos
- \doglobal\increment\currentautopos
- \hpos{\POSstackprefix\currentautopos}
- {\doifoverlappingelse{\POSstackprefix\currentautopos}{\POSstackprefix\previousautopos}
- {#1}
- {\flushnextbox}}}}%
- \hbox}
-
-\def\stackposup {\dostackposbox{\raise\lineheight\flushnextbox}}
-\def\stackposdown {\dostackposbox{\lower\lineheight\flushnextbox}}
-\def\stackposleft {\dostackposbox{\copy\nextbox\hskip\nextboxwd\hskip\stackposdistance}}
-\def\stackposright{\dostackposbox{\hskip\stackposdistance\hskip\nextboxwd\flushnextbox}}
-
-%D \macros
-%D {stackeddown}
-%D
-%D However, a better implementation is possible with the
-%D following macro. We now have an extra key \type {stack} for
-%D margin settings. When set to \type {yes}, this macro comes
-%D into action.
-
-% \def\stackeddown
-% {\dowithnextbox
-% {\doglobal\increment\currentautopos
-% \hpos{\POSstackprefix\currentautopos}
-% {\edef\next
-% {\nextboxht\the\nextboxht
-% \nextboxdp\the\nextboxdp
-% \nextboxwd\the\nextboxwd}%
-% \let\previousautopos\currentautopos
-% \scratchdimen\zeropoint
-% \doloop
-% {\decrement\previousautopos
-% \doifoverlappingelse{\POSstackprefix\currentautopos}{\POSstackprefix\previousautopos}
-% {\advance\scratchdimen\MPh{\POSstackprefix\previousautopos}%
-% \advance\scratchdimen\MPd{\POSstackprefix\previousautopos}}%
-% \exitloop
-% \ifnum\previousautopos<\zerocount\exitloop\fi}%
-% % \ifdim\scratchdimen>\zeropoint
-% \setbox\nextbox\iftracepositions\@EA\ruledhbox\else\@EA\hbox\fi
-% {\lower\scratchdimen\flushnextbox}%
-% \next
-% % \fi
-% \flushnextbox}}}
-
-% Because there can be many stacked items in a line and successive lines, we
-% play dirty and adapt the position and height of the current node so that
-% this becomes visible to a next pass.
-%
-% \startbuffer
-% \inleft {test 1} test 1 \inleft {test 2} test 2 \endgraf
-% \inleft {test 3} test 3
-% \stopbuffer
-% \getbuffer \typebuffer \flushstatus \page
-%
-% \startbuffer
-% \inleft {test 1} test 1 \inleft {test 2} test 2 \inleft {test 3} test 3 \endgraf
-% \inleft {test 4} test 4
-% \stopbuffer
-% \getbuffer \typebuffer \flushstatus \page
-%
-% \startbuffer
-% \inleft {test 1} test 1 \endgraf
-% \inleft {test 2} test 2 \endgraf
-% \inleft {test 3} test 3
-% \stopbuffer
-% \getbuffer \typebuffer \flushstatus \page
-%
-% \startbuffer
-% \inleft {test 1\\test 1} test 1 \inleft {test 2} test 2 \endgraf
-% \inleft {test 3} test 3
-% \stopbuffer
-% \getbuffer \typebuffer \flushstatus \page
-%
-% \startbuffer
-% \inleft {test 1\\test 1\\test 1\\test 1\\test 1} test 1 \endgraf
-% test 2 \endgraf
-% \inleft {test 3} test 3
-% \stopbuffer
-% \getbuffer \typebuffer \flushstatus \page
-%
-% \startbuffer
-% \inleft{test 1} test \inleft{test 2} test \inleft{test 3\\test 3} test
-% \stopbuffer
-% \getbuffer \typebuffer \flushstatus \page
-%
-% \startbuffer
-% \inleft{test 1\\test 1\\test 1} test \inleft{test 2\\test 2} test \inleft{test 3\\test 3\\test 3} test \endgraf
-% \inleft{test 1\\test 1\\test 1} test \inleft{test 2\\test 2} test \inleft{test 3\\test 3\\test 3} test
-% \stopbuffer
-% \getbuffer \typebuffer \flushstatus \page
-
-\newdimen\laststackvmove
-
-\def\stackeddown
- {\bgroup
- % this macro assumes a few things and is meant to work for margin notes
- \dowithnextbox
- {\doglobal\increment\currentautopos
- \global\laststackvmove\zeropoint
- \hpos{\POSstackprefix\currentautopos}
- {\edef\next
- {\nextboxht\the\nextboxht
- \nextboxdp\the\nextboxdp
- \nextboxwd\the\nextboxwd}%
- \let\previousautopos\currentautopos
- \scratchdimen\zeropoint
- \scratchcounter\zerocount
- \doloop
- {\decrement\previousautopos\relax
- \edef\currentposition {\POSstackprefix\currentautopos}%
- \edef\previousposition{\POSstackprefix\previousautopos}%
- \ifnum\MPp\currentposition=\MPp\previousposition\relax
- %\registerstatus{doing \currentautopos/\previousautopos}%
- \doifoverlappingelse\currentposition\previousposition
- {\scratchskip \MPy\currentposition
- \advance\scratchskip-\MPy\previousposition
- \advance\scratchskip-\MPd\currentposition % untested
- \advance\scratchskip \MPd\previousposition % untested
- \advance\scratchskip \MPh\currentposition
- % todo: also take depth into account
- \relax
- \ifdim\scratchskip<\scratchdimen
- %\registerstatus{no \the\scratchskip}%
- \else
- %\registerstatus{yes \the\scratchskip}%
- \scratchdimen\scratchskip
- \fi}%
- \donothing % {\registerstatus{next}}%
- \ifnum\previousautopos<\zerocount\exitloop\fi
- \else
- \exitloop
- \fi}%
- \ifdim\scratchdimen=\zeropoint \else
- \bgroup
- \edef\currentposition{\POSstackprefix\currentautopos}%
- \scratchskip\scratchdimen
- \advance\scratchskip\MPh\currentposition
- \scratchdimen-\scratchdimen
- \advance\scratchdimen\MPy\currentposition
- %\registerstatus{old \currentautopos: \MPy\currentposition/\MPh\currentposition}%
- \expanded{\replacepospxywhd
- {\currentposition}{\MPp\currentposition}{\MPx\currentposition}{\the\scratchdimen}%
- {\MPw\currentposition}{\the\scratchskip}{\MPd\currentposition}}%
- %\registerstatus{new \currentautopos: \MPy\currentposition/\MPh\currentposition}%
- \egroup
- \global\laststackvmove\scratchdimen % new
- \setbox\nextbox\iftracepositions\@EA\ruledhbox\else\@EA\hbox\fi
- {\lower\scratchdimen\flushnextbox}%
- \next
- %\registerstatus{\strut}%
- \fi
- \flushnextbox}%
- \egroup}}
-
-%D The next hack make sure that margin texts near faulty
-%D strutted lines are handled ok.
-
-\newif\ifrepositionmarginbox % \repositionmarginboxtrue
-
-\newcounter\currentmarginpos
-
-% \def\dopositionmarginbox#1%
-% {\bgroup
-% \ifrepositionmarginbox
-% \doglobal\increment\currentmarginpos
-% \setposition{\s!margin:\currentmarginpos}%
-% \scratchdimen=\MPy{\s!margin:\currentmarginpos}%
-% \doglobal\increment\currentmarginpos
-% \advance\scratchdimen by -\MPy{\s!margin:\currentmarginpos}%
-% \advance\scratchdimen by -\strutdp
-% \setbox#1=\hbox
-% {\setposition{\s!margin:\currentmarginpos}\raise\scratchdimen\box#1}%
-% \dp#1=\!!zeropoint
-% \ht#1=\!!zeropoint
-% \fi
-% \vadjust{\box#1}%
-% \egroup}
-
-\def\dopositionmarginbox#1% how about page boundaries !
- {\bgroup
- \ifrepositionmarginbox
- \doglobal\increment\currentmarginpos
- \setposition{\s!margin:\currentmarginpos}%
- \scratchdimen\MPy{\s!margin:\currentmarginpos}%
- \doglobal\increment\currentmarginpos
- \advance\scratchdimen -\MPy{\s!margin:\currentmarginpos}%
- \advance\scratchdimen -\strutdp
- % new
- \setbox#1\hbox
- {\hskip-\MPx{\s!margin:\currentmarginpos}%
- \hskip\MPx{head:\realfolio}%
- \box#1}%
- % so far
- \setbox#1\hbox
- {\setposition{\s!margin:\currentmarginpos}%
- \raise\scratchdimen\box#1}%
- \dp#1\zeropoint
- \ht#1\zeropoint
- \fi
- \graphicvadjust{\box#1}%
- \egroup}
-
-%D For a right menu, a sequence of calls to \type
-%D {right_menu_button} is generated.
-%D
-%D \starttyping
-%D right_menu_button (n, p, s=0/1/2, x, y, w, h, d) ;
-%D \stoptyping
-%D
-%D Here, n is the number of the button, s a status variable,
-%D while the rest is positional info. The status variable is
-%D 0, 1 or~2: not found, found and found but current page.
-
-% 0=not found 1=found 2=current page
-
-% geen leeg
-
-\newtoks\MPmenutoks
-
-\def\MPmenubuttons#1{\the\MPmenutoks}
-
-\appendtoks \global\MPmenutoks\emptytoks \to \everyshipout
-
-% 0=notfound 1=found 2=currentpage
-
-\def\do@@amposition#1#2#3%
- {\doifelsevalue{\??am#1\c!position}\v!yes
- {\doglobal\increment\currentamposition
- \doifnumberelse{#2}
- {\docheckrealreferencepage{#2}%
- \global\chardef\currentamrealpage\ifrealreferencepage2\else1\fi}
- {\doifreferencefoundelse{#2}
- {\global\chardef\currentamrealpage\ifrealreferencepage2\else1\fi}
- {\global\chardef\currentamrealpage0}}% % not found
- \expanded
- {\doglobal\noexpand\appendtoks
- #1_menu_button(\currentamposition,\the\currentamrealpage,\noexpand\MPpos{#1:\currentamposition}) ;
- \to \MPmenutoks}%
- \hpos{#1:\currentamposition}{#3}}
- {#3}}
-
-\def\do@@ammenuposition#1%
- {\ifnum\currentamposition>0
- \dowithnextbox{\hpos{menu:#1:\realfolio}{\flushnextbox}}\hbox
- \fi}
-
-%D \macros
-%D {GFC, GTC, GSC}
-%D
-%D The next macros extend tables and tabulation with
-%D backgrounds and position related features. Areas are
-%D specified with symbolic names, and symbolic references to
-%D the graphics involved. Each table has its own namespace.
-
-\newcounter\noftabpositions
-\newtoks \posXCtoks
-
-\def\tbPOSprefix
- {tbp:\noftabpositions:}
-
-\def\tablepos
- {\scratchtoks\posXCtoks
- \global\posXCtoks\emptytoks
- \the\scratchtoks}
-
-\let\tabulatepos\tablepos
-
-\def\dodododoGSC[#1:#2]%
- {\remappositionframed{#2}{\tbPOSprefix#1}%
- \bpos{\tbPOSprefix#1}%
- \doglobal\appendtoks\@EA\epos\@EA{\tbPOSprefix#1}\to\posXCtoks}
-
-\def\dododoGSC[#1:#2:#3]%
- {\doglobal\appendtoks\dodododoGSC[#1:#2]\to\posXCtoks\NC}
-
-\def\dodoGSC[#1]%
- {\def\docommando##1{\dododoGSC[##1:##1]}%
- \processcommalist[#1]\docommando}
-
-\def\dodododoGFC[#1:#2:#3]%
- {\remappositionframed{#2}{\tbPOSprefix#1}%
- \bpos{\tbPOSprefix#1}}
-
-\def\dododoGFC[#1]%
- {\def\docommando##1{\dodododoGFC[##1:##1]}%
- \processcommalist[#1]\docommando}
-
-\def\dodoGFC[#1]%
- {\doglobal\appendtoks\dododoGFC[#1]\to\posXCtoks\NC}
-
-\def\dododododoGTC[#1:#2]%
- {\epos{\tbPOSprefix#1}}
-
-\def\dodododoGTC[#1]%
- {\def\docommando##1{\dododododoGTC[##1:##1]}%
- \processcommalist[#1]\docommando}
-
-\def\dododoGTC[#1]%
- {\doglobal\appendtoks\dodododoGTC[#1]\to\posXCtoks}
-
-\def\dodoGTC[#1]%
- {\doglobal\appendtoks\dododoGTC[#1]\to\posXCtoks\NC}
-
-\def\dodododoXC[#1#2]%
- {\if#1>\dodoGFC [#2:#2]\else
- \if#1+\dodoGFC [#2:#2]\else
- \if#1<\dodoGTC [#2:#2]\else
- \if#1-\dodoGTC [#2:#2]\else
- \if#1=\dodoGSC [#2:#2]\else
- \dodoGSC[#1#2:#1#2]\fi\fi\fi\fi\fi}
-
-\def\dododoXC#1%
- {\dodododoXC[#1]}
-
-\def\dodoXC[#1]%
- {{\let\NC\relax\processcommalist[#1]\dododoXC}}
-
-\def\doGSC[#1]{\iffirstargument\dodoGSC[#1]\else\expandafter\NC\fi}
-\def\doGFC[#1]{\iffirstargument\dodoGFC[#1]\else\expandafter\NC\fi}
-\def\doGTC[#1]{\iffirstargument\dodoGTC[#1]\else\expandafter\NC\fi}
-\def\doXC [#1]{\iffirstargument\dodoXC [#1]\else\expandafter\fi\NC}
-
-\def\tbGSC{\dosingleempty\doGSC}
-\def\tbGFC{\dosingleempty\doGFC}
-\def\tbGTC{\dosingleempty\doGTC}
-\def\tbXC {\dosingleempty\doXC }
-
-%D The amount of code to support tables and tabulation is
-%D rather minimalistic.
-
-\let\tabulatepos\tablepos
-
-\def\tabulatenormalpos
- {\hss\tabulatepos\hss}
-
-\def\tabulateequalpos
- {\setbox\scratchbox\hbox{\tabulateEQ}%
- \hbox to \wd\scratchbox{\hss\kern\zeropoint\tabulatepos\hss}%
- \hskip-\wd\scratchbox
- \box\scratchbox}
-
-\def\tabulatenormalcolumn#1% overloaded
- {&\iftabulateequal\tabulateequalpos\else\tabulatenormalpos\fi
- &\global\chardef\tabulatetype#1&}
-
-\def\tabulateequalcolumn#1% overloaded
- {&\tabulateequalpos
- &\global\chardef\tabulatetype#1&}
-
-\appendtoks
- \doglobal\increment\noftabpositions
-\to \everytabulate
-
-%D In order to prevent potential clashes with abbreviations,
-%D postpone the mapping.
-
-\appendtoks
- \let\GSC\tbGSC \let\GFC\tbGFC \let\GTC\tbGTC \let\XC\tbXC
-\to \everytabulate
-
-%D \macros
-%D {definepositionframed}
-%D
-%D The next example show how to provide backgrounds to table
-%D cells. First we define some framed backgrounds.
-%D
-%D \startbuffer
-%D \definepositionframed[x][background=color,backgroundcolor=red]
-%D \definepositionframed[y][background=color,backgroundcolor=green]
-%D \definepositionframed[z][background=color,backgroundcolor=blue]
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D % \getbuffer
-%D
-%D \startbuffer
-%D \starttabulate[|c|c|c|]
-%D \GFC[f:x] this is a small \NC table \NC in which we \NC \FR
-%D \NC will demonstrate \GFC[g:z] that this \GTC[g] positioning \NC \MR
-%D \GSC[e:y] mechanism also \GTC[f] works quite well \NC in tables \NC \LR
-%D \stoptabulate
-%D \stopbuffer
-%D
-%D The table itself defines three areas (a, b and~c) using
-%D these frames.
-%D
-%D \typebuffer
-%D % \getbuffer
-%D
-%D Tables (based on \TABLE) are supported by:
-
-\def\normalTABLEsimplebar {\unskip\!ttRightGlue&\tablepos&} % |
-\def\normalTABLEcomplexbar{\unskip\!ttRightGlue&\omit\tablepos\!ttAlternateVrule} % \|
-\def\normalTABLEquote {\unskip\!ttRightGlue&\omit\tablepos&} % "
-
-\appendtoks
- \doglobal\increment\noftabpositions
-\to \everytable
-
-%D Since we don't want nameclashes:
-
-\appendtoks
- \let\GSC\tbGSC \let\GFC\tbGFC \let\GTC\tbGTC \let\XC\tbXC
-\to \everytable
-
-%D In the previous example, we could have provided an overlay to
-%D the framed definition. A more direct approach is demonstrated
-%D below:
-%D
-%D \startbuffer
-%D \def\cw#1{\color[white]{#1}}
-%D
-%D \startMPpositiongraphic{tableshade}
-%D initialize_area(\MPpos{\MPvar{from}},\MPpos{\MPvar{to}}) ;
-%D color c ; c := \MPvar{color} ;
-%D linear_shade(pxy,0,.4c,.9c) ;
-%D anchor_area(\MPanchor{\MPvar{from}}) ;
-%D \stopMPpositiongraphic
-%D
-%D \setMPpositiongraphic{b:x}{tableshade}{from=b:x,to=e:x,color=red}
-%D \setMPpositiongraphic{b:y}{tableshade}{from=b:y,to=e:y,color=green}
-%D \setMPpositiongraphic{b:z}{tableshade}{from=b:z,to=e:z,color=blue}
-%D \stopbuffer
-%D
-%D \typebuffer \getbuffer
-%D
-%D The definition of the table looks about the same as the
-%D previous one:
-%D
-%D \startbuffer
-%D \starttable[|c|c|c|]
-%D \GFC[b:z] \cw{this is a small} \NC \cw{table} \NC in which we \NC \FR
-%D \NC \cw{will demonstrate} \GFC[c:y] \cw{that this} \GTC[c] \cw{positioning} \NC \MR
-%D \GSC[a:x] \cw{mechanism also} \GTC[b] \cw{works quite well} \NC in tables \NC \LR
-%D \stoptable
-%D \stopbuffer
-%D
-%D \typebuffer
-%D
-%D \getbuffer
-
-% \definepositionframed[w][background=color,backgroundcolor=yellow]
-% \definepositionframed[x][background=color,backgroundcolor=red]
-% \definepositionframed[y][background=color,backgroundcolor=green]
-% \definepositionframed[z][background=color,backgroundcolor=blue]
-%
-% \starttabulate[|c|c|c|]
-% \NC this is a small \NC table \NC in which we \NC \FR
-% \NC will demonstrate \NC that this \NC positioning \NC \MR
-% \NC mechanism also \NC works quite well \NC in tables \NC \LR
-% \stoptabulate
-%
-% \starttabulate[|c|c|c|]
-% \GFC[f:x] this is a small \GTC table \NC in which we \NC \FR
-% \NC will demonstrate \GFC[g:z] that this \GTC[g] positioning \NC \MR
-% \GSC[e:y] mechanism also \GTC[f] works quite well \NC in tables \NC \LR
-% \stoptabulate
-%
-% \starttabulate[|c|c|c|]
-% \GFC[f:x,d:w] this is a small \GTC[d] table \NC in which we \NC \FR
-% \NC will demonstrate \GFC[g:z] that this \GTC[g] positioning \NC \MR
-% \GSC[e:y] mechanism also \GTC[f] works quite well \NC in tables \NC \LR
-% \stoptabulate
-%
-% \starttabulate[|c|c|c|]
-% \XC[+f:x] this is a small \XC table \NC in which we \NC \FR
-% \NC will demonstrate \XC[+g:z] that this \XC[-g] positioning \NC \MR
-% \XC[=e:y] mechanism also \XC[-f] works quite well \NC in tables \NC \LR
-% \stoptabulate
-%
-% \starttabulate[|c|c|c|]
-% \XC[+f:x,+d:w] this is a small \XC[-d] table \NC in which we \NC \FR
-% \NC will demonstrate \XC[+g:z] that this \XC[-g] positioning \NC \MR
-% \XC[=e:y] mechanism also \XC[-f] works quite well \NC in tables \NC \LR
-% \stoptabulate
-
-% evt [b:x]
-%
-% \definepositionframed[x][background=color,fillcolor=red]
-% \definepositionframed[y][background=color,fillcolor=green]
-% \definepositionframed[z][background=color,fillcolor=blue]
-
-\def\remappositionframed#1#2% from to
- {\copyposition{b:#1}{b:#2}%
- \copyposition{e:#1}{e:#2}%
- \dosetpositionaction{b:#2}{\dopositionaction{b:#1}}}
-
-\def\definepositionframed
- {\dodoubleargument\dodefinepositionframed}
-
-\def\dodefinepositionframed[#1][#2]%
- {\dosetpositionaction{b:#1}{\dopositionframed[#1][#2]}}
-
-\def\positionframed
- {\dodoubleempty\dopositionframed}
-
-\def\dopositionframed[#1][#2]%
- {\bgroup
- \setbox\scratchbox\hbox
- {\dimen0=\MPx{e:#1}%
- \advance\dimen0 -\MPx{b:#1}%
- \dimen2=\MPy{b:#1}%
- \advance\dimen2 -\MPy{e:#1}%
- \advance\dimen2 \MPd{e:#1}%
- \lower\dimen2\hbox
- {\advance\dimen2 \MPh{b:#1}%
- \framed
- [\c!width=\dimen0,\c!height=\dimen2,
- \c!offset=\v!overlay,#2]{}}}%
- \smashedbox\scratchbox
- \egroup}
-
-% \def\sethdistances#1%
-% {\hbox{\lpos{ml:#1}\hpos{mh:#1}{\strut}\rpos{mr:#1}}}
-%
-% \def\gethdistances#1%
-% {\scratchdimen\MPx{mh:#1}%
-% \advance\scratchdimen -\MPx{ml#1}%
-% \edef\lefthdistance{\the\scratchdimen}%
-% \scratchdimen\MPx{mr:#1}%
-% \advance\scratchdimen -\MPx{mh:#1}%
-% \edef\righthdistance{\the\scratchdimen}}
-
\protect \endinput
-
-% todo 1: shift down option
-
-\startuseMPgraphic{mpos:par:columnset}
- \iftracepositions show_multi_pars \else draw_multi_pars \fi ;
- path p ; p := boundingbox currentpicture ;
- currentpicture := currentpicture shifted (0,-StrutDepth/2) ;
- setbounds currentpicture to p ;
-\stopuseMPgraphic
-
-\setupcolors[state=start]
-
-\definetextbackground[underline][location=text,alternative=1,background=,frame=off,distance=2pt]
-
-\definestartstop
- [underline]
- [before={\starttextbackground[underline]},
- after=\stoptextbackground]
diff --git a/tex/context/base/core-rul.tex b/tex/context/base/core-rul.tex
index 88fcb8cb2..509422e3d 100644
--- a/tex/context/base/core-rul.tex
+++ b/tex/context/base/core-rul.tex
@@ -556,18 +556,18 @@
\def\@@frame@@{@@frame@@}
-\setvalue{t\@@frame@@\v!on\v!on}{\hrule\!!height\ruledlinewidth\kern-\ruledlinewidth}
+\setvalue{t\@@frame@@\v!on \v!on}{\hrule\!!height\ruledlinewidth\kern-\ruledlinewidth}
\setvalue{t\@@frame@@\v!off\v!on}{\hrule\!!height\ruledlinewidth\kern-\ruledlinewidth}
- \setvalue{t\@@frame@@\v!on}{\hrule\!!height\ruledlinewidth\kern-\ruledlinewidth}
-\setvalue{b\@@frame@@\v!on\v!on}{\kern-\ruledlinewidth\hrule\!!height\ruledlinewidth}
+\setvalue{t\@@frame@@\v!on }{\hrule\!!height\ruledlinewidth\kern-\ruledlinewidth}
+\setvalue{b\@@frame@@\v!on \v!on}{\kern-\ruledlinewidth\hrule\!!height\ruledlinewidth}
\setvalue{b\@@frame@@\v!off\v!on}{\kern-\ruledlinewidth\hrule\!!height\ruledlinewidth}
- \setvalue{b\@@frame@@\v!on}{\kern-\ruledlinewidth\hrule\!!height\ruledlinewidth}
-\setvalue{l\@@frame@@\v!on\v!on}{\vrule\!!width\ruledlinewidth\kern-\ruledlinewidth}
+\setvalue{b\@@frame@@\v!on }{\kern-\ruledlinewidth\hrule\!!height\ruledlinewidth}
+\setvalue{l\@@frame@@\v!on \v!on}{\vrule\!!width\ruledlinewidth\kern-\ruledlinewidth}
\setvalue{l\@@frame@@\v!off\v!on}{\vrule\!!width\ruledlinewidth\kern-\ruledlinewidth}
- \setvalue{l\@@frame@@\v!on}{\vrule\!!width\ruledlinewidth\kern-\ruledlinewidth}
-\setvalue{r\@@frame@@\v!on\v!on}{\kern-\ruledlinewidth\vrule\!!width\ruledlinewidth}
+\setvalue{l\@@frame@@\v!on }{\vrule\!!width\ruledlinewidth\kern-\ruledlinewidth}
+\setvalue{r\@@frame@@\v!on \v!on}{\kern-\ruledlinewidth\vrule\!!width\ruledlinewidth}
\setvalue{r\@@frame@@\v!off\v!on}{\kern-\ruledlinewidth\vrule\!!width\ruledlinewidth}
- \setvalue{r\@@frame@@\v!on}{\kern-\ruledlinewidth\vrule\!!width\ruledlinewidth}
+\setvalue{r\@@frame@@\v!on }{\kern-\ruledlinewidth\vrule\!!width\ruledlinewidth}
%D I condidered using the low level support command
%D \type{\ruledhbox}, but this would slow down processing by a
diff --git a/tex/context/base/core-sec.tex b/tex/context/base/core-sec.tex
index bf60a2ae6..446eab57e 100644
--- a/tex/context/base/core-sec.tex
+++ b/tex/context/base/core-sec.tex
@@ -135,37 +135,40 @@
\def\dohandleheadnumber#1%
{\expanded{\separatednumber{#1}}}
-\def\dodochecknummer#1#2#3% will become ugly after speed up
+\def\dodochecknumber#1#2#3% will become ugly after speed up
{\bgroup
\doifinstringelse{.0}{.#2}
{\doifnot{#3}\v!by
{%\debuggerinfo\m!systems{number #1 #3 becomes \getnumbervariable{#1\c!way}}%
\setevalue{\@@thenumber{#1}\c!way}{#3}% geen \xdef, gaat mis met \subpage
- \dochecknummer{#1}}} % tricky and ugly
+ \dochecknumber{#1}}} % tricky and ugly
{\doifnotvalue{\@@thenumber{#1}\s!check}{#2}
- {\setcounter{\@@thenumber{#1}}{0\getvalue{\@@thenumber{#1}\c!start}}%
- \setxvalue{\@@thenumber{#1}\c!way\c!local}%
- {\getvalue{\@@thenumber{#1}\c!way}}%
- \setxvalue{\@@thenumber{#1}\s!check}%
- {#2}}}%
+ {% new, calculate accumulated number
+ \scratchcounter\getvalue{\@@thenumber{#1}\c!n}\relax
+ \advance\scratchcounter\countervalue{\@@thenumber{#1}}\relax
+ \setxvalue{\@@thenumber{#1}\c!n}{\the\scratchcounter}%
+ %
+ \setcounter{\@@thenumber{#1}}{0\getvalue{\@@thenumber{#1}\c!start}}%
+ \setxvalue{\@@thenumber{#1}\c!way\c!local}{\getvalue{\@@thenumber{#1}\c!way}}%
+ \setxvalue{\@@thenumber{#1}\s!check}{#2}}}%
\egroup}
-\def\dochecknummer#1%
+\def\dochecknumber#1%
{\edef\currentsection{\csname\??by\csname\@@thenumber{#1}\c!way\endcsname\endcsname}%
\ifx\currentsection\empty\else
- \dodochecknummer
+ \dodochecknumber
{#1}%
{\csname\currentsection\c!number\endcsname}%
{\v!by\previoussection\currentsection}%
\fi}
-\def\checknummer#1%
+\def\checknumber[#1]%
{\bgroup
%\ifcase\blocklevel\else
\ifdoingblocks
\doifnotvalue{\@@thenumber{#1}\c!blockway}\v!no\setblockcounters
\fi
- \dochecknummer{#1}%
+ \dochecknumber{#1}%
\egroup}
\def\rawsectionnumber#1%
@@ -265,33 +268,36 @@
\letvalue{\??by\v!by\v!all }\v!text
\letvalue{\??by\v!by\v!page}\v!text % see footnotes
-%%%%%%%%% old
-
-\def\dosetupsection[#1][#2]%
- {\getparameters[\??se#1][#2]%
- \doifelsevalue{\??se#1\c!previousnumber}\v!yes
- {\setvalue{#1\c!number}{\@@longsectionnumber{#1}}}
- {\setvalue{#1\c!number}{\@@shortsectionnumber{#1}}}}
+\def\sectionofhead#1{\executeifdefined{\??ko#1\c!section}\s!unknown}
\def\setupsection
- {\dodoubleargument\dosetupsection}
-
-%%%%%%%%% new, multilingual
-
-\def\dosetupsection[#1][#2][#3]%
- {\ifthirdargument
- \getparameters[\??se#1#2][#3]%
- \else
- \getparameters[\??se#1][#2]%
- \fi
- \doifelsevalue{\??se#1\c!previousnumber}\v!yes
- {\setvalue{#1\c!number}{\@@longsectionnumber {#1}}}
- {\setvalue{#1\c!number}{\@@shortsectionnumber{#1}}}}
-
-\def\setupsection%
{\dotripleempty\dosetupsection}
-%%%%%%%%%
+\def\dosetupsection[#1]%
+ {\doifdefinedelse{\??se#1}
+ {\dodosetupsection[#1]}%
+ {\dodosetupsection[\sectionofhead{#1}]}}
+
+% \def\dosetupsection[#1][#2][#3]%
+% {\ifthirdargument
+% \getparameters[\??se#1#2][#3]%
+% \else
+% \getparameters[\??se#1][#2]%
+% \fi
+% \doifelsevalue{\??se#1\c!previousnumber}\v!yes
+% {\setvalue{#1\c!number}{\@@longsectionnumber {#1}}}
+% {\setvalue{#1\c!number}{\@@shortsectionnumber{#1}}}}
+
+\def\dodosetupsection[#1][#2][#3]%
+ {\doifdefined{\??se#1}
+ {\ifthirdargument
+ \getparameters[\??se#1#2][#3]%
+ \else
+ \getparameters[\??se#1][#2]%
+ \fi
+ \doifelsevalue{\??se#1\c!previousnumber}\v!yes
+ {\setvalue{#1\c!number}{\@@longsectionnumber {#1}}}
+ {\setvalue{#1\c!number}{\@@shortsectionnumber{#1}}}}}
\def\docouplemarking[#1][#2]%
{\doifdefinedelse{\??ko#2\c!section}
@@ -1170,7 +1176,7 @@
\newif\ifemptyhead
\newif\ifwritetolist
\newif\ifheadnumber
-\newif\ifcontinuoushead
+\newif\ifzushead
\newif\ifheadnumbercontent % niet meer wijzigen / wordt mode
\newif\ifheadprefix
\newif\ifsomeheadconversion
@@ -1495,16 +1501,16 @@
\rawreference\s!sec{#2}{{#3}{\asciititle}}%
\resetsectionmarks\@@sectie
\setlistparameter\@@koppeling\c!expansion{\getvalue{\??ko#1\c!expansion}}%
-\doifelsevalue{\??ko#1\c!ownnumber}\v!yes % brrr, new per 18/1/2005, sometimes we need
- {\dowritetolist\@@koppeling{#3}{#4}\v!head} % entries in the list (special purpose) but
- {\dowritetolist\@@koppeling {}{#4}\v!head}% not in the header, ok we could pop in a command
-}% \dowritetolist\@@koppeling{}{#4}\v!head}
+ \doifelsevalue{\??ko#1\c!ownnumber}\v!yes % brrr, new per 18/1/2005, sometimes we need
+ {\dowritetolist\@@koppeling{#3}{#4}\v!head} % entries in the list (special purpose) but
+ {\dowritetolist\@@koppeling {}{#4}\v!head}% not in the header, ok we could pop in a command
+ }% \dowritetolist\@@koppeling{}{#4}\v!head}
{#4}
{\marking[#1]{#4}%
\doifelsevalue{\??ko#1\c!ownnumber}\v!yes % brrr
{\edef\finalsectionnumber{#3}}
{\determineheadnumber[#1]}%
-% todo : geen markering (leeg maken)
+ % todo : geen markering (leeg maken)
\expanded{\marking[#1\v!number]{\finalsectionnumber}}}%
\writesection{#1}{-}{#4}%
\fi
@@ -1887,72 +1893,6 @@
\def\localheadsetup{\dolocalheadsetup{#1}}%
\startsynchronization}
-% \def\endheadplacement#1#2%
-% {\doifelsevalue{\??rf#1\c!state}\v!start
-% {\doifvaluenothing{\??ko#1\c!file}{\autocrossdocumentfalse}}
-% {\autocrossdocumentfalse}%
-% % no message needed here, should be a proper switch
-% % \let\unknownreference\gobbleoneargument
-% \ifdisplaysectionhead
-% \let\headlastlinewidth\!!zeropoint
-% \snaptogrid[\getvalue{\??ko#1\c!grid}]\hbox
-% {\hskip\localheadskip
-% \hskip\getvalue{\??ko#1\c!margin}\relax
-% \iflocation
-% \ifautocrossdocument
-% \doifreferencefoundelse{\getvalue{\??ko#1\c!file}::#1}
-% {\edef\currentinnerreference{\s!aut:\currenttextreference}% stored in
-% \gotoouterlocation{}{\box0}} % text slot
-% {\hbox{\box0}}%
-% \else
-% \hbox{\box0}%
-% \fi
-% \else
-% \hbox{\box0}%
-% \fi}%
-% \doflushnotes % new, not really needed
-% \endgraf
-% \nointerlineskip
-% \dosomebreak\nobreak
-% #2%
-% \else
-% \strut
-% \doflushnotes % new, here since we're in par mode
-% \iflocation
-% \ifautocrossdocument
-% \hhboxindent=\ifcontinuoushead\headlastlinewidth\else\zeropoint\fi
-% \unhhbox0\with{\gotobox{\box\hhbox}[\getvalue{\??ko#1\c!file}::#1]}%
-% \advance\lasthhboxwidth by \numberheaddistance
-% \xdef\headlastlinewidth{\the\lasthhboxwidth}%
-% \else
-% \unhbox0
-% \globallet\headlastlinewidth\!!zeropoint
-% \fi
-% \else
-% \unhbox0
-% \globallet\headlastlinewidth\!!zeropoint
-% \fi
-% #2%
-% \dimen0=\numberheaddistance
-% \hskip\dimen0 \!!plus \dimen0 \!!minus .25\dimen0
-% \hskip\headsignal\ignorespaces
-% \fi
-% \ifdisplaysectionhead \ifvmode
-% \ifgridsnapping % important, font related depth, see comment
-% \prevdepth\strutdp
-% \else
-% \prevdepth\localheaddepth
-% \fi
-% \fi \fi
-% \stopsynchronization
-% \egroup
-% \egroup
-% \ifdisplaysectionhead
-% \dochecknextindentation{\??ko#1}%
-% \else
-% \nonoindentation % recently added, was a bug
-% \fi}
-
% \setuphead[chapter] [style=\bfd,after=,hang=line] % fit broad 2
% \setuphead[section] [style=\bfc,after=,hang=line]
% \setuphead[subsection] [style=\bfb,after=,hang=line]
@@ -1989,6 +1929,8 @@
\dp0 \strutdp
\edef\localheaddepth{\the\strutdp}}
+\newconditional\continuoussectionhead % oeps, \newif\ifcontinuoushead got lost
+
\def\endheadplacement#1#2%
{\doifelsevalue{\??rf#1\c!state}\v!start
{\doifvaluenothing{\??ko#1\c!file}{\autocrossdocumentfalse}}
@@ -2037,7 +1979,7 @@
\doflushnotes % new, here since we're in par mode
\iflocation
\ifautocrossdocument
- \hhboxindent=\ifcontinuoushead\headlastlinewidth\else\zeropoint\fi
+ \hhboxindent=\ifconditional\continuoussectionhead\headlastlinewidth\else\zeropoint\fi
\unhhbox0\with{\gotobox{\box\hhbox}[\getvalue{\??ko#1\c!file}::#1]}%
\advance\lasthhboxwidth by \numberheaddistance
\xdef\headlastlinewidth{\the\lasthhboxwidth}%
@@ -2075,14 +2017,14 @@
\scratchcounter=\lastpenalty\unpenalty % no beauty in this
\ifdim\lastskip=\headsignal
\handlepagebreakC{#1}%
- \global\continuousheadtrue
+ \global\settrue\continuoussectionhead
\else
\penalty\scratchcounter
- \global\continuousheadfalse
+ \global\setfalse\continuoussectionhead
#1{#2}%
\fi
\else
- \global\continuousheadfalse
+ \global\setfalse\continuoussectionhead
#1{#2}%
\fi}
diff --git a/tex/context/base/core-spa.tex b/tex/context/base/core-spa.tex
index 9c50ab3bd..406a50ef5 100644
--- a/tex/context/base/core-spa.tex
+++ b/tex/context/base/core-spa.tex
@@ -13,7 +13,7 @@
\writestatus{loading}{Context Spacing Macros}
-% to be sorted out: dependencies, orderof initialization
+% to be sorted out: dependencies, order of initialization
\unprotect
diff --git a/tex/context/base/m-streams.tex b/tex/context/base/m-streams.tex
index 5822a0c9f..d465c390a 100644
--- a/tex/context/base/m-streams.tex
+++ b/tex/context/base/m-streams.tex
@@ -268,6 +268,44 @@
%D \stoptext
%D \stoptyping
+
+\def\starttextstreamlayer
+ {\startstreamlayer}
+
+\def\stoptextstreamlayer
+ {\endgraf
+ % maybe depth if no proper depth and no skip
+ \removelastskip
+ \stopstreamlayer}
+
+\def\placetextstreamlayer{\placestreamlayer}
+
+%D \starttyping
+%D \definestreamlayer[whatever][width=12cm]
+%D
+%D \startstreamlayer[whatever]
+%D \startitemize[columns,two][after=]
+%D \item one
+%D \item two
+%D \item three
+%D \item four
+%D \stopitemize
+%D \stopstreamlayer
+%D
+%D \framed[strut=no,align=normal]{\placestreamlayer[whatever]\obeydepth}
+%D
+%D \starttextstreamlayer[whatever]
+%D \startitemize[columns,two]
+%D \item one
+%D \item two
+%D \item three
+%D \item four
+%D \stopitemize
+%D \stoptextstreamlayer
+%D
+%D \framed[strut=no]{\placetextstreamlayer[whatever]}
+%D \stoptyping
+
\endinput
\setupinterlinespace[top=height]
diff --git a/tex/context/base/m-visual.tex b/tex/context/base/m-visual.tex
index 8e992b855..5ff273f5c 100644
--- a/tex/context/base/m-visual.tex
+++ b/tex/context/base/m-visual.tex
@@ -17,6 +17,27 @@
%D needed them for manuals and styles. The macros are documented
%D in a my way document.
+%D For Mojca:
+%D
+%D \starttyping
+%D \def\simplethesis
+%D {\setupsystem[random=1234]
+%D \title{\fakewords{3}{4}}
+%D \placelist[chapter,section]
+%D \dorecurse{6}
+%D {\chapter{\fakewords{5}{10}}
+%D \dorecurse{5}
+%D {\section{\fakewords{2}{5}}
+%D \dorecurse{2}
+%D {\dorecurse{3}{\fakewords{100}{200}\endgraf}
+%D \placefigure{\fakewords{8}{15}}{\fakefigure{5cm}{3cm}{10cm}{5cm}}
+%D \dorecurse{2}{\fakewords{100}{200}\endgraf}}}}}
+%D
+%D \starttext
+%D \simplethesis
+%D \stoptext
+%D \stoptyping
+
\definecolor[fakerulecolor] [black]
\definecolor[fakebaselinecolor] [green]
\definecolor[fakeparindentcolor][blue]
diff --git a/tex/context/base/meta-dum.tex b/tex/context/base/meta-dum.tex
index 47c550477..10ce6d99a 100644
--- a/tex/context/base/meta-dum.tex
+++ b/tex/context/base/meta-dum.tex
@@ -82,14 +82,16 @@
\globallet\figurereplacementcycle\!!plusone
\fi
\weightGRAYfalse % monochrome anyway
+ \MPcmykcolorsfalse
+ \MPspotcolorsfalse
\defineoverlay
[\s!dummy]
[\useMPgraphic
- {placeholder}%
- {width=\figurewidth,
- height=\figureheight,
- reduction=\@@efreduction,
- color=placeholder:\figurereplacementcycle}]%
+ {placeholder}%
+ {width=\figurewidth,
+ height=\figureheight,
+ reduction=\@@efreduction,
+ color=placeholder:\figurereplacementcycle}]%
\expanded{\localframed
[\??ef]
[\c!width=\figurewidth,
diff --git a/tex/context/base/meta-pag.tex b/tex/context/base/meta-pag.tex
index 32473cb74..8b266add8 100644
--- a/tex/context/base/meta-pag.tex
+++ b/tex/context/base/meta-pag.tex
@@ -181,6 +181,27 @@
\hbox{#1}%
\fi}
+% better, so that we can force a key and share with e.g. renumbering
+%
+% \let\namedtextarea\empty
+%
+% \def\registerMPlocaltextarea#1%
+% {\ifpositioning
+% \bgroup
+% \ifx\namedtextarea\empty
+% \doglobal\increment\currentMPtextareadata
+% \edef\namedtextarea{gbd:\currentMPtextareadata}%
+% \fi
+% \hpos\namedtextarea{\iftracetextareas\boxrulewidth3pt\ruledhbox\fi{#1}}%
+% \edef\ascii{RegisterLocalTextArea(%
+% \MPx\namedtextarea,\MPy\namedtextarea,%
+% \MPw\namedtextarea,\MPh\namedtextarea,\MPd\namedtextarea);}%
+% \global\MPlocaltextareadata\@EA{\ascii}%
+% \egroup
+% \else
+% \hbox{#1}%
+% \fi}
+
\def\resetMPlocaltextarea
{\global\MPlocaltextareadata\emptytoks}
diff --git a/tex/context/base/page-flt.tex b/tex/context/base/page-flt.tex
index 0c93a13ae..18ea5113a 100644
--- a/tex/context/base/page-flt.tex
+++ b/tex/context/base/page-flt.tex
@@ -225,6 +225,43 @@
\v!innermargin,\v!outermargin,\v!inneredge,\v!outeredge,%
\v!text,\v!opposite}% \v!page
+% \def\dodocomplexplacefloat[#1][#2][#3]#4%
+% {\flushnotes
+% \flushsidefloats % here !
+% \ifsomefloatwaiting
+% % this was \checkwaitingfloats spread all over
+% \doifinsetelse\v!always{#2}
+% {\showmessage\m!floatblocks5\empty}
+% {\expanded{\doifcommonelse{#2}{\flushfloatslist}}\doflushfloats\donothing}%
+% % but which should be done before using box \floatbox
+% \fi
+% \ifmargeblokken % waarschijnlijk gebroken ! ! ! !
+% \doifinset\v!margin{#2}
+% {\endgraf
+% \bgroup\everypar{\egroup\the\everypar}%
+% \hsize\@@mbwidth}%
+% \fi
+% \global\insidefloattrue
+% \begingroup % **
+% \the\everyinsidefloat
+% \let\@@extrafloat\empty
+% \presetmorefloatvariables{#2}%
+% \dowithnextboxcontent % better a \the\everyfloattoks
+% {\setlocalfloathsize
+% \getvalue{\??fl#1\c!inner}%
+% \fuzzysnappingfalse
+% \postponenotes} % new
+% {\xdocompletefloat{#1}{#3}{#1}{#2}{#1}{#4}% ** not yet done
+% % we need to carry over the par because of side floats
+% \doifnotinset\v!text{#2}{\carryoverpar\endgroup}%
+% \global\sidefloatdownshift \zeropoint
+% \global\sidefloatextrashift\zeropoint
+% \ifparfloat
+% \doifinset\v!reset{#2}\forgetsidefloats
+% \doinhibitblank
+% \fi}% better move this to side floats
+% \vbox}
+
\def\dodocomplexplacefloat[#1][#2][#3]#4%
{\flushnotes
\flushsidefloats % here !
@@ -251,7 +288,12 @@
\getvalue{\??fl#1\c!inner}%
\fuzzysnappingfalse
\postponenotes} % new
- {\xdocompletefloat{#1}{#3}{#1}{#2}{#1}{#4}% ** not yet done
+ {%
+\doifvaluesomething{\??fl#1\c!criterium}
+ {\ifdim\wd\nextbox>\getvalue{\??fl#1\c!criterium}\relax
+ \edef\forcedfloatmethod{\executeifdefined{\??fl#1\c!fallback}\v!here}%
+ \fi}%
+ \xdocompletefloat{#1}{#3}{#1}{#2}{#1}{#4}% ** not yet done
% we need to carry over the par because of side floats
\doifnotinset\v!text{#2}{\carryoverpar\endgroup}%
\global\sidefloatdownshift \zeropoint
@@ -554,7 +596,6 @@
\fi\fi}
% todo: \floatparameter + \currentfloat - saves many hash entries
-%
\def\dododefinefloat[#1][#2]%
{\presetlocalframed[\??fl#1]%
@@ -623,6 +664,7 @@
\c!sectionnumber=\getvalue{\??kj#1\c!sectionnumber},
\c!conversion=\getvalue{\??kj#1\c!conversion}]%
\presetlabeltext[#1=\Word{#1}~]%
+ \checkfloatracer{\v!float#1}%
\dodefinefloatcommands[#1][#2]}
\def\dodefinefloatcommands[#1][#2]%
@@ -707,6 +749,7 @@
\def\dosavefloatdata % \expanded
{\bgroup
+ \doglobal\increment\noffloatdata
\edef\dosavefloatdata
{\writeutilitycommand
{\twopassentry
@@ -728,48 +771,103 @@
% Er wordt bij \v!altijd als dat nodig is hernummerd.
% Daarbij wordt gebruik gemaakt van de opgeslagen nummers en
% volgorde.
-
-\definetwopasslist\s!float
-
-% \def\dofloatreference
-% {\doglobal\increment\numberedfloat
-% \edef\dodofloatreference
-% {\writeutilitycommand
-% {\twopassentry
-% {\s!float}%
-% {\numberedfloat}%
-% {\composedsectionnumber}}}%
-% \dodofloatreference}
-
+%
+% replaced code:
+%
+% \definetwopasslist\s!float
+%
+% \def\dofloatreference#1%
+% {\doifnot\@@bknumbering\v!nocheck
+% {\doglobal\increment\numberedfloat
+% \doifelse\@@bknumbering\v!text % alternative to yes|page
+% {\let\next\immediatewriteutilitycommand}
+% {\let\next\writeutilitycommand}%
+% \expanded{\next
+% {\noexpand\twopassentry
+% {\s!float}%
+% {\numberedfloat}%
+% {\composedsectionnumber}}}}}
+%
% \def\redofloatorder#1%
-% {\doglobal\increment\nofplacedfloats\relax
-% \gettwopassdata\s!float
-% \iftwopassdatafound
-% \doifnot\composedsectionnumber\twopassdata
-% {\edef\oldcomposedsectionnumber{\composedsectionnumber}%
-% \xdef\composedsectionnumber{\twopassdata}%
-% \showmessage\m!floatblocks1{\nofplacedfloats,#1 \oldcomposedsectionnumber,\composedsectionnumber}}%
-% \fi}
+% {\doifnot\@@bknumbering\v!nocheck
+% {\doglobal\increment\nofplacedfloats\relax
+% \gettwopassdata\s!float
+% \iftwopassdatafound
+% \doifnot\composedsectionnumber\twopassdata
+% {\edef\oldcomposedsectionnumber{\composedsectionnumber}%
+% \xdef\composedsectionnumber{\twopassdata}%
+% \showmessage\m!floatblocks1{\nofplacedfloats,#1 \oldcomposedsectionnumber,\composedsectionnumber}}%
+% \fi}}
+%
+% \def\preparefloatnumber#1%
+% {\incrementnumber[#1]%
+% \makesectionnumber[#1]}
+%
+% \def\tracefloatnumber#1%
+% {\dofloatreference{#1}%
+% \redofloatorder{#1}}
+%
+% \def\checkfloatracer#1%
+% {}
-\def\dofloatreference
- {\doifnot\@@bknumbering\v!nocheck
- {\doglobal\increment\numberedfloat
- \expanded{\writeutilitycommand
- {\noexpand\twopassentry
- {\s!float}%
- {\numberedfloat}%
- {\composedsectionnumber}}}}}
-
-\def\redofloatorder#1%
+\def\checkfloatracer#1%
+ {\newnodelocation{#1}}
+
+\def\tracefloatnumber#1%
{\doifnot\@@bknumbering\v!nocheck
- {\doglobal\increment\nofplacedfloats\relax
- \gettwopassdata\s!float
- \iftwopassdatafound
- \doifnot\composedsectionnumber\twopassdata
- {\edef\oldcomposedsectionnumber{\composedsectionnumber}%
- \xdef\composedsectionnumber{\twopassdata}%
- \showmessage\m!floatblocks1{\nofplacedfloats,#1 \oldcomposedsectionnumber,\composedsectionnumber}}%
+ {\checkfloatracer{\v!float#1}% will go
+ \tagnodelocation{\v!float#1}}}
+
+\def\preparefloatnumber#1%
+ {\doifelse\@@bknumbering\v!nocheck
+ {\incrementnumber[#1]%
+ \makesectionnumber[#1]}
+ {\ifinsidecolumns
+ \chardef\nodelocationmode\zerocount
+ % to be perfected:
+ % \chardef\nodelocationmode\plustwo
+ \fi
+ \ifcase\nodelocationmode
+ \incrementnumber[#1]%
+ \makesectionnumber[#1]%
+ \else
+ % force check, so that we get a proper way-sync and
+ % can use the accumulated number
+ % \checknumber[#1]% \incrementnumber does this
+ \incrementnumber[#1]%
+ \savenumber[#1]%
+ % the real work is done here
+ \checkfloatracer{\v!float#1}% will go
+ \nextnodelocation{\v!float#1}% better \nextfloatnumber
+ \analyzenodelocation{\v!float#1}%
+ \scratchcounter\getnodelocationo{\v!float#1}%
+ \advance\scratchcounter\minusone
+ % here we correct for 'per whatever handling'
+ \advance\scratchcounter-\accumulatednumber[#1]%
+ \setnumber[#1]\scratchcounter
+ \incrementnumber[#1]%
+ \makesectionnumber[#1]%
+ \restorenumber[#1]%
+ % now we're back to normal numbering
\fi}}
+
+%D test case:
+%D
+%D \starttyping
+%D \setupfloat[figure][criterium=\marginwidth,fallback=bottom]
+%D \dorecurse{3}{
+%D \chapter{test}
+%D \placefigure[bottom]{1}{\framed{bottom}}
+%D test
+%D \placetable[bottom]{1}{\framed{table}}
+%D test
+%D \placetable{2}{\framed{table}}
+%D test
+%D \placefigure[left]{2}{\framed{left but way too wide}}
+%D \input tufte
+%D \placefigure[left]{3}{\framed{left but ok}}
+%D \input tufte }
+%D \stoptyping
% In \dofloatinfomessage wordt {{ }} gebruikt omdat anders
% binnen \startpostponing...\stoppostponing geen goede
@@ -1218,27 +1316,50 @@
\def\setfloatcaption % \dosetfloatcaption already in use
{\dodoubleempty\dodosetfloatcaption} % beware, name clash
+% \def\dodosetfloatcaption[#1][#2]#3% to do namespace for number/ascii
+% {\ifnofloatnumber % also handle trialtypesetting
+% \letgvalue{@fl@r@#1}\relax
+% \letgvalue{@fl@t@#1}\relax
+% \else
+% \incrementnumber[#1]%
+% \makesectionnumber[#1]%
+% % \globallet\flcomposedsectionnumber\composedsectionnumber % beware, not unique should be done on a per class base
+% \letgvalue{@fl@n@#1}\composedsectionnumber
+% % indirect macro can be more efficient
+% \setgvalue{@fl@r@#1}%
+% {\dofloatreference
+% \redofloatorder{#1}%
+% % \dowritetolist{#1}{\flcomposedsectionnumber}{#3}{#1}%
+% \dowritetolist{#1}{\getvalue{@fl@n@#1}}{#3}{#1}%
+% \doglobal\convertargument#3\to\flasciititle % \asciititle is global
+% % \doifsomething{#2}{\rawreference\s!flt{#2}{{\flcomposedsectionnumber}{\flasciititle}}}%
+% \doifsomething{#2}{\rawreference\s!flt{#2}{{\getvalue{@fl@n@#1}}{\flasciititle}}}%
+% \letgvalue{@fl@r@#1}\relax}% nils
+% \setgvalue{@fl@t@#1}%
+% % {\preparethenumber{\??kj#1}\flcomposedsectionnumber\preparednumber
+% {\preparethenumber{\??kj#1}{\getvalue{@fl@n@#1}}\preparednumber
+% \doattributes{\??kj#1}\c!style\c!color
+% {\doattributes{\??kj#1}\c!headstyle\c!headcolor
+% {\labeltexts{#1}{\preparednumber}}%
+% \doattributes{\??kj#1}\c!textstyle\c!textcolor
+% {\dotfskip{\getvalue{\??kj#1\c!distance}}#3}}}%
+% \fi}
+
\def\dodosetfloatcaption[#1][#2]#3% to do namespace for number/ascii
{\ifnofloatnumber % also handle trialtypesetting
\letgvalue{@fl@r@#1}\relax
\letgvalue{@fl@t@#1}\relax
\else
- \incrementnumber[#1]%
- \makesectionnumber[#1]%
- % \globallet\flcomposedsectionnumber\composedsectionnumber % beware, not unique should be done on a per class base
+ \preparefloatnumber{#1}%
\letgvalue{@fl@n@#1}\composedsectionnumber
% indirect macro can be more efficient
\setgvalue{@fl@r@#1}%
- {\dofloatreference
- \redofloatorder{#1}%
- % \dowritetolist{#1}{\flcomposedsectionnumber}{#3}{#1}%
+ {\tracefloatnumber{#1}%
\dowritetolist{#1}{\getvalue{@fl@n@#1}}{#3}{#1}%
\doglobal\convertargument#3\to\flasciititle % \asciititle is global
- % \doifsomething{#2}{\rawreference\s!flt{#2}{{\flcomposedsectionnumber}{\flasciititle}}}%
\doifsomething{#2}{\rawreference\s!flt{#2}{{\getvalue{@fl@n@#1}}{\flasciititle}}}%
\letgvalue{@fl@r@#1}\relax}% nils
\setgvalue{@fl@t@#1}%
- % {\preparethenumber{\??kj#1}\flcomposedsectionnumber\preparednumber
{\preparethenumber{\??kj#1}{\getvalue{@fl@n@#1}}\preparednumber
\doattributes{\??kj#1}\c!style\c!color
{\doattributes{\??kj#1}\c!headstyle\c!headcolor
@@ -1448,7 +1569,8 @@
% float is wider than \hsize
\dosetraggedvbox\@@kjkjalign
\setbox\scratchbox\raggedbox % trial run
- {\hsize\captionhsize
+ {\trialtypesettingtrue
+ \hsize\captionhsize
\notesenabledfalse
\putcompletecaption{#4}{#2}{#3}{0}}%
\ifdim\ht\scratchbox>\lineheight % more lines
@@ -1472,7 +1594,8 @@
\edef\captionhsize{\the\scratchdimen}%
\fi
\setbox\scratchbox\vbox % test with overshoot
- {\scratchdimen\captionhsize
+ {\trialtypesettingtrue
+ \scratchdimen\captionhsize
\advance\scratchdimen \captionovershoot
\advance\scratchdimen 3em % an average word length
\ifdim\scratchdimen<\hsize \hsize\scratchdimen \fi
@@ -1735,17 +1858,21 @@
\newcounter\noxfloatlocations
+% \long\def\dofloat#1#2#3#4%
+% {\dosetfloatbox{#1}{#2}{#3}{#4}%
+% \doifelsevaluenothing{\??fl#4\c!criterium}
+% {\dogetfloatbox{#1}\empty}
+% {\ifdim\wd\floatbox>\getvalue{\??fl#4\c!criterium}\relax
+% \postcenterfloatbox{\wd\floatbox}% else we get left aligned
+% %dogetfloatbox{#1}\v!here % see details/pascal
+% \dogetfloatbox{#1}{\executeifdefined{\??fl#4\c!fallback}\v!here}%
+% \else
+% \dogetfloatbox{#1}\empty
+% \fi}}
+
\long\def\dofloat#1#2#3#4%
{\dosetfloatbox{#1}{#2}{#3}{#4}%
- \doifelsevaluenothing{\??fl#4\c!criterium}
- {\dogetfloatbox{#1}\empty}
- {\ifdim\wd\floatbox>\getvalue{\??fl#4\c!criterium}\relax
- \postcenterfloatbox{\wd\floatbox}% else we get left aligned
- %dogetfloatbox{#1}\v!here % see details/pascal
- \dogetfloatbox{#1}{\executeifdefined{\??fl#4\c!fallback}\v!here}%
- \else
- \dogetfloatbox{#1}\empty
- \fi}}
+ \dogetfloatbox{#1}\empty}
\let\naturalfloatheight\!!zeropoint
\let\naturalfloatwidth \!!zeropoint
@@ -1756,6 +1883,51 @@
\xdef\naturalfloatwidth {\the\wd#1}%
\xdef\naturalfloatdepth {\the\dp#1}}
+% \long\def\docompletefloat#1#2#3#4#5#6#7% #7 = box number
+% {%\flushsidefloats % moved
+% \presetfloatvariables{#1}{#4}{#2}{#6}%
+% \bgroup
+% \setnaturalfloatdimensions#7%
+% \global\setbox\floatbox\vbox
+% {\executeifdefined{\??fl#1\c!command}\firstofoneargument{\box#7}}%
+% \setnaturalfloatdimensions\floatbox
+% \dimen0 \ht\floatbox
+% \advance\dimen0 \dp\floatbox
+% \ifdim\dimen0=\zeropoint
+% \showmessage\m!floatblocks{11}\empty
+% \global\setbox\floatbox\vbox{\doemptyblock{#3}}%
+% \fi
+% \ifnofloatcaption
+% \global\setbox\floatbox\vbox
+% {\unvbox\floatbox
+% \vss % gets rid of the depth (unless tabulate)
+% \rawpagereference\s!flt{#2}}%
+% \egroup
+% \dofloat{#4}{}{#6}{#1}%
+% \else
+% \doglobal\convertargument#6\to\asciititle % \asciititle is global
+% \ifnofloatnumber
+% \global\setbox\floatbox\vbox
+% {\unvbox\floatbox % no \vss, keep the depth
+% \rawreference\s!flt{#2}{{}{\asciititle}}}%
+% \egroup
+% \dofloat{#4}{}{#6}{#1}%
+% \else
+% \incrementnumber[#1]%
+% \makesectionnumber[#1]%
+% \global\setbox\floatbox\vbox
+% {\unvbox\floatbox % no \vss, keep the depth
+% \dofloatreference
+% \redofloatorder{#1}%
+% \rawreference\s!flt{#2}{{\composedsectionnumber}{\asciititle}}%
+% \dowritetolist{#3}{\composedsectionnumber}{#6}{#3}}%
+% \egroup
+% \preparethenumber{\??kj#1}\composedsectionnumber\preparednumber
+% \dofloat{#4}{\labeltexts{#5}{\preparednumber}}{#6}{#1}%
+% \fi
+% \fi
+% \global\insidefloatfalse}
+
\long\def\docompletefloat#1#2#3#4#5#6#7% #7 = box number
{%\flushsidefloats % moved
\presetfloatvariables{#1}{#4}{#2}{#6}%
@@ -1786,12 +1958,10 @@
\egroup
\dofloat{#4}{}{#6}{#1}%
\else
- \incrementnumber[#1]%
- \makesectionnumber[#1]%
+ \preparefloatnumber{#1}%
\global\setbox\floatbox\vbox
{\unvbox\floatbox % no \vss, keep the depth
- \dofloatreference
- \redofloatorder{#1}%
+ \tracefloatnumber{#1}%
\rawreference\s!flt{#2}{{\composedsectionnumber}{\asciititle}}%
\dowritetolist{#3}{\composedsectionnumber}{#6}{#3}}%
\egroup
@@ -2032,12 +2202,15 @@
% ook (continued)
+\newif\ifinsidesplitfloat % will become chardef
+
\def\dosplitfloat[#1]#2% nog dubbele refs
- {\ifinsidecolumns % tzt ook nog figuren splitten
+ {\ifinsidecolumns % tzt ook nog figuren splitten
% not yet supported
\else
\bgroup
\insidefloattrue
+ \insidesplitfloattrue
\getparameters[\??si][#1]%
\resetnumber[\??si]%
\def\floatcaptionsuffix{\convertednumber[\??si]}%
@@ -2071,6 +2244,8 @@
\def\splitfloat
{\dosingleempty\dosplitfloat}
+
+% \splitfloat [settings] {\placetable[optional args]{test}} {content}
\def\dooutput{\sidefloatoutput} % redefinition of \dooutput
diff --git a/tex/context/base/page-mul.tex b/tex/context/base/page-mul.tex
index 1eb1a4e81..991e7532d 100644
--- a/tex/context/base/page-mul.tex
+++ b/tex/context/base/page-mul.tex
@@ -637,7 +637,7 @@
\chardef\columnedtopflushmethod\plusone
-\def\flushcolumnedpage
+\def\flushcolumnedpage#1%
{\bgroup
\forgetall
\setmulticolumnsout
@@ -729,6 +729,22 @@
\global\finalcolumnheights\ht\columnpagebox
\getnoflines\finalcolumnheights
\global\finalcolumnlines\noflines
+ \ifcase#1\else
+ % messy correction, we need to rewrite this module (newcolumns)
+ \setbox\columnpagebox\vbox
+ {\offinterlineskip
+ \scratchdimen\ht\columnpagebox
+ \advance\scratchdimen\dp\columnpagebox % we probably lost that one already
+ \box\columnpagebox
+ \vskip-\scratchdimen}%
+ \scratchdimen\noflines\openlineheight
+ \advance\scratchdimen-\openstrutdepth
+ \advance\scratchdimen-\openlineheight
+ \advance\scratchdimen\topskip
+ \ht\columnpagebox\scratchdimen
+ \dp\columnpagebox\openstrutdepth
+ % end of mess
+ \fi
\box\columnpagebox
\egroup}
@@ -1038,7 +1054,7 @@
\dohandleallcolumns
{\global\ht\currentcolumnbox\dimen0}%
\fi
- \setbox\precolumnbox\vbox{\flushcolumnedpage}%
+ \setbox\precolumnbox\vbox{\flushcolumnedpage\zerocount}%
\finaloutput\box\precolumnbox
\sethsize
\setvsize
@@ -1202,7 +1218,7 @@
\fi
\global\output{\balancingerror}%
\b@selinebottomtrue % forces depth in separation rule
- \flushcolumnedpage
+ \flushcolumnedpage\plusone
\multicolumnseject
\egroup}
@@ -1688,7 +1704,7 @@
{\testrulewidth\zeropoint\ruledvskip\textheight} % we misuse a
\penalty-200 % side effect
\vskip-\textheight
- \prevdepth-\thousandpoint} % signals top of column to \blank
+ }% bugged : \prevdepth-\thousandpoint} % signals top of column to \blank
\setupcolumns
[\c!n=2,
diff --git a/tex/context/base/page-num.tex b/tex/context/base/page-num.tex
index e452b55aa..a684eb7ef 100644
--- a/tex/context/base/page-num.tex
+++ b/tex/context/base/page-num.tex
@@ -343,7 +343,7 @@
% so far
\def\checkpagecounter
- {\checknummer{\s!page}}
+ {\checknumber[\s!page]}
% \getpagestatus
% \ifrightpage als odd/enkelzijdig
diff --git a/tex/context/base/page-set.tex b/tex/context/base/page-set.tex
index 5e295b82d..1c31f6a10 100644
--- a/tex/context/base/page-set.tex
+++ b/tex/context/base/page-set.tex
@@ -1799,6 +1799,31 @@
\bgroup
\fi}
+% \setuplayout[grid=yes] \definecolumnset[example] \showgrid
+
+% \starttext
+% \startcolumnset[example]
+% \input knuth \endgraf \input knuth
+% \placetable{table}{\framed[width=\makeupwidth,height=4cm]{Hello}}
+% \input knuth \endgraf \input knuth
+% \stopcolumnset
+% \input knuth \endgraf \input knuth
+% \stoptext
+
+
+\def\OTRSETflushleftovers % new per 13/4/2006
+ {\OTRSETdoifcellelse{1}{1}
+ {\bgroup
+ \OTRSETcentergridcells
+ \chardef\OTRSETbalancemethod\plusone
+ \OTRSETreducegridbox
+ \global\setbox\OTRfinalpagebox\OTRSETmakegridbox
+ \global\ht\OTRfinalpagebox\textheight % signals output that there is content
+ \OTRSETdofinaloutput
+ \globallet\OTRSETbalht\zeropoint
+ \egroup}
+ {}}
+
\def\stopcolumnset
{\relax
\ifnum\columnsetlevel=\plusone
@@ -1820,6 +1845,7 @@
\fi
\global\chardef\OTRSETfinish\zerocount
\ifsomefloatwaiting \setvsize \pagebreak \setvsize \fi
+ \OTRSETflushleftovers
\else
\egroup
\fi
diff --git a/tex/context/base/spec-dpx.tex b/tex/context/base/spec-dpx.tex
index 3c0d45897..31bcb39ff 100644
--- a/tex/context/base/spec-dpx.tex
+++ b/tex/context/base/spec-dpx.tex
@@ -816,6 +816,10 @@
%D 7. Copied codes from \type{spec-dvi}
+% coming pdftex versions will provide pos support
+
+% \ifnum\pdftexversion>140 .. \fi
+
\definespecial\dosetposition#1%
{\special{pos:pxy "#1"}}
@@ -830,7 +834,7 @@
\definespecial\dosetpositionpapersize#1#2%
{\xdef\flushDVIpositionpapersize%
{\special{pos:papersize #1 #2}%
- \noexpand\installprogram{dvipos \jobname}%
+ \noexpand\installprogram{dvipos -o \jobname.tuo \jobname.dvi }%
\global\noexpand\let\noexpand\flushDVIpositionpapersize\relax}}
\prependtoksonce \flushDVIpositionpapersize \to \everyshipout
diff --git a/tex/context/base/spec-dvi.tex b/tex/context/base/spec-dvi.tex
index 5da86743c..b84d3c3b7 100644
--- a/tex/context/base/spec-dvi.tex
+++ b/tex/context/base/spec-dvi.tex
@@ -106,7 +106,7 @@
%
% \appendtoksonce
% \ifspecialbasedsettings
-% \ifpositioning\installprogram{dvipos \jobname}\fi
+% \ifpositioning\installprogram{dvipos -o \jobname.tuo \jobname.dvi}\fi
% \fi
% \to \everystoptext
%
@@ -115,7 +115,7 @@
\definespecial\dosetpositionpapersize#1#2%
{\xdef\flushDVIpositionpapersize%
{\special{pos:papersize #1 #2}%
- \noexpand\installprogram{dvipos \jobname}%
+ \noexpand\installprogram{dvipos -o \jobname.tuo \jobname.dvi }%
\global\noexpand\let\noexpand\flushDVIpositionpapersize\relax}}
\prependtoksonce \flushDVIpositionpapersize \to \everyshipout
diff --git a/tex/context/base/supp-box.tex b/tex/context/base/supp-box.tex
index 0afe4e13b..76c71c199 100644
--- a/tex/context/base/supp-box.tex
+++ b/tex/context/base/supp-box.tex
@@ -453,10 +453,13 @@
{\beginofshapebox
\unvbox\nextbox
\endofshapebox
- \global\count1\zerocount
- \reshapebox{\global\advance\count1\plusone}%
- \egroup\noflines\count1 }%
- \vbox}
+ % \global\count1\zerocount
+ % \reshapebox{\global\advance\count1\plusone}%
+ % \egroup\noflines\count1 }%
+ \scratchcounter\zerocount
+ \reshapebox{\global\advance\scratchcounter\plusone}%
+ \expandafter\egroup\expandafter\noflines\the\scratchcounter\relax
+ }\vbox}
%D \macros
%D {doiftextelse, doiftext}
@@ -1802,7 +1805,7 @@
%D
%D \normalvbox
%D \bgroup
-%D \converthboxtovbox
+%D \convertvboxtohbox
%D \egroup
%D \stoptyping
%D
@@ -1878,6 +1881,26 @@
\setbox0\normalhbox{\box2\unhbox0}%
\repeat}
+% \def\makehboxofhboxes
+% {\setbox0\normalhbox{}%
+% \doloop % \doloop { .. \exitloop .. }
+% {% \dorecurse{3}{\unskip\unpenalty}% get rid of ... (better do this in a shapeloop)
+% \setbox2\lastbox
+% \ifhbox2
+% \setbox0\normalhbox{\box2\unhbox0}%
+% \else
+% \exitloop
+% \fi}}
+
+% \def\flushboxesonly % feed this into \makehboxofhboxes
+% {\dowithnextbox
+% {\beginofshapebox
+% \unvbox\nextbox
+% \endofshapebox
+% \doreshapebox{\box\shapebox}{}{}{}% get rid of penalties etc
+% \innerflushshapebox}
+% \vbox}
+
\def\removehboxes
{\setbox0\lastbox
\ifhbox0
diff --git a/tex/context/base/unic-ini.tex b/tex/context/base/unic-ini.tex
index cafd435c6..361ff00a9 100644
--- a/tex/context/base/unic-ini.tex
+++ b/tex/context/base/unic-ini.tex
@@ -743,7 +743,7 @@
%D Well, let's at least preload a few familiar ones. Here we
%D also load the \UTF\ regime.
-\useunicodevector[0,1,2,3,4,5,30,32,33,34,37,39]
+\useunicodevector[0,1,2,3,4,5,30,32,33,34,37,39,251]
\useunicodevector[cjk]
\useregime[utf]
diff --git a/tex/context/base/verb-c.tex b/tex/context/base/verb-c.tex
new file mode 100644
index 000000000..a7a041c7e
--- /dev/null
+++ b/tex/context/base/verb-c.tex
@@ -0,0 +1,483 @@
+%D \module
+%D [ file=verb-c,
+%D version=2006.04.17,
+%D title=\CONTEXT\ Verbatim Macros,
+%D subtitle=Pretty C Verbatim,
+%D author=Nikolai Weibull,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+\writestatus{loading}{Context Support Macros / Pretty C Verbatim}
+
+% HH:
+%
+% - extra !!pretty definitions moved to verb-ini
+% - added a c!
+% - did a few small cosmetic things
+
+\unprotect
+
+\doglobal\newif\ifinCsingle
+\doglobal\newif\ifinCdouble
+\doglobal\newif\ifinCcomment
+\doglobal\newif\ifinCsinglelinecomment
+\doglobal\newif\ifinCmultilinecomment
+\doglobal\newif\ifcontinueCsinglelinecomment
+
+\gdef\Csetcontrols
+ {\saveprettycontrols
+ \def\obeyedspace
+ {\endCtypesix
+ \oldobeyedspace}%
+ \def\flushrestofverbatimline
+ {\endCtypesix
+ \ifinCsinglelinecomment
+ \ifcontinueCsinglelinecomment
+ \continueCsinglelinecommentfalse
+ \else
+ \egroup
+ \endofpretty
+ \global\inCsinglelinecommentfalse
+ \global\inCcommentfalse
+ \fi
+ \fi}%
+ \def\obeyedline
+ {\oldobeyedline}%
+ \let\obeytabs\ignoretabs}
+
+\gdef\setupprettyCtype
+ {\def\prettyidentifier{C}%
+ \Csetvariables
+ \Csetcontrols
+ \Csethandlers
+ \Csetspecials
+ \Csetdiagnostics}
+
+\gdef\Csetvariables
+ {\global\inCsinglefalse
+ \global\inCdoublefalse
+ \global\inCcommentfalse
+ \global\continueCsinglelinecommentfalse
+ \global\naturaltextexttrue
+ \global\let\Csequence\empty
+ \global\let\Cprefix\empty}
+
+% TODO: should handle -> as well
+
+\gdef\Csetspecials
+ {\setpretty`\{=10 \setpretty`\}=10
+ \setpretty`\$=20 \setpretty`\@=20
+ \setpretty`\[=30 \setpretty`\]=30 \setpretty`\(=30 \setpretty`\)=30
+ \setpretty`\==30 \setpretty`\~=30 \setpretty`\<=30 \setpretty`\>=30
+ \setpretty`\%=30
+ \setpretty`\-=41 \setpretty`\+=41
+ \setpretty`\|=41 \setpretty`\`=41 \setpretty`\!=41 \setpretty`\?=41
+ \setpretty`\^=41 \setpretty`\&=41
+ \setpretty`\/=43 \setpretty`\*=44
+ \setpretty`\#=45
+ \setpretty`\\=50
+ \setpretty`\1=61 \setpretty`\2=61 \setpretty`\3=61 \setpretty`\4=61 \setpretty`\5=61
+ \setpretty`\6=61 \setpretty`\7=61 \setpretty`\8=61 \setpretty`\9=61 \setpretty`\0=61
+ \setpretty`\A=62 \setpretty`\B=62 \setpretty`\C=62 \setpretty`\D=62 \setpretty`\E=62
+ \setpretty`\F=62 \setpretty`\G=62 \setpretty`\H=62 \setpretty`\I=62 \setpretty`\J=62
+ \setpretty`\K=62 \setpretty`\L=62 \setpretty`\M=62 \setpretty`\N=62 \setpretty`\O=62
+ \setpretty`\P=62 \setpretty`\Q=62 \setpretty`\R=62 \setpretty`\S=62 \setpretty`\T=62
+ \setpretty`\U=62 \setpretty`\V=62 \setpretty`\W=62 \setpretty`\X=62 \setpretty`\Y=62
+ \setpretty`\Z=62
+ \setpretty`\a=62 \setpretty`\b=62 \setpretty`\c=62 \setpretty`\d=62 \setpretty`\e=62
+ \setpretty`\f=62 \setpretty`\g=62 \setpretty`\h=62 \setpretty`\i=62 \setpretty`\j=62
+ \setpretty`\k=62 \setpretty`\l=62 \setpretty`\m=62 \setpretty`\n=62 \setpretty`\o=62
+ \setpretty`\p=62 \setpretty`\q=62 \setpretty`\r=62 \setpretty`\s=62 \setpretty`\t=62
+ \setpretty`\u=62 \setpretty`\v=62 \setpretty`\w=62 \setpretty`\x=62 \setpretty`\y=62
+ \setpretty`\z=62
+ \setpretty`\_=62
+ \setpretty`\;=70 \setpretty`\:=70 \setpretty`\,=70 \setpretty`\.=70
+ \setpretty`\'=80
+ \setpretty`\"=90 }
+
+\gdef\Csethandlers
+ {\installprettyhandler 10 \Ctypeone
+ \installprettyhandler 20 \Ctypetwo
+ \installprettyhandler 30 \Ctypethree
+ \installprettyhandler 41 \Ctypefourone
+ \installprettyhandler 43 \Ctypefourthree
+ \installprettyhandler 44 \Ctypefourfour
+ \installprettyhandler 45 \Ctypefourfive
+ \installprettyhandler 50 \Ctypefive
+ \installprettyhandler 61 \Ctypesixone
+ \installprettyhandler 62 \Ctypesixtwo
+ \installprettyhandler 70 \Ctypeseven
+ \installprettyhandler 80 \Ctypeeight
+ \installprettyhandler 90 \Ctypenine}
+
+\gdef\Ctypeone#1%
+ {\ifinCdouble
+ \ifinCcomment
+ \endCtypesix
+ \getpretty{#1}%
+ \else\ifx\Cprefix\empty
+ \endCtypesix
+ \getpretty{#1}%
+ \else
+ \endCtypesix
+ \xdef\Cprefix{\getpretty{#1}}%
+ \beginofpretty[\!!prettyone]\getpretty{#1}\endofpretty
+ \fi\fi
+ \else
+ \endCtypesix
+ \ifinCcomment
+ \getpretty{#1}%
+ \else\ifinCsingle
+ \getpretty{#1}%
+ \else
+ \beginofpretty[\!!prettyone]\getpretty{#1}\endofpretty
+ \fi\fi
+ \fi}
+
+\gdef\Ctypetwo#1%
+ {\endCtypesix
+ \getpretty{#1}}
+
+\gdef\Ctypethree#1%
+ {\endCtypesix
+ \ifinCcomment
+ \getpretty{#1}%
+ \else\ifinCsingle
+ \getpretty{#1}%
+ \else\ifinCdouble
+ \getprettydata{#1}%
+ \ifx\Cprefix\empty
+ \getpretty{#1}%
+ \else
+ \beginofpretty[\!!prettythree]\getpretty{#1}\endofpretty
+ \fi
+ \else
+ \beginofpretty[\!!prettythree]\getpretty{#1}\endofpretty
+ \fi\fi\fi}
+
+\gdef\Ctypefourone#1%
+ {\endCtypesix
+ \ifinCcomment
+ \getpretty{#1}%
+ \else\ifinCsingle
+ \getpretty{#1}%
+ \else\ifinCdouble
+ \getpretty{#1}%
+ \else
+ \beginofpretty[\!!prettyfour]\getpretty{#1}\endofpretty
+ \fi\fi\fi}
+
+\gdef\doCtypefourtwo#1#2%
+ {\getprettydata{#2}%
+ \ifnum\prettytype=62
+ \expandafter\Ctypetwo
+ \else
+ \expandafter\Ctypefourone
+ \fi
+ {#1}#2}
+
+\gdef\Ctypefourtwo
+ {\handlenextnextpretty\doCtypefourtwo\Ctypefourone}
+
+\gdef\Ctypefourthree
+ {\handlenextnextpretty\doCtypefourthree\Ctypefourtwo}
+
+\gdef\doCtypefourthree#1#2%
+ {\getprettydata{#2}%
+ \ifnum\prettytype=43
+ \let\next\dodoCtypefourthree
+ \else\ifnum\prettytype=44
+ \global\inCcommenttrue
+ \global\inCmultilinecommenttrue
+ \let\next\Cstartcomment
+ \else
+ \let\next\Ctypefourtwo
+ \fi\fi
+ \next{#1}#2}
+
+\gdef\Cstartcomment#1#2%
+ {\beginofpretty[\!!prettyfourthree]\bgroup\ttsl\getpretties{#1}{#2}}
+
+\gdef\dodoCtypefourthree% #1%
+ {\endCtypesix
+ \handlenextnextpretty\dododoCtypefourthree\dodododoCtypefourthree}
+
+\gdef\dododoCtypefourthree
+ {\ifnewpretty\expandafter\handlenewpretty\fi\dodododoCtypefourthree}
+
+\gdef\dodododoCtypefourthree#1#2%
+ {\ifinCcomment
+ \getpretties{#1}{#2}%
+ \else
+ \global\inCcommenttrue
+ \global\inCsinglelinecommenttrue
+ \def\next{\beginofpretty[\!!prettyfourthree]\bgroup\ttsl\getpretties{#1}{#2}}%
+ \expandafter\next
+ \fi}
+
+\gdef\Ctypefourfour
+ {\handlenextnextpretty\doCtypefourfour\Ctypefourtwo}
+
+\gdef\doCtypefourfour#1#2%
+ {\getprettydata{#2}%
+ \ifnum\prettytype=44
+ % \beginofpretty[\!!prettyfour]\getpretty{#1}\endofpretty
+ \ifinCcomment
+ \getpretty{#1}%
+ \else
+ \endCtypesix
+ \beginofpretty[\!!prettyfour]\getpretty{#1}\endofpretty
+ \fi
+ \expandafter#2%
+ \else\ifnum\prettytype=43
+ \getpretties{#1}{#2}%
+ \egroup
+ \endofpretty
+ \global\inCcommentfalse
+ \global\inCmultilinecommentfalse
+ \else\ifinCcomment
+ \getpretty{#1}%
+ \expandafter#2%
+ \else\ifinCsingle
+ \getpretty{#1}%
+ \expandafter#2%
+ \else\ifinCdouble
+ \getpretty{#1}%
+ \expandafter#2%
+ \else
+ \endCtypesix
+ \beginofpretty[\!!prettyfour]\getpretty{#1}\endofpretty
+ \expandafter#2%
+ \fi\fi\fi\fi\fi}
+
+\gdef\Ctypefourfive#1%
+ {\ifinCcomment
+ \getpretty{#1}%
+ \else\ifinCsingle
+ \getpretty{#1}%
+ \else\ifinCdouble
+ \getpretty{#1}%
+ \else
+ \endCtypesix
+ \global\inCcommenttrue
+ \global\inCsinglelinecommenttrue
+ \def\next{\beginofpretty[\!!prettyfourthree]\bgroup\ttsl\getpretty{#1}}%
+ \expandafter\next
+ \fi\fi\fi}
+
+\gdef\doCtypefiveA#1#2%
+ {\endCtypesix
+ \ifinCcomment
+ \getpretties{#1}{#2}%
+ \else\ifinCsingle
+ \getprettydata{#2}%
+ \ifnum\prettytype=50
+ \beginofpretty[\!!prettyfive]\getpretties{#1}{#2}\endofpretty\beginofpretty[\!!prettyeight]%
+ \else\ifnum\prettytype=80
+ \beginofpretty[\!!prettyfive]\getpretties{#1}{#2}\endofpretty\beginofpretty[\!!prettyeight]%
+ \else
+ \getpretties{#1}{#2}%
+ \fi\fi
+ \else\ifinCdouble
+ \beginofpretty[\!!prettyfive]\getpretties{#1}{#2}\endofpretty\beginofpretty[\!!prettynine]%
+ \else
+ \beginofpretty[\!!prettyfive]\getpretties{#1}{#2}\endofpretty
+ \fi\fi\fi}
+
+\gdef\doCtypefiveB#1%
+ {\endCtypesix
+ \ifinCcomment
+ \ifcat#1\relax
+ \continueCsinglelinecommenttrue
+ \getpretty{#1}%
+ \else
+ \getpretty{#1}%
+ \fi
+ \else\ifinCsingle
+ \getpretty{#1}%
+ \else\ifinCdouble
+ \beginofpretty[\!!prettyfive]\getpretty{#1}\endofpretty\beginofpretty[\!!prettynine]%
+ \else
+ \beginofpretty[\!!prettyfive]\getpretty{#1}\endofpretty
+ \fi\fi\fi}
+
+\gdef\Ctypefive
+ {\expandafter\handlenextnextpretty\expandafter\doCtypefiveA\expandafter\doCtypefiveB}
+
+\gdef\endCtypesix
+ {\ifx\Csequence\empty\else
+ \ifinCcomment
+ \Csequence
+ \else\ifinCsingle
+ \Csequence
+ \else\ifinCdouble
+ \Csequence
+ \else\ifx\Cprefix\empty
+ \doendCtypesix\!!prettytwo
+ \else
+ \doendCtypesixtype\!!prettytwo
+ \fi\fi\fi\fi
+ \global\let\Csequence\empty
+ \global\let\Cprefix\empty
+ \fi}
+
+\gdef\doendCtypesix#1%
+ {\doifprettyidentifierelse{\Csequence}{\Ckeywords}
+ {\beginofpretty[#1]%
+ {\prettyidentifierfont\Csequence}%
+ \endofpretty}
+ {\doifprettyidentifierelse{\Csequence}{\Ctypes}
+ {\beginofpretty[\!!prettytwoone]%
+ {\prettyvariablefont\Csequence}%
+ \endofpretty}
+ {\Csequence}}}
+
+\gdef\doendCtypesixtype#1%
+ {\doifprettyidentifierelse{\Cprefix\Csequence}{\Ctypes}
+ {\beginofpretty[#1]%
+ {\prettyvariablefont\Csequence}%
+ \endofpretty}
+ {\Csequence}}
+
+\gdef\Ctypesixone#1%
+ {\ifinCcomment
+ \def\next{\getpretty{#1}}%
+ \else\ifinCsingle
+ \def\next{\getpretty{#1}}%
+ \else\ifinCdouble
+ \def\next{\getpretty{#1}}%
+ \else\ifx\Csequence\empty
+ \def\next{\beginofpretty[\!!prettyeight]\getpretty{#1}\endofpretty}%
+ \else
+ \def\next{\Ctypesixtwo{#1}}%
+ \fi\fi\fi\fi
+ \expandafter\next}
+
+\gdef\Ctypesixtwo#1%
+ {\ifinCcomment
+ \getpretty{#1}%
+ \else\ifinCsingle
+ \getpretty{#1}%
+ \else\ifinCdouble
+ \ifx\Cprefix\empty
+ \getpretty{#1}%
+ \else
+ \xdef\Csequence{\Csequence\getpretty{#1}}%
+ \fi
+ \else
+ \xdef\Csequence{\Csequence\getpretty{#1}}%
+ \fi\fi\fi}
+
+\gdef\Ctypeseven#1%
+ {\endCtypesix
+ \getpretty{#1}}
+
+\gdef\Ctypeeight#1% single quote
+ {\endCtypesix
+ \ifinCcomment
+ \getpretty{#1}%
+ \else\ifinCdouble
+ \getpretty{#1}%
+ \else\ifinCsingle
+ \global\inCsinglefalse
+ \getpretty{#1}%
+ \endofpretty
+ \else
+ \global\inCsingletrue
+ \beginofpretty[\!!prettyeight]\getpretty{#1}
+ \fi\fi\fi}
+
+\gdef\Ctypenine#1% double quote
+ {\endCtypesix
+ \ifinCcomment
+ \getpretty{#1}%
+ \else\ifinCsingle
+ \getpretty{#1}%
+ \else\ifinCdouble
+ \global\inCdoublefalse
+ \getpretty{#1}%
+ \endofpretty
+ \else
+ \global\inCdoubletrue
+ \beginofpretty[\!!prettynine]\getpretty{#1}
+ \fi\fi\fi}
+
+\gdef\doreportprettyCtype#1#2#3#4%
+ {#1%
+ [C \string#2 typing conflict, use \string#3 instead]
+ \writestatus
+ {C typing}
+ {use \string#3 instead of \string#2 to enable propper visualization}%
+ \global#4%
+ \expandafter\doemptyverbatimline
+ \fi}
+
+\gdef\reportprettyCtype
+ {\doreportprettyCtype\ifinCsingle'\'\inCsinglefalse
+ \doreportprettyCtype\ifinCdouble"\"\inCdoublefalse}
+
+\gdef\Csetdiagnostics
+ {\let\normaldoemptyverbatimline\doemptyverbatimline
+ \def\doemptyverbatimline
+ {\normaldoemptyverbatimline
+ \reportprettyCtype}}
+
+\useprettyidentifiers \Ckeywords \Csetspecials
+ break case continue default do else for goto if return sizeof switch while
+
+\useprettyidentifiers \Ctypes \Csetspecials
+ auto char const double enum extern float int long register restrict short
+ signed static struct typedef union unsigned void volatile bool
+
+\installprettytype [C] [C]
+
+\definetyping[C][\c!option=C]
+
+\definecolor [colorprettyone] [black]
+\definecolor [colorprettytwo] [r=.46, g=.38, b=.13]
+\definecolor [colorprettytwoone] [r=.38, g=.18, b=.5]
+\definecolor [colorprettythree] [black]
+\definecolor [colorprettyfour] [black]
+\definecolor [colorprettyfourthree] [r=.15, g=.45, r=.15]
+\definecolor [colorprettyfive] [r=.94, g=.15, b=.15]
+\definecolor [colorprettyeight] [r=.58, g=.09, b=.09]
+\definecolor [colorprettynine] [r=.58, g=.09, b=.09]
+
+\definecolor [grayprettyone] [s=.30]
+\definecolor [grayprettytwo] [s=.45]
+\definecolor [grayprettythree] [s=.60]
+\definecolor [grayprettyfour] [s=.75]
+\definecolor [grayprettyfourthree] [s=.70]
+
+\definepalet
+ [colorpretty]
+ [ prettyone=colorprettyone,
+ prettytwo=colorprettytwo,
+ prettytwoone=colorprettytwoone,
+ prettythree=colorprettythree,
+ prettyfour=colorprettyfour,
+ prettyfourthree=colorprettyfourthree,
+ prettyfive=colorprettyfive,
+ prettyeight=colorprettyeight,
+ prettynine=colorprettynine]
+
+\definepalet
+ [graypretty]
+ [ prettyone=grayprettyone,
+ prettytwo=grayprettytwo,
+ prettythree=grayprettythree,
+ prettyfour=grayprettyfour,
+ prettyfourthree=grayprettyfourthree]
+
+\definepalet [Ccolorpretty] [colorpretty]
+\definepalet [Cgraypretty] [graypretty]
+
+\setuptyping
+ [C]
+ [\c!icommand=\tttf]
+
+\protect \endinput
diff --git a/tex/context/base/verb-ini.tex b/tex/context/base/verb-ini.tex
index 63f924887..43b563a80 100644
--- a/tex/context/base/verb-ini.tex
+++ b/tex/context/base/verb-ini.tex
@@ -1145,12 +1145,17 @@
%D Just to keep things consistant and to speed up some macros a
%D but, we define a few private constants.
-\def\!!PRETTY {PRETTY}
-
-\def\!!prettyone {prettyone}
-\def\!!prettytwo {prettytwo}
-\def\!!prettythree {prettythree}
-\def\!!prettyfour {prettyfour}
+\def\!!PRETTY {PRETTY}
+
+\def\!!prettyone {prettyone}
+\def\!!prettytwo {prettytwo}
+\def\!!prettythree {prettythree}
+\def\!!prettyfour {prettyfour}
+\def\!!prettyfive {prettyfive}
+\def\!!prettynine {prettynine}
+\def\!!prettyeight {prettyeight}
+\def\!!prettytwoone {prettytwoone}
+\def\!!prettyfourthree {prettyfourthree}
%D The first step in defining a pretty interpreter is to assign
%D each character that needs special attention a number, like:
diff --git a/tex/context/base/x-fig-01.tex b/tex/context/base/x-fig-01.tex
index 5d6c0fa3f..e74cfc483 100644
--- a/tex/context/base/x-fig-01.tex
+++ b/tex/context/base/x-fig-01.tex
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-% \readfile {x-res-01} \donothing \donothing \endinput
+% \readfile {x-res-01} \donothing \donothing \endinput
%D See \type {x-fig-00.tex} for more information on how to use
%D and generate figure databases. This file loads the file
@@ -58,6 +58,9 @@
\doifnothing {\jobfilename} {\end}
\doiffileelse {\jobfilename.xml} {} {\end}
+\definesymbol [attachment] [{\bf\color[darkred]{\jobname.xml}}]
+\setupattachments [symbol=attachment]
+\useattachment [datafile] [\jobname.xml]
\def\StartDescription
{\bgroup
@@ -77,6 +80,7 @@
{\NC product \NC \XMLpop{product} \NC \NR}{}
\doifXMLdataelse{comment}
{\NC comment \NC \XMLpop{comment} \NC \NR}{}
+ \NC specification \NC \attachment[datafile] \NC \NR
\stoptabulate
\blank[2*big]
\egroup}
@@ -335,7 +339,7 @@
\def\StartLibrary{\mainlanguage[\XMLpar{figurelibrary}{language}{en}]}
\def\StopLibrary {}
-\defineXMLignore [description]
+\defineXMLignore [description]
\defineXMLenvironment [figure] \StartFigureC \StopFigureC
\doglobal\newcounter\CurrentPage
diff --git a/tex/context/base/x-newcml.tex b/tex/context/base/x-newcml.tex
index 1c2b8f53e..b1928cce9 100644
--- a/tex/context/base/x-newcml.tex
+++ b/tex/context/base/x-newcml.tex
@@ -136,11 +136,11 @@
\removeunwantedspaces
\begingroup
\startsavingXMLelements
-\ignorespaces
+ \ignorespaces
\stopsetups
\startsetups cml:molecule:stop
-\removeunwantedspaces
+ \removeunwantedspaces
\stopsavingXMLelements
\resetCMLcaption
\XMLfirstnamed{caption}
@@ -324,7 +324,7 @@
\ifx\startchemical\undefined
\def\startchemical {\hbox{module chemic is not loaded}}
- \let\stopchemical {}
+ \let\stopchemical \relax
\def\chemical[#1][#2]{}
\fi
diff --git a/tex/context/base/x-newmml.tex b/tex/context/base/x-newmml.tex
index 5bc4c324a..54e5940ca 100644
--- a/tex/context/base/x-newmml.tex
+++ b/tex/context/base/x-newmml.tex
@@ -621,10 +621,25 @@
\endgroup
\stopsetups
-\mapXMLvalue {mmc:int} {closed} {\left[\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right]}
-\mapXMLvalue {mmc:int} {open-closed} {\left(\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right]}
-\mapXMLvalue {mmc:int} {closed-open} {\left[\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right)}
-\mapXMLvalue {mmc:int} {open} {\left(\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right)}
+\setupMMLappearance[interval][\c!alternative=\v!a]
+
+\mapXMLvalue {mmc:int} {closed}
+ {\left[\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right]}
+
+\mapXMLvalue {mmc:int} {open-closed}
+ {\doifelse\@@MMLintervalalternative\v!b
+ {\left<\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right]}
+ {\left(\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right]}}
+
+\mapXMLvalue {mmc:int} {closed-open}
+ {\doifelse\@@MMLintervalalternative\v!b
+ {\left[\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right>}
+ {\left[\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right)}}
+
+\mapXMLvalue {mmc:int} {open}
+ {\doifelse\@@MMLintervalalternative\v!b
+ {\left<\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right>}
+ {\left(\getXMLstackdata\plusone,\getXMLstackdata\plustwo\right)}}
% inverse
@@ -1176,54 +1191,63 @@
}
\stopsetups
-\setupMMLappearance[diff][\c!location=\v!top]
+\setupMMLappearance[diff][\c!location=\v!top,\c!alternative=\v!a]
\defineXMLcommand [diff] {\directsetup{mmc:diff}}
\defineXMLcommand [partialdiff] {\directsetup{mmc:partialdiff}}
+% \setupMMLappearance[diff][alternative=b]
+%
+% \startXMLdata
+% <math><apply><apply><diff/><bvar><ci>x</ci></bvar><ci>f</ci></apply><ci>a</ci></apply></math>
+% <math><apply><apply><diff/><bvar><ci>x</ci></bvar><degree>2</degree><ci>f</ci></apply><ci>a</ci></apply></math>
+% \stopXMLdata
+
\startsetups mmc:diff
\MMLcreset
- \XMLdoifonstackelse{bvar} {
- \frac {
- \XMLdoifonstackelse{degree} {
- \collectXMLnamedstack{degree}\empty
- } {
- \collectXMLnamedstacknamed{bvar}{degree}+
- }
-% \begingroup
-% \MMLrm\getXMLentity{mathematicald}
-% \endgroup
- \mfunction{\getXMLentity{mathematicald}}
- ^{\the\XMLRtoks}
- \doif\@@MMLdifflocation\v!top {
- \XMLdoifonstackelse{ci} {
- \XMLfirstnamed{ci}
+ \doifelse\@@MMLdiffalternative\v!a {
+ \XMLdoifonstackelse{bvar} {
+ \frac {
+ \XMLdoifonstackelse{degree} {
+ \collectXMLnamedstack{degree}\empty
} {
-% \doifelseMMCfunction {
+ \collectXMLnamedstacknamed{bvar}{degree}+
+ }
+ \mfunction{\getXMLentity{mathematicald}}
+ ^{\the\XMLRtoks}
+ \doif\@@MMLdifflocation\v!top {
+ \XMLdoifonstackelse{ci} {
+ \XMLfirstnamed{ci}
+ } {
\MMLcreset\XMLfirstnamed{apply}
-% } {
-% \left(\MMLcreset\XMLfirstnamed{apply}\right)
-% }
+ }
}
+ } {
+ \mfunction{\getXMLentity{mathematicald}}
+ \begingroup
+ \defineXMLsave[degree]
+ \XMLfirstnamed{bvar}
+ \doifXMLdata{degree} {
+ ^{\XMLflush{degree}}
+ }
+ \endgroup
+ }
+ \doifnot\@@MMLdifflocation\v!top {
+ \left(\MMLcreset\XMLfirstnamed{apply,ci}\right)
}
} {
-% \begingroup
-% \MMLrm\getXMLentity{mathematicald}
-% \endgroup
- \mfunction{\getXMLentity{mathematicald}}
- \begingroup
- \defineXMLsave[degree]
- \XMLfirstnamed{bvar}
- \doifXMLdata{degree} {
- ^{\XMLflush{degree}}
- }
- \endgroup
- }
- \doifnot\@@MMLdifflocation\v!top {
- \left(\MMLcreset\XMLfirstnamed{apply,ci}\right)
+ \flushXMLstackfrom\plustwo^\prime
}
} {
- \flushXMLstackfrom\plustwo^\prime
+ \MMLcreset\XMLfirstnamed{apply,ci}
+ ^{
+ \XMLdoifonstackelse{degree} {
+ \defXMLfirstnamedtext\ascii{degree}
+ \dorecurse\ascii\prime
+ } {
+ \prime
+ }
+ }
}
\stopsetups
@@ -1607,7 +1631,7 @@
{\directsetup{mmc:annotation}}
\startsetups mmc:annotation
- \doif{\XMLpar{annotation}{encoding}{}}{TeX} {
+ \expanded{\doifinset{\XMLpar{annotation}{encoding}{}}{TeX,tex,TEX,ConTeXt,context,CONTEXT}} {
\XMLtexdata{annotation}
}
\stopsetups
diff --git a/tex/context/base/x-openmath.tex b/tex/context/base/x-openmath.tex
new file mode 100644
index 000000000..38474996e
--- /dev/null
+++ b/tex/context/base/x-openmath.tex
@@ -0,0 +1,4 @@
+% This module is yet empty. We assume a transformation using
+% x-openmath.xsl.
+
+\endinput
diff --git a/tex/context/base/x-res-01.tex b/tex/context/base/x-res-01.tex
index 82c1116de..e989d7090 100644
--- a/tex/context/base/x-res-01.tex
+++ b/tex/context/base/x-res-01.tex
@@ -24,8 +24,13 @@
%D The following modes are supported:
%D
%D \starttabulate[|lT|l|]
-%D \NC letter \NC map the preview on letter size \NC \NR
-%D \NC compact \NC use an alternative presentation \NC \NR
+%D \NC letter \NC map the preview on letter size \NC \NR
+%D \NC compact \NC use an alternative presentation \NC \NR
+%D \NC clipgrid-distance \NC add a copy with grid overlayed \NC \NR
+%D \NC clipgrid-steps \NC add a copy with grid overlayed \NC \NR
+%D \NC previewpage-A4 \NC show graphic relative to A4 \NC \NR
+%D \NC previewpage-letter \NC show graphic relative to letter \NC \NR
+%D \NC previewpage-S6 \NC show graphic relative to S6 \NC \NR
%D \stoptabulate
%D
%D The resulting file has the following characteristics:
@@ -60,6 +65,10 @@
\doifnothing {\jobfullname} {\end}
\doiffileelse {\jobfullname} {} {\end}
+\definesymbol [attachment] [{\bf\color[darkred]{\jobname.xml}}]
+\setupattachments [symbol=attachment]
+\useattachment [datafile] [\jobname.xml]
+
\def\StartDescription
{\bgroup}
@@ -74,15 +83,41 @@
{\NC product \NC \XMLflush{rl:product} \NC \NR}{}
\doifXMLdataelse{rl:comment}
{\NC comment \NC \XMLflush{rl:comment} \NC \NR}{}
+ \NC specification \NC \attachment[datafile] \NC \NR
\stoptabulate
\blank[2*big]
\egroup}
-\def\StartFigureA
- {\bgroup
- \XMLassign{rl:file}{unknown}}
-\defineoverlay[page][\overlaybutton{Description}]
+\def\localexternalfigurereplacement#1#2#3% hack, no reuse of dummies (yet), todo: pass objname
+ {\doifelsenothing{\XMLflush{rl:label}}
+ {\edef\FigureName{\XMLflush{rl:label}}}
+ {\edef\FigureName{\XMLflush{rl:file}}}%
+ \doifobjectfoundelse{rl}\FigureName
+ {}
+ {\setobject{rl}\FigureName\vbox{\normalexternalfigurereplacement{#1}{#2}{#3}}}%
+ \getobject{rl}\FigureName}
+
+\startmode[dummy]
+
+ \useMPlibrary[dum]
+
+ \def\StartFigureA
+ {\bgroup
+ \XMLassign{rl:file}{dummy}}
+
+ \let\normalexternalfigurereplacement\externalfigurereplacement
+ \let\externalfigurereplacement \localexternalfigurereplacement
+
+\stopmode
+
+\startnotmode[dummy]
+
+ \def\StartFigureA
+ {\bgroup
+ \XMLassign{rl:file}{unknown}}
+
+\stopnotmode
\startbuffer[unknown]
\framed
@@ -98,6 +133,8 @@
\useexternalfigure[unknown][unknown][type=buffer,object=no]
+\defineoverlay[page][\overlaybutton{Description}]
+
% \def\externalfigurereplacement#1#2#3%
% {\getbuffer[rl-unknown]}
@@ -105,9 +142,9 @@
{\doglobal\increment\CurrentPage
\setupbackgrounds[page][background=page]
\doifelsenothing{\XMLflush{rl:label}}
- {\expanded{\definereference[Description][about: \XMLflush{rl:file}]}%
+ {\expanded{\definereference[Description][about:\XMLflush{rl:file}]}%
\expanded{\pagereference[\XMLflush{rl:file}]}}
- {\expanded{\definereference[Description][about: \XMLflush{rl:label}]}%
+ {\expanded{\definereference[Description][about:\XMLflush{rl:label}]}%
\expanded{\pagereference[\XMLflush{rl:label}]}}
\pagefigure[\XMLflush{rl:file}]
\setupbackgrounds[page][background=]
@@ -153,7 +190,6 @@
\enablemode[previewpage-A4]
\stopnotmode
-%startbuffer[paper]
\startsetups[paper]
\startmode[previewpage-A4]
\framed
@@ -174,7 +210,6 @@
{\externalfigure[\XMLflush{rl:file}][reset=yes]}
\stopmode
\stopsetups
-%stopbuffer
\setupbuttons
[offset=10pt,
@@ -196,8 +231,8 @@
{\hbox to \hsize
{\forgetall \dontcomplain
\doifelsenothing{\XMLflush{rl:label}}
- {\expanded{\pagereference[about: \XMLflush{rl:file}]}}
- {\expanded{\pagereference[about: \XMLflush{rl:label}]}}%
+ {\expanded{\pagereference[about:\XMLflush{rl:file}]}}
+ {\expanded{\pagereference[about:\XMLflush{rl:label}]}}%
% moved here, because descriptions may be absent
\ifnum\CurrentPage=1 \pagereference[begin]\fi
%
@@ -238,7 +273,7 @@
[offset=overlay,
framecolor=darkred,
rulethickness=.5pt]
- {\scale[width=40pt]{\setups[paper]}}% {\disableXML\getbuffer[paper]}}%
+ {\scale[width=40pt]{\setups[paper]}}%
\startmode[compact]%
\vfill
\hbox to \hsize{\hss\strut\bf\CurrentPage\hss}%
@@ -432,9 +467,9 @@
\setupbackgrounds[page][background=page]
\startpagefigure[\XMLflush{rl:file}][offset=20pt]%
\doifelsenothing{\XMLflush{rl:label}}
- {\expanded{\definereference[Description][about: \XMLflush{rl:file}]}%
+ {\expanded{\definereference[Description][about:\XMLflush{rl:file}]}%
\expanded{\pagereference[grid:\XMLflush{rl:file}]}}
- {\expanded{\definereference[Description][about: \XMLflush{rl:label}]}%
+ {\expanded{\definereference[Description][about:\XMLflush{rl:label}]}%
\expanded{\pagereference[grid:\XMLflush{rl:label}]}}
\stoppagefigure
%\pagefigure[\XMLflush{rl:file}][offset=20pt]
diff --git a/tex/context/base/x-xml-11.tex b/tex/context/base/x-xml-11.tex
index bdacd97c2..81fbac5b4 100644
--- a/tex/context/base/x-xml-11.tex
+++ b/tex/context/base/x-xml-11.tex
@@ -14,8 +14,11 @@
% xmltools --analyze yourfile.xml
% texexec --use=xml-analyze yourfile.*
-\doifnothing {\inputfilename} {\end}
-\doiffileelse {\inputfilename} {} {\end}
+% \doifnothing {\inputfilename} {\end}
+% \doiffileelse {\inputfilename} {} {\end}
+
+\doifnothing {\jobfullname} {\end}
+\doiffileelse {\jobfullname} {} {\end}
\useXMLfilter[ent]
\useXMLfilter[utf]
@@ -30,6 +33,7 @@
[SomeElement]
[ownnumber=yes,
style=\tfb,
+ numberstyle=\tfxx,
alternative=margin]
\setuplayout
@@ -41,7 +45,7 @@
header=0pt]
\setupfootertexts
- [\inputfilename]
+ [\jobfullname] % [\inputfilename]
\usetypescript[modern][texnansi] \setupbodyfont[modern,tt,10pt]
@@ -51,8 +55,8 @@
{}
\defineXMLpickup
- [entities]
- {\page
+ [entities][n=0]
+ {\expanded{\SomeElement{\XMLop{n}}{Entities}}
\starttabulate[|l|p|]}
{\stoptabulate}
@@ -65,9 +69,34 @@
\noexpand \NR
\stopexpanded}
+\defineXMLpickup
+ [characters][n=0]
+ {\expanded{\SomeElement{\XMLop{n}}{Characters}}
+ \bgroup
+ \let\nonbreakablespace\empty % messes up the table
+ \starttabulate[|l|r|r|l|l|l|l|]}
+ {\stoptabulate
+ \egroup}
+
+% todo: narrowtt
+
+\defineXMLcommand
+ [character][number=,utf=,n=0,uname=,pname=,cname=]
+ {\startexpanded
+ \noexpand \NC \noexpand \unicodehexnumber{\XMLop{number}}
+ \noexpand \NC \XMLop{number}
+ \noexpand \NC \XMLop{n}
+ \noexpand \NC \noexpand \unicodechar {\XMLop{number}}
+ \noexpand \NC \tx \lowercase\expandafter{\XMLop{uname}}
+ \noexpand \NC \tx \noexpand \unicodepair {\XMLop{number}}
+ \noexpand \NC \tx \XMLop{cname}
+ \noexpand \NC
+ \noexpand \NR
+ \stopexpanded}
+
\defineXMLenvironment
[elements]
- {\page}
+ {}
{}
\newtoks \TabulateToks
@@ -98,6 +127,7 @@
\starttext
-\processXMLfilegrouped{\inputfilename}
+% \processXMLfilegrouped{\inputfilename}
+\processXMLfilegrouped{\jobfullname}
\stoptext
diff --git a/tex/context/base/xtag-mmc.tex b/tex/context/base/xtag-mmc.tex
index 803891164..d4ee14c59 100644
--- a/tex/context/base/xtag-mmc.tex
+++ b/tex/context/base/xtag-mmc.tex
@@ -537,8 +537,8 @@ complex-cartesian=>\let\next\MMLccartesian,
\doifelse\@@MMLtimesauto\v!no
{\let\@@MMLtimes@@symbol\@@MMLtimessymbol}
{\doifelseXMLRneighbors{cn}{#3}
- {\let\@@MMLtimes@@symbol\@@MMLtimesauto}
- {\let\@@MMLtimes@@symbol\v!no}}%
+ {\let\@@MMLtimes@@symbol\v!yes}
+ {\let\@@MMLtimes@@symbol\@@MMLtimessymbol}}%
\doifelse\@@MMLtimes@@symbol\v!yes
{\encapsulateXMLR{}{\times}{}{#3\empty}}
{\doifelse\@@MMLtimes@@symbol{dot}
diff --git a/tex/context/interface/cont-cz.xml b/tex/context/interface/cont-cz.xml
index d940b7a5c..821a9ff64 100644
--- a/tex/context/interface/cont-cz.xml
+++ b/tex/context/interface/cont-cz.xml
@@ -4431,7 +4431,7 @@
<cd:parameter name="cislovani">
<cd:constant type="ano"/>
<cd:constant type="nocheck"/>
- </cd:parameter>
+ </cd:parameter>
<cd:inherit name="nastavoramovani"/>
</cd:assignments>
</cd:arguments>
diff --git a/tex/context/interface/cont-de.xml b/tex/context/interface/cont-de.xml
index 9c57cd1ea..542c0fd24 100644
--- a/tex/context/interface/cont-de.xml
+++ b/tex/context/interface/cont-de.xml
@@ -4431,7 +4431,7 @@
<cd:parameter name="nummerierung">
<cd:constant type="ja"/>
<cd:constant type="nocheck"/>
- </cd:parameter>
+ </cd:parameter>
<cd:inherit name="stelleumrahmtein"/>
</cd:assignments>
</cd:arguments>
diff --git a/tex/context/interface/cont-en.xml b/tex/context/interface/cont-en.xml
index 08639e437..e67085c00 100644
--- a/tex/context/interface/cont-en.xml
+++ b/tex/context/interface/cont-en.xml
@@ -4431,7 +4431,7 @@
<cd:parameter name="numbering">
<cd:constant type="yes"/>
<cd:constant type="nocheck"/>
- </cd:parameter>
+ </cd:parameter>
<cd:inherit name="setupframed"/>
</cd:assignments>
</cd:arguments>
diff --git a/tex/context/interface/cont-fr.xml b/tex/context/interface/cont-fr.xml
index 5f552c701..0cfd795c1 100644
--- a/tex/context/interface/cont-fr.xml
+++ b/tex/context/interface/cont-fr.xml
@@ -4431,7 +4431,7 @@
<cd:parameter name="numerotation">
<cd:constant type="oui"/>
<cd:constant type="nonverifie"/>
- </cd:parameter>
+ </cd:parameter>
<cd:inherit name="regleencadre"/>
</cd:assignments>
</cd:arguments>
diff --git a/tex/context/interface/cont-it.xml b/tex/context/interface/cont-it.xml
index e62e5bb47..aa09da6bd 100644
--- a/tex/context/interface/cont-it.xml
+++ b/tex/context/interface/cont-it.xml
@@ -4431,7 +4431,7 @@
<cd:parameter name="numerazione">
<cd:constant type="si"/>
<cd:constant type="nocheck"/>
- </cd:parameter>
+ </cd:parameter>
<cd:inherit name="impostaincorniciato"/>
</cd:assignments>
</cd:arguments>
diff --git a/tex/context/interface/cont-nl.xml b/tex/context/interface/cont-nl.xml
index dc9d30d54..1734b2962 100644
--- a/tex/context/interface/cont-nl.xml
+++ b/tex/context/interface/cont-nl.xml
@@ -4431,7 +4431,7 @@
<cd:parameter name="nummeren">
<cd:constant type="ja"/>
<cd:constant type="geencontrole"/>
- </cd:parameter>
+ </cd:parameter>
<cd:inherit name="stelomlijndin"/>
</cd:assignments>
</cd:arguments>
diff --git a/tex/context/interface/cont-ro.xml b/tex/context/interface/cont-ro.xml
index 9a778a7b5..9ed76d25c 100644
--- a/tex/context/interface/cont-ro.xml
+++ b/tex/context/interface/cont-ro.xml
@@ -4431,7 +4431,7 @@
<cd:parameter name="numerotare">
<cd:constant type="da"/>
<cd:constant type="nocheck"/>
- </cd:parameter>
+ </cd:parameter>
<cd:inherit name="seteazainconjurat"/>
</cd:assignments>
</cd:arguments>
diff --git a/tex/context/interface/keys-cz.xml b/tex/context/interface/keys-cz.xml
index e96a0f735..e7cba225f 100644
--- a/tex/context/interface/keys-cz.xml
+++ b/tex/context/interface/keys-cz.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="cz" version="2006.04.10 20:04">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="cz" version="2006.04.22 10:41">
<cd:variables>
<cd:variable name="one" value="jedna"/>
diff --git a/tex/context/interface/keys-de.xml b/tex/context/interface/keys-de.xml
index a07f285e1..c8a1c07f2 100644
--- a/tex/context/interface/keys-de.xml
+++ b/tex/context/interface/keys-de.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="de" version="2006.04.10 20:04">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="de" version="2006.04.22 10:41">
<cd:variables>
<cd:variable name="one" value="eins"/>
diff --git a/tex/context/interface/keys-en.xml b/tex/context/interface/keys-en.xml
index eadd51069..6d2cd76dd 100644
--- a/tex/context/interface/keys-en.xml
+++ b/tex/context/interface/keys-en.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="en" version="2006.04.10 20:04">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="en" version="2006.04.22 10:41">
<cd:variables>
<cd:variable name="one" value="one"/>
diff --git a/tex/context/interface/keys-fr.xml b/tex/context/interface/keys-fr.xml
index 9cb988b7f..1a609efe4 100644
--- a/tex/context/interface/keys-fr.xml
+++ b/tex/context/interface/keys-fr.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="fr" version="2006.04.10 20:04">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="fr" version="2006.04.22 10:41">
<cd:variables>
<cd:variable name="one" value="un"/>
diff --git a/tex/context/interface/keys-it.xml b/tex/context/interface/keys-it.xml
index da2cb1a59..8b2dbe167 100644
--- a/tex/context/interface/keys-it.xml
+++ b/tex/context/interface/keys-it.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="it" version="2006.04.10 20:04">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="it" version="2006.04.22 10:41">
<cd:variables>
<cd:variable name="one" value="uno"/>
diff --git a/tex/context/interface/keys-nl.xml b/tex/context/interface/keys-nl.xml
index 871166538..5ecab0ff8 100644
--- a/tex/context/interface/keys-nl.xml
+++ b/tex/context/interface/keys-nl.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="nl" version="2006.04.10 20:04">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="nl" version="2006.04.22 10:41">
<cd:variables>
<cd:variable name="one" value="een"/>
diff --git a/tex/context/interface/keys-ro.xml b/tex/context/interface/keys-ro.xml
index 41066c585..b2e71bcd2 100644
--- a/tex/context/interface/keys-ro.xml
+++ b/tex/context/interface/keys-ro.xml
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="ro" version="2006.04.10 20:04">
+<cd:interface xmlns:cd="http://www.pragma-ade.com/commands" name="context" language="ro" version="2006.04.22 10:41">
<cd:variables>
<cd:variable name="one" value="unu"/>