diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/page-grd.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/page-grd.mkiv | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/page-grd.mkiv b/Master/texmf-dist/tex/context/base/page-grd.mkiv new file mode 100644 index 00000000000..e882978ca38 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/page-grd.mkiv @@ -0,0 +1,85 @@ +%D \module +%D [ file=page-grd, % moved from page-ini +%D version=2011.12.07, % 2000.10.20, +%D title=\CONTEXT\ Page Macros, +%D subtitle=Grids, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}] +%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 Page Macros / Grids} + +\unprotect + +\definepalet + [layout] + [grid=red, + page=green] + +\newconstant\c_page_grids_location +\newconstant\c_page_grids_line_mode +\newconstant\c_page_grids_lineno_mode + +\unexpanded\def\showgrid + {\dosingleempty\page_grids_show} + +\def\page_grids_show[#1]% + {\c_page_grids_location \plusone % downward compatible default + \c_page_grids_line_mode \plusone + \c_page_grids_lineno_mode\plusone + \processallactionsinset + [#1]% + [ \v!reset=>\c_page_grids_location \zerocount, + \v!bottom=>\c_page_grids_location \plusone, + \v!top=>\c_page_grids_location \plustwo, + \v!none=>\c_page_grids_line_mode \zerocount, + \v!all=>\c_page_grids_line_mode \plusone, + \v!lines=>\c_page_grids_line_mode \plustwo, + \v!frame=>\c_page_grids_line_mode \plusthree, + \v!nonumber=>\c_page_grids_lineno_mode\zerocount, + \v!right=>\c_page_grids_lineno_mode\plusone, + \v!left=>\c_page_grids_lineno_mode\plustwo, + \v!outer=>\c_page_grids_lineno_mode\plusthree]% + \ifcase\c_page_grids_location + \let\page_grids_add_to_box\gobbleoneargument + \else % 1=bottom 2=top + \let\page_grids_add_to_box\page_grids_add_to_box_indeed + \fi} + +% if really needed for speed we can cache the grid + +\let\page_grids_add_to_box\gobbleoneargument + +\def\page_grids_add_to_box_indeed#1% to be checked for color and layer ..... use mp + {\startcolor[layout:grid]% + \gridboxlinemode \c_page_grids_line_mode + \gridboxlinenomode\c_page_grids_lineno_mode + \setgridbox\scratchbox\makeupwidth\textheight % todo: check color + \global\setbox#1\hbox % global ? + {\ifcase\c_page_grids_location\or\or\box#1\hskip-\makeupwidth\fi + \begingroup % color + \ifcase\layoutcolumns\else + \gray + \setlayoutcomponentattribute{\v!grid:\v!columns}% + \hbox \layoutcomponentboxattribute to \makeupwidth + {\dorecurse\layoutcolumns + {\hskip\layoutcolumnwidth + \ifnum\recurselevel<\layoutcolumns + \vrule + \!!height\ht\scratchbox + \!!depth\dp\scratchbox + \!!width\layoutcolumndistance + \fi}}% + \hskip-\makeupwidth + \fi + \setlayoutcomponentattribute{\v!grid:\v!lines}% + \hbox \layoutcomponentboxattribute{\box\scratchbox}% + \endgroup + \ifcase\c_page_grids_location\or\hskip-\makeupwidth\box#1\fi}% + \stopcolor} + +\protect \endinput |