page-par.mkiv /size: 2211 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=page-par, % copied from page-lin
3
%D version=1997.03.31,
4
%D title=\CONTEXT\ Page Macros,
5
%D subtitle=Line Numbering,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\writestatus
{
loading
}{
ConTeXt
Page
Macros
/
Paragraph
Numbering
}
15 16
\unprotect
17 18
\installcorenamespace
{
paragraphnumbering
}
19
\installcorenamespace
{
paragraphnumberingvariants
}
20 21
\installsimplecommandhandler
\??paragraphnumbering
{
paragraphnumbering
}
\??paragraphnumbering
22 23
\definecounter
[
\v!paragraph
]
24 25
\let
\showparagraphnumber
\relax
26 27
\appendtoks
28
\page_par_check_state
29
\to
\everysetupparagraphnumbering
30 31
\unexpanded
\def
\page_par_check_state
32
{
\rawprocesscommacommand
[
\paragraphnumberingparameter
\c!state
]
\page_par_check_state_step
}
33 34
\def
\page_par_check_state_step
#
1
%
35
{
\ifcsname
\??paragraphnumberingvariants
#
1
\endcsname
36
\csname
\??paragraphnumberingvariants
#
1
\endcsname
37
\fi
}
38 39
\setvalue
{
\??paragraphnumberingvariants\v!start
}
%
40
{
\let
\showparagraphnumber
\page_par_show_number_normal
}
41 42
\setvalue
{
\??paragraphnumberingvariants\v!stop
}
%
43
{
\let
\showparagraphnumber
\relax
}
44 45
\setvalue
{
\??paragraphnumberingvariants\v!line
}
%
46
{
\let
\showparagraphnumber
\page_par_show_number_lines
}
47 48
\setvalue
{
\??paragraphnumberingvariants\v!reset
}
%
49
{
\strc_counters_reset
\v!paragraph
50
\let
\showparagraphnumber
\page_par_show_number_normal
}
51 52
\unexpanded
\def
\page_par_show_number_normal
53
{
\strc_counters_increment
\v!paragraph
54
\inleftmargin
% todo: \c!location, only a few make sense
55
{
\hfill
% no complaints
56
\tf
% \tf normalizes em
57
\useparagraphnumberingstyleandcolor
\c!style\c!color
58
\convertedcounter
[
\v!paragraph
]
%
59
\kern
\paragraphnumberingparameter
\c!distance
}}
60 61
\unexpanded
\def
\page_par_show_number_lines
62
{
\ifnumberinglines
63
\page_par_show_number_normal
64
\fi
}
65 66
\setupparagraphnumbering
67
[
\c!state
=
\v!stop
,
68
%\c!location,
69
%\c!style=,
70
%\c!color=,
71
\c!distance
=
\ifcase
\c_page_lines_location
2
\emwidth
\else
\zeropoint
\fi
]
% will change
72 73
\protect
\endinput
74