summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkiv/page-par.mkiv
blob: 588065d6563ac32a4f1bee7289e17b5bcddedc29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
%D \module
%D   [       file=page-par, % copied from page-lin
%D        version=1997.03.31,
%D          title=\CONTEXT\ Page Macros,
%D       subtitle=Line Numbering,
%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 / Paragraph Numbering}

\unprotect

\installcorenamespace {paragraphnumbering}
\installcorenamespace {paragraphnumberingvariants}

\installsimplecommandhandler \??paragraphnumbering {paragraphnumbering} \??paragraphnumbering

\definecounter[\v!paragraph]

\let\showparagraphnumber\relax

\appendtoks
    \page_par_check_state
\to \everysetupparagraphnumbering

\unexpanded\def\page_par_check_state
  {\rawprocesscommacommand[\paragraphnumberingparameter\c!state]\page_par_check_state_step}

\def\page_par_check_state_step#1%
  {\ifcsname\??paragraphnumberingvariants#1\endcsname
     \csname\??paragraphnumberingvariants#1\endcsname
   \fi}

\setvalue{\??paragraphnumberingvariants\v!start}%
  {\let\showparagraphnumber\page_par_show_number_normal}

\setvalue{\??paragraphnumberingvariants\v!stop}%
  {\let\showparagraphnumber\relax}

\setvalue{\??paragraphnumberingvariants\v!line}%
  {\let\showparagraphnumber\page_par_show_number_lines}

\setvalue{\??paragraphnumberingvariants\v!reset}%
  {\strc_counters_reset\v!paragraph
   \let\showparagraphnumber\page_par_show_number_normal}

\unexpanded\def\page_par_show_number_normal
  {\strc_counters_increment\v!paragraph
   \inleftmargin % todo: \c!location, only a few make sense
     {\hfill % no complaints
      \tf % \tf normalizes em
      \useparagraphnumberingstyleandcolor\c!style\c!color
      \convertedcounter[\v!paragraph]%
      \kern\paragraphnumberingparameter\c!distance}}

\unexpanded\def\page_par_show_number_lines
  {\ifnumberinglines
     \page_par_show_number_normal
   \fi}

\setupparagraphnumbering
  [\c!state=\v!stop,
  %\c!location,
  %\c!style=,
  %\c!color=,
   \c!distance=\ifcase\c_page_lines_location2\emwidth\else\zeropoint\fi] % will change

\protect \endinput