summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/plain/pitex/pitex.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/plain/pitex/pitex.tex')
-rw-r--r--Master/texmf-dist/tex/plain/pitex/pitex.tex425
1 files changed, 132 insertions, 293 deletions
diff --git a/Master/texmf-dist/tex/plain/pitex/pitex.tex b/Master/texmf-dist/tex/plain/pitex/pitex.tex
index 5b62b8b5529..fcaa7f5132c 100644
--- a/Master/texmf-dist/tex/plain/pitex/pitex.tex
+++ b/Master/texmf-dist/tex/plain/pitex/pitex.tex
@@ -3,8 +3,10 @@
% archived on CTAN).
%
% Perhaps in the future, when this achieves some kind of
-% format-like completude, there'll be a documentation and
-% it'll be publicly announced.
+% format-like completude, it'll be publicly announced. In the
+% meanwhile, a documentation exists (pitex-doc.pdf, also readable
+% in a text editor as pitex-doc.txt).
+%
%
% You can of course use those macros, but you are on your
% own, and the files will probably be modified without announcement.
@@ -13,333 +15,168 @@
%
% The files needed are:
%
-% texapi.tex (an independent package \input in the following file)
-% yax.tex (an independent package)
-% fonts.ptx (piTeX font "management")
-% luaotfload.sty (an independent package (not by me))
-% sections.ptx (piTeX sectionning commands)
+% texapi.tex (an independent package for programming)
+% yax.tex (an independent package for key=value interface)
+% gates.tex and gates.lua (an independant package for overall architecture)
+% navigator.tex (an independant package for PDF features)
+% lua.ptx and base.ptxlua (Lua side)
+% files.ptx (file management)
+% fonts.ptx, fonts.ptxlua and foundry-settings.lua
+% (fonts, should be independant some day; actually
+% fonts.ptxlua can be used independantly, but there is
+% no doc)
+% sections.ptx (sectionning commands)
+% blocks.ptx (text blocks)
+% references.ptx (labels and references)
+% verbatim.ptx (typesetting verbatim)
+% inserts.ptx (footnotes and figures, a mess)
+% output.ptx (output routine)
+%
+% The file i-pitex.lua is needed only to typeset the documentation with the
+% Interpreter package.
%
-% Date: July 2010.
+%
+% Date: November 2011.
%
%
% User interface
\input yax % which itself \input's texapi
+\input gates
\setcatcodes{\@\_=11}
-\def\ptx@error{\senderror{PiTeX}}
+\suppressoutererror=1
-% This to write in latin1.
-\directlua{%
- lualog = function (message)
- texio.write_nl("") texio.write_nl("")
- texio.write_nl(message)
- texio.write_nl("") texio.write_nl("")
- end
- function convert(buf)
- return string.gsub(buf,"(.)", function (ch)
- return unicode.utf8.char(string.byte(ch))
- end)
- end
- callback.register('process_input_buffer',convert)
- }
+% MESSAGES
+\def\ptx@error{\senderror{PiTeX}}
+\def\ptx@log#1{%
+ \immediate\write17{^^J#1^^J}%
+ }
+\def\ptx@warn#1{%
+ \ptx@log{PiTeX warning: #1}%
+ }
+% ATTRIBUTES
\newcount\ptx@attribute_count
+\ptx@attribute_count=100 % The first 100 attributes are scratch.
\def\newattribute#1{%
\advance\ptx@attribute_count1
- \edefcs{ptx@attribute_#1}{10\the\ptx@attribute_count}%
+ \attributedef#1=\ptx@attribute_count
+ \xdefcs{ptx@attribute:\commandtoname#1}{\the\ptx@attribute_count}%
+ }
+\def\unsetattribute#1{#1=-"7FFFFFFF\relax}
+\def\attributenumber#1{\usecs{ptx@attribute:\commandtoname#1}}
+
+% FREEDEF
+\def\freedef#1{%
+ \def#1{%
+ \ifnextnospace"
+ {\ptx@freedef_quote#1}
+ {\ifnextnospace/
+ {\ptx@freedef_slash#1}
+ {\usecs{ptx@freedef_user:\commandtoname#1}}}%
+ }%
+ \defcs{ptx@freedef_user:\commandtoname#1}##1%
+ }
+\def\ptx@freedef_quote#1"#2"{%
+ \usecs{ptx@freedef_user:\commandtoname#1}{#2}%
+ }
+\def\ptx@freedef_slash#1/#2/{%
+ \usecs{ptx@freedef_user:\commandtoname#1}{#2}%
}
-\def\ptx@attribute_number#1{\usecs{ptx@attribute_#1}}
-\def\ptx@attribute_set#1{\passcs\attribute{ptx@attribute_#1}=1\relax}
-\def\ptx@attribute_unset#1{\passcs\attribute{ptx@attribute_#1}=-"7FFFFFFF\relax}
-\newdimen\urvsize
-\urvsize\vsize
-\def\inputpitexfile#1 {\input #1.ptx }
+\newbox\ptx@box_temp
-\inputpitexfile fonts
-\inputpitexfile sections
-% No footnotes in documentations.
-%\input footnotes.tex
-% I redefine the output routine on every job.
-%\input output.tex
+\newif\ifmaintext
+\maintexttrue
-\defactiveparameter document{%
- \pdfinfo{%
- /Author (\usevalueor #1 : author {Unknown author})
- /Title (\usevalueor #1 : pdftitle {\usevalueor #1 : title {No title}})
- \ifattribute #1 : subject {/Subject (\usevalue #1 : subject )}{}
- \ifattribute #1 : keywords {/Keywords (\usevalue #1 : keywords )}{}
- }%
- \pdfcatalog{%
- /PageMode
- \ifcasevalue #1 : display
- \val outlines /UseOutlines
- \val signets /UseOutlines % French!
- \val thumbs /UseThumbs
- \val thumbnails /UseThumbs
- \val full /FullScreen
- \val fullscreen /FullScreen
- \elseval /UseNone
- \endval
- }%
+% CATCODE TABLES
+\newcount\ptx@catcodetable_count
+\ptx@catcodetable_count=100 % First 100 are scratch.
+\def\newcatcodetable#1#2{%
+ \global\advance\ptx@catcodetable_count1
+ \chardef#1=\ptx@catcodetable_count
+ \begingroup
+ \setcatcodes{#2}%
+ \savecatcodetable#1%
+ \endgroup
}
-\restrictparameter document : author title pdftitle date subject keywords display version\par
-\restrictattribute document:display outlines signets thumbs thumbnails full fullscreen\par
+\newcatcodetable\texcatcodes{\@\_=12}
+\def\inputpitexfile#1 {\input #1.ptx }
-\defactiveparameter page{%
- \settovalue\pdfpagewidth #1 : pagewidth
- \settovalue\pdfpageheight #1 : pageheight
- \settovalue\baselineskip #1 : baselineskip
- \settovalueor\topskip #1 : topskip {\topskip=\baselineskip}%
- \settovalue\pdfhorigin #1 : left
- \ifattribute #1 : right
- {\hsize = \dimexpr(\pdfpagewidth-\pdfhorigin-\usevalue #1 : right )\relax}
- {\settovalue\hsize #1 : hsize }%
- \settovalue\pdfvorigin #1 : top
- \settovalue\parindent #1 : parindent
- \settovalue\parskip #1 : parskip
- \ifattribute #1 : lines {\vsize=\usevalue #1 : lines \baselineskip}{}%
- }
-\restrictparameter page : pagewidth
- pageheight
- hsize
- baselineskip
- topskip
- left
- right
- top
- lines
- parindent
- parskip
- \par
-
-% Defaults... they don't produce anything beautiful.
-% I redefine them on every job.
-\setparameter page:
- pageheight = 28cm
- pagewidth = 21cm
- hsize = 15cm
- baselineskip = 12pt
- lines = 42
- left = 1in
- top = 1in
- parskip = 0pt
+\inputpitexfile lua
+\inputpitexfile files
+\inputpitexfile fonts
+\inputpitexfile sections
+\inputpitexfile blocks
+\inputpitexfile references
+\inputpitexfile verbatim
+\inputpitexfile inserts
+\inputpitexfile output
+\input navigator.tex
+
+% AUXILIARY FILE
+\iffile{\jobname.aux}{%
+ \ptx@lua{%
+ remove_conversion()
+ tex.print("\luaescapestring{\noexpand\input\noexpand\jobname.aux}")
+ }%
+ \directlua{restore_conversion()}}
+\immediate\openout\ptx@auxfile=\jobname.aux
+% PDF SETTINGS
+\restrictparameter document : author title pdftitle date pdfdate subject keywords mode layout version\par
+\restrictattribute document : mode outlines bookmarks thumbs thumbnails attachments files oc\par
+\restrictattribute document : layout onepage onecolumn twopage twocolumn twopage* twocolumn*\par
-% Should be used with YaX to set parameters.
-\long\pdef\newblock{%
- \ifnext*{\gobbleoneand\ptx@newblock_group}
- {\ptx@newblock_nogroup}%
- }
-\def\ptx@newblock_nogroup#1#2#3{%
- \def#1{\ifnext/{\gobbleoneand{#3}}{#2}}%
- }
-\def\ptx@newblock_group#1#2#3{%
- \def#1{\ifnext/{\gobbleoneand{#3\egroup}}{\bgroup#2}}%
- }
-\def\antigobblespace{%
- \ifcatnext a{ }{\iffnext({ }}%
+\suppressoutererror=1
+\let\ptx@bye\bye
+\def\bye{%
+ \passvalueand{\setattribute navigator : title = } document : pdftitle { }{}
+ % The "date" attribute in the "document" parameter isn't supposed to hold a
+ % PDF-date, as navigator expects.
+ \deleteattribute document : date
+ \passvalueand{\setattribute navigator : date = } document : pdfdate { }{}
+ \finishpdffile\ptx@bye
}
+\setattribute navigator : meta = document
-% PDF links
-\def\dest#1#2{%
- \ifcs{ptx@link_name=#1}
- {\ptx@error{Link `#1' already exists}#2}
- {\letcs{ptx@link_name=#1}\relax
- \bgroup
- \ifvmode
- \pdfdest name {#1} xyz #2%
- \else
- \setbox0=\hbox{#2}%
- \raise\ht0\hbox{\pdfdest name {#1} xyz}#2%
- \fi
- \egroup
- }%
- }
-\def\link#1#2{%
- \pdfstartlink attr {/Border [0 0 0]} goto name {#1}#2\pdfendlink
- }
+% Turns a dimen into PostScript points, without the unit (as wanted by PDF).
+\def\pdfpoint#1{%
+ \directlua{%
+ local d = "\the\dimexpr#1"
+ d = string.gsub(d, "pt", "")
+ tex.print(tostring(d * (72/72.27)))
+ }}
-% Margin notes à la Bringhurst: aligned with the line they refer
-% to, unless they bleed into the bottom margin, in which case they
-% are shifted up so that their bottom line is aligned with the
-% page's bottom line. Totally experimental. It'd be nice if I could
-% do that with sections too (so that a note doesn't bleed into the
-% next section).
-\newattribute{note}
-\def\note{\ifnext[{\ptx@note}{\ptx@note[0pt]}}
-\def\ptx@note[#1]#2{%
- \ptx@attribute_set{note}%
- \setbox0=\hbox{\vtop{% We need the box's height minus its first line, hence the vtop.
- \notefont \baselineskip=9pt
- \hsize\dimexpr\pdfpagewidth-(\pdfhorigin+\hsize+4em)\relax
- \rightskip=0pt plus 1fil
- \it\noindent #2}}%
- \ptx@attribute_unset{note}%
- \ht0=0pt \dp0=0pt
- \vadjust{%
- \kern-\dimexpr(2pt+#1)\relax
- \moveright\dimexpr\hsize+1em
- \box0
- \kern\dimexpr2pt+#1}%
- \vrule height 0pt width 0pt depth 2pt
-% Problem: if the line where the note appears is last of its
-% box, the box has no depth and vfilling doesn't work properly.
- }%
-\directlua{%
- %
- % Box255 is traversed from the last node upward.
- % Each node with dimension adds to the "remaining height",
- % which is used when a note is encountered: if the note's depth
- % (minus its last box's depth) is larger than the remaining height,
- % then it is shifted upward, so that it doesn't bleed in the bottom
- % margin. When computing the remaining height, kerns and glues aren't
- % taken into account until a box has been seen (and the depth of
- % that first box isn't added either), so the note doesn't even
- % bleed into available page space that isn't filled with text.
- %
- process_marginalia = function (head)
- local remainingheight, first, item = 0, true, node.slide(head)
- while item do
- if node.has_attribute(item,\ptx@attribute_number{note}) then
- local depth = item.list.depth - node.tail(item.list.list).depth
- if depth > remainingheight then
- lualog("A note has been shifted on page " .. tex.count[0] ..
- " by an amount of " .. (depth-remainingheight)/65536 .. "pt.")
- item.list.shift = remainingheight-depth
- end
- elseif node.has_field(item, "height") then
- remainingheight = remainingheight+item.height
- if first then
- first = false
- else
- remainingheight = remainingheight + item.depth
- end
- elseif node.has_field(item,"kern") then
- if not first then
- remainingheight = remainingheight+item.kern
- end
- elseif node.has_field(item, "spec") then
- if not first then
- remainingheight = remainingheight+item.spec.width
- end
- end
- item = item.prev
- end
- end
- }
-\def\processmarginalia{%
- \directlua{process_marginalia(tex.box[255].list)}%
- }
-\def\stoppage{\penalty-10000\relax}
-\def\clearpage{\vfil\stoppage\relax}
-\def\needspace#1{%
- \penalty0
- \ifdim\dimexpr\pagegoal-\pagetotal<\dimexpr#1\relax
- \clearpage
- \fi
- }
-% Verbatim facilities.
-\newbox\ptx@box_temp
-\def\tcode#1{{\codefont#1}}
-\long\def\com#1{%
- \bgroup
- \codefont
- \string#1%
- \egroup
- \antigobblespace
+% TEX SETTINGS
+\long\def\ptx@tex_set#1#2#3{%
+ \ifcs{#2}
+ {\usecs{#2}=#3\relax}
+ {\ptx@error{No TeX parameter `#2'}}
}
-\def\arg#1{{\codefont\it<#1>}\iffnext\spacechar{\kern.2ex }}
-\def\barg#1{{\codefont\char"007B\relax{\it<#1>}\char"007D\relax}}
-\def\oarg#1{{\codefont[{\it<#1>}]}}
-
-\def\exampleskip{\vskip\baselineskip}
-\def\example{%
- \exampleskip
- \bgroup
- \parindent0pt
- \setcatcodes{\\\{\}\$\&\#\^\_\ \~\%=12,\^^M=13}%
- \codefont
- \readexample
- }%
-\let\ptx@example_original\example
-\bgroup
-\setcatcodes{\\=12,\|=0,\^^M=13}%
-|gdef|readexample#1^^M#2\example/{#2|egroup|exampleskip}%
-|restorecatcodes%
-\setcatcodes{\^^M=13}%
-\gdef^^M{\quitvmode\endgraf}%
-\egroup%
-\def\verb#1{%
- \def\ptx@verb##1#1{##1\egroup}%
- \bgroup
- \setcatcodes{\\\{\}\$\&\#\^\_\ \~\%=12}%
- \codefont
- \ptx@verb
+\defactiveparameter tex {%
+ \parameterloop #1 : \ptx@tex_set
}
-%
-% Read and process examples.
-%
-\newwrite\ptx@examplewrite
-
-\bgroup
-\setcatcodes{\%=12,\/=14}
-\gdef\Example{/
- \immediate\openout\ptx@examplewrite=\jobname.pex
- \immediate\write\ptx@examplewrite{% This is a scratch file used to typeset examples in \jobname.tex.}/
- \immediate\write\ptx@examplewrite{% You can delete it.}/
- \immediate\write\ptx@examplewrite{%}/
- \bgroup
- \setcatcodes{\\\#\%\^^M\ =12}/
- \writeexample
- }/
-\egroup
-
-\bgroup
-\setcatcodes{\^^M=12}%
-\gdef\writeexample#1^^M{%
- \immediate\write\ptx@examplewrite{\noexpand\example}%
- \ptx@writeexample}%
-\gdef\ptx@writeexample#1^^M{%
- \passexpanded{\ifstring{#1}}{\examplestring}%
- {\immediate\write\ptx@examplewrite{\string\example/}%
- \immediate\closeout\ptx@examplewrite\egroup%
- \processexample}%
- {\immediate\write\ptx@examplewrite{\primunexpanded{#1}}%
- \ptx@writeexample}%
- }%
-{\setcatcodes{\\=12,\|=0}|gdef|examplestring{\Example/}}%
-\egroup
+\frenchspacing
+\maxdepth=\maxdimen
-\def\typesetexample{%
- {\input\jobname.pex }%
- }
-\def\doexamplenogroup{\let\example\ptx@Example\input\jobname.pex \let\example\ptx@example_original}
-\def\doexample{{\doexamplenogroup}}
-\def\ptx@Example{%
- \iffnext/{\gobbleoneand\endinput}%
+\def\antigobblespace{%
+ \ifcatnext a{ }{\iffnext({ }}%
}
-% To be redefined for different layout.
-\def\processexample{\typesetexample\doexample}
-\def\verb#1{%
- \def\ptx@verb##1#1{##1\egroup}%
- \bgroup
- \setcatcodes{\\\{\}\$\&\#\^\_\ \~\%=12}%
- \codefont
- \ptx@verb
+\def\strut#1#2{%
+ \vrule height#1 depth#2 width0pt
}
-
\newdimen\extraboxspace
\newdimen\ptx@extraboxspace_top
\newdimen\ptx@extraboxspace_right
@@ -385,13 +222,15 @@
-\expandafter\noPT\the\ptx@extraboxspace_left
\expandafter\noPT\the\dimexpr(\ht\ptx@box_temp+\ptx@extraboxspace_top)\relax
\expandafter\noPT\the\dimexpr(\wd\ptx@box_temp+\ptx@extraboxspace_left+\ptx@extraboxspace_right)\relax
- -\expandafter\noPT\the\dimexpr(\ht\ptx@box_temp+\ptx@extraboxspace_top+\dp0+\ptx@extraboxspace_bottom)\relax
+ -\expandafter\noPT\the\dimexpr(\ht\ptx@box_temp+\ptx@extraboxspace_top+\dp\ptx@box_temp+\ptx@extraboxspace_bottom)\relax
re f Q}%
#2}%
\egroup
}
-\def\trace{\tracingcommands4 \tracingmacros4 }
+\def\og{\char"00AB~} \def\fg{~\char"00BB\antigobblespace}
+
+\def\trace{\tracingcommands3 \tracingmacros2 }
\def\untrace{\tracingcommands0 \tracingmacros0 }
-\restorecatcodes \ No newline at end of file
+\restorecatcodes