summaryrefslogtreecommitdiff
path: root/tex/context/base/page-flt.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/page-flt.mkiv')
-rw-r--r--tex/context/base/page-flt.mkiv214
1 files changed, 94 insertions, 120 deletions
diff --git a/tex/context/base/page-flt.mkiv b/tex/context/base/page-flt.mkiv
index 65abc844c..18c0ad263 100644
--- a/tex/context/base/page-flt.mkiv
+++ b/tex/context/base/page-flt.mkiv
@@ -20,42 +20,31 @@
\unprotect
-\ifdefined\s!topfloat \else \def\s!topfloat {topfloat} \fi
-\ifdefined\s!bottomfloat \else \def\s!bottomfloat{bottomfloat} \fi
+%D To be checked and removed
-\defineinsertion[\s!topfloat]
-\defineinsertion[\s!bottomfloat]
-
-\newdimen \d_page_floats_inserted_bottom
-\newdimen \d_page_floats_inserted_top
-\newcount \c_page_floats_n_of_top \c_page_floats_n_of_top \plustwo
-\newcount \c_page_floats_n_of_bottom \c_page_floats_n_of_bottom\zerocount
-
-\newconstant\c_page_floats_insertions_topskip_mode % 1 = no topskip
-
-%def\page_floats_report_saved {\showmessage\m!floatblocks2{\the\totalnoffloats}}
-\def\page_floats_report_total {\showmessage\m!floatblocks4{\the\totalnoffloats}}
-\def\page_floats_report_flushed{\showmessage\m!floatblocks3{\the\numexpr\totalnoffloats-\savednoffloats\relax}}
+%def\dosavefloatinfo {\showmessage\m!floatblocks2{\the\totalnoffloats}}
+\def\doinsertfloatinfo {\showmessage\m!floatblocks4{\the\totalnoffloats}}
+\def\dofloatflushedinfo{\showmessage\m!floatblocks3{\the\numexpr\totalnoffloats-\savednoffloats\relax}}
%D Extra float registers.
-\newconditional\c_page_floats_room
-\newconditional\c_page_floats_some_waiting
-\newconditional\c_page_floats_not_permitted
-\newconditional\c_page_floats_flushing
-\newconditional\c_page_floats_center_box \settrue\c_page_floats_center_box
-\newconditional\c_page_floats_center_box_local
-\newconditional\c_page_floats_center_box_global
-\newconditional\c_page_floats_pack_flushed \settrue\c_page_floats_pack_flushed
-
-%D For the moment we keep this but they will become private too.
-
-\newcount\totalnoffloats % these will be redone ... handled at the lua end anyway
-\newcount\savednoffloats % these will be redone ... handled at the lua end anyway
+\newif\ifsomefloatwaiting \somefloatwaitingfalse
+\newif\ifroomforfloat \roomforfloattrue
+\newif\ifnofloatpermitted \nofloatpermittedfalse
+\newif\ifcenterfloatbox \centerfloatboxtrue
+\newif\iflocalcenterfloatbox \localcenterfloatboxfalse
+\newif\ifglobalcenterfloatbox \globalcenterfloatboxfalse
+\newif\ifflushingfloats \flushingfloatsfalse
+\newif\ifpackflushedfloats \packflushedfloatstrue % for the moment
+\newif\ifpackcolumnfloats \packcolumnfloatstrue
+
+\newcount\totalnoffloats
+\newcount\savednoffloats
+\newcount\noffloatinserts
\newcount\nofcollectedfloats % communication channel
-\newcount\noffloatinserts % these will be redone ... handled at the lua end anyway
-
+\newbox \floatlist
+\newbox \savedfloatlist
\newbox \floattext
\newdimen\floatwidth
@@ -76,55 +65,55 @@
\appendtoks
\ifcase\savednoffloats
- \global\setfalse\c_page_floats_some_waiting
+ \global\somefloatwaitingfalse
\else
- \global\settrue\c_page_floats_some_waiting
+ \global\somefloatwaitingtrue
\fi
\to \everyfloatscheck
-\unexpanded\def\page_floats_flush#1#2%
+\def\dofloatsflush#1#2%
{\ctxcommand{flushfloat("#1",\number#2)}%
\the\everyfloatscheck}
-\unexpanded\def\page_floats_flush_by_label#1#2%
+\def\dofloatsflushbylabel#1#2%
{\ctxcommand{flushfloat("#1","#2",true)}%
\the\everyfloatscheck}
-\unexpanded\def\page_floats_save#1%
+\def\dofloatssave#1%
{\ctxcommand{savefloat("#1")}%
\the\everyfloatscheck}
-\unexpanded\def\page_floats_resave#1%
+\def\dofloatsresave#1%
{\ctxcommand{resavefloat("#1")}%
\the\everyfloatscheck}
-\unexpanded\def\page_floats_push_saved
+\def\dopushsavedfloats
{\ctxcommand{pushfloat()}%
\the\everyfloatscheck}
-\unexpanded\def\page_floats_pop_saved
+\def\dopopsavedfloats
{\ctxcommand{popfloat()}%
\the\everyfloatscheck}
-\unexpanded\def\page_floats_get_info#1%
+\def\dofloatsgetinfo#1%
{\ctxcommand{consultfloat("#1")}}
-\unexpanded\def\page_floats_if_else#1%
+\def\doifelsesavedfloat#1%
{\ctxcommand{doifelsesavedfloat("#1")}}
-\unexpanded\def\page_floats_collect#1#2#3%
+\def\dofloatscollect#1#2#3%
{\ctxcommand{collectfloat("#1",\number\dimexpr#2,\number\dimexpr#3)}}
-\unexpanded\def\nofstackedfloatincategory#1%
+\def\nofstackedfloatincategory#1%
{\ctxcommand{nofstackedfloats("#1")}}
-\let\page_floats_column_push_saved\page_floats_push_saved % overloaded in page-mul
-\let\page_floats_column_pop_saved \page_floats_pop_saved % overloaded in page-mul
+\let\dopushcolumnfloats\dopushsavedfloats
+\let\dopopcolumnfloats \dopopsavedfloats
-\unexpanded\def\page_floats_save_page_float#1#2%
+\def\dofloatssavepagefloat#1#2%
{\ctxcommand{savefloat("#1", { specification = "#2" })}}
-\unexpanded\def\page_floats_save_somewhere_float#1#2% #1=method
+\def\dofloatssavesomewherefloat#1#2% #1=method
{\ctxcommand{savefloat("#1", { specification = "#2", label = "\floatlabel" })}}
%D This is an experimental new feature (for Alan Braslau), a prelude to more:
@@ -144,19 +133,19 @@
%D \placenamedfloat[figure][beta]
%D \stoptyping
-\unexpanded\def\placenamedfloat
- {\dodoubleargument\page_floats_place_named}
+\def\placenamedfloat
+ {\dodoubleargument\doplacenamedfloat}
-\def\page_floats_place_named[#1][#2]%
+\def\doplacenamedfloat[#1][#2]%
{\doloop
- {\page_floats_flush_by_label\s!somewhere{#2}%
+ {\dofloatsflushbylabel\s!somewhere{#2}%
\ifvoid\floatbox
\exitloop
\else
- \def {#1}%
+ \def\currentfloat{#1}%
\blank[\rootfloatparameter\c!spacebefore]%
\box\floatbox
- \blank[\rootfloatparameter\c!spaceafter]%
+ \blank[\rootfloatparameter\c!spaceafter]
\fi}}
% \setupcaption [figure] [align=flushleft]
@@ -173,10 +162,10 @@
%
% \placefloatwithsetups[somefigure]{}{\externalfigure[dummy][width=5cm,height=2cm]}
-\unexpanded\def\placefloatwithsetups
- {\dotripleempty\page_floats_place_with_setups}
+\def\placefloatwithsetups
+ {\dotripleempty\doplacefloatwithsetups}
-\def\page_floats_place_with_setups[#1][#2][#3]#4%
+\long\def\doplacefloatwithsetups[#1][#2][#3]#4%
{\def\floatsetupcaption {#4}%
\def\floatsetupcontent {\copy\nextbox}%
\def\floatsetupwidth {\wd\nextbox}%
@@ -189,10 +178,10 @@
%D
%D First we reimplement some helpers.
-\unexpanded\def\page_floats_get
- {\ifconditional\c_page_floats_some_waiting
- \page_floats_flush\s!text\plusone
- \ifconditional\c_page_floats_center_box
+\def\dogetfloat
+ {\ifsomefloatwaiting
+ \dofloatsflush\s!text{1}%
+ \ifcenterfloatbox
\ifdim\wd\globalscratchbox<\hsize
\global\setbox\floatbox\hbox to \hsize{\hss\box\floatbox\hss}%
\else
@@ -209,53 +198,40 @@
\global\setbox\floatbox\emptybox
\fi}
-\unexpanded\def\page_floats_flush_saved
+\def\dosavefloat
+ {\dofloatssave\s!text
+ \nonoindentation} % brrr nonoindentation here
+
+\def\doresavefloat
+ {\dofloatsresave\s!text}
+
+\def\doreversesavefloat
+ {\dofloatsresave\s!text}
+
+\def\doflushsavedfloats
{\doloop
- {\ifconditional\c_page_floats_some_waiting
+ {\ifsomefloatwaiting
\page_otr_command_check_if_float_fits
- \ifconditional\c_page_floats_room
- \page_floats_get
+ \ifroomforfloat
+ \dogetfloat
\doplacefloatbox
\else
\exitloop
\fi
\else
- % \ifconditional\c_page_margin_blocks_present % not here, here just as many floats as fit
- % \page_otr_command_flush_margin_blocks
- % \else
+% \ifconditional\c_page_margin_blocks_present % not here, here just as many floats as fit
+% \page_otr_command_flush_margin_blocks
+% \else
\exitloop
- % \fi
+% \fi
\fi}}
-%D This is a future mechamism that will be integrated once we're sure about it:
-%D
-%D \starttyping
-%D \dorecurse{10}
-%D {\input thuan
-%D \placefigure{}{\framed[height=1.5cm]{test}}
-%D \placefloatplaceholder}
-%D \stoptyping
-
-\unexpanded\def\placefloatplaceholder
- {\ifconditional\c_page_floats_room \else
- \ifdim\dimexpr\pagegoal-\pagetotal-3\lineheight\relax>\zeropoint
- \startlinecorrection[blank]
- \mhbox{\inframed{\labeltexts{placeholder}{\lastcaptiontag}}}%
- \stoplinecorrection
- \else
- \allowbreak
- \fi
- \fi}
-
-\setuplabeltext
- [placeholder={\Word{\lastplacedfloat}~, moved}]
-
%D Page floats use different stacks.
-\newtoks\everybeforeflushedpagefloat
+\newtoks \everybeforeflushedpagefloat
-\def\page_floats_flush_page_floats_indeed#1% future releases can do more clever things
- {\page_floats_flush{#1}\plusone
+\def\doflushsomepagefloat#1% future releases can do more clever things
+ {\dofloatsflush{#1}{1}%
\edef\floatspecification{\ctxcommand{getfloatvariable("specification")}}% Is this okay?
\the\everybeforeflushedpagefloat
\vbox to \textheight
@@ -264,15 +240,38 @@
\doifnotinset\v!low\floatspecification\vfill}%
\page_otr_fill_and_eject_page}
-\unexpanded\def\page_floats_flush_page_floats % used in postpone
+\def\doflushpagefloats
{\edef\m_page_otf_checked_page_float{\ctxcommand{checkedpagefloat()}}% (true) for packed
\ifx\m_page_otf_checked_page_float\empty
% nothing
\else\ifx\m_page_otf_checked_page_float\v!empty
\emptyhbox \page_otr_fill_and_eject_page % why not dummy_page
\else
- \page_floats_flush_page_floats_indeed\m_page_otf_checked_page_float
+ \doflushsomepagefloat\m_page_otf_checked_page_float
\fi\fi}
+
+\def\uncenteredfloatbox % hm, where is this one used (was in save/restore, see old implementation)
+ {\ifcenterfloatbox
+ \ifhbox\floatbox\relax % remove centering
+ \ifdim\wd\floatbox=\hsize
+ \ifhbox\floatbox
+ \setbox\scratchbox\hbox
+ {\unhbox\floatbox
+ \unskip\unskip
+ \global\setbox\globalscratchbox\lastbox}%
+ \box\globalscratchbox
+ \else
+ \box\floatbox
+ \fi
+ \else
+ \box\floatbox
+ \fi
+ \else
+ \box\floatbox
+ \fi
+ \else
+ \box\floatbox
+ \fi}
% temp hack, needed to prevent floatbox being forgotten during
% output, this will change to using another box for flushing
@@ -292,28 +291,3 @@
\to \everyafteroutput
\protect \endinput
-
-% hm, where is this one used (was in save/restore, see old implementation)
-%
-% \unexpanded\def\uncenteredfloatbox
-% {\ifconditional\c_page_floats_center_box
-% \ifhbox\floatbox\relax % remove centering
-% \ifdim\wd\floatbox=\hsize
-% \ifhbox\floatbox
-% \setbox\scratchbox\hbox
-% {\unhbox\floatbox
-% \unskip\unskip
-% \global\setbox\globalscratchbox\lastbox}%
-% \box\globalscratchbox
-% \else
-% \box\floatbox
-% \fi
-% \else
-% \box\floatbox
-% \fi
-% \else
-% \box\floatbox
-% \fi
-% \else
-% \box\floatbox
-% \fi}