typo-fln.mkiv /size: 3065 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=typo-fln,
3
%D version=2013.08.22, % comes from the few years older m-newstuff
4
%D title=\CONTEXT\ Typesetting Macros,
5
%D subtitle=First Lines,
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
Typesetting
Macros
/
First
Lines
}
15 16
%D I had this code laying around for a while \unknown\ probably as a side effect
17
%D of cleaning up the supp-fun modules. There is probably room for improvement
18
%D and more features.
19 20
% \setupbodyfont[pagella]
21
%
22
% \starttext
23
%
24
% \setupindenting[medium,yes]
25
%
26
% \definefirstline
27
% [smallcaps]
28
% [alternative=line,
29
% color=darkred,
30
% style=\setfontfeature{smallcaps}]
31
%
32
% \setfirstline[smallcaps] \input tufte \par
33
% \setfirstline[smallcaps] \input ward \par
34
% \setfirstline[smallcaps] \input knuth \par
35
% \setfirstline[smallcaps] \input bryson \par
36
%
37
% \definefirstline
38
% [smallcaps]
39
% [alternative=word,
40
% color=darkblue,
41
% style=bold,
42
% n=2]
43
%
44
% \setfirstline[smallcaps] \input tufte \par
45
% \setfirstline[smallcaps] \input ward \par
46
% \setfirstline[smallcaps] \input knuth \par
47
% \setfirstline[smallcaps] \input bryson \par
48
%
49
% \stoptext
50 51
\unprotect
52 53
\registerctxluafile
{
typo
-
fln
}
{
}
54 55
\definesystemattribute
[
firstline
]
[
public
]
56 57
\appendtoks
58
\c_attr_firstline
\attributeunsetvalue
59
\to
\everyforgetall
60 61
\installcorenamespace
{
firstline
}
62 63
\installcommandhandler
\??firstline
{
firstline
}
\??firstline
64 65
\setupfirstline
66
[
\c!alternative
=
\v!line
,
67
%\c!style=,
68
%\c!color=,
69
\c!n
=
1
]
70 71
\unexpanded
\def
\setfirstline
72
{
\dosingleempty
\typo_firstline_set
}
73 74
\unexpanded
\def
\typo_firstline_set
[
#
1
]
%
75
{
\edef
\typo_firstline_handle
{
\typo_firstline_handle_indeed
{
#
1
}
}
}
76 77
\unexpanded
\def
\typo_firstline_handle_indeed
#
1
%
78
{
\dontleavehmode
79
\begingroup
80
\edef
\currentfirstline
{
#
1
}
%
81
\usefirstlinestyleandcolor
\c!style
\c!color
82
\clf_setfirstline
83
alternative
{
\firstlineparameter
\c!alternative
}
%
84
ma
\c_attr_colormodel
85
ca
\c_attr_color
86
ta
\c_attr_transparency
87
n
\numexpr
\firstlineparameter
\c!n
\relax
88
font
\fontid
\font
89
dynamic
\font_dynamic_value
90
\relax
91
% \kern\zeropoint % we need a node
92
% \hskip\zeropoint\s!plus\emwidth\relax % can be an option
93
\endgroup
94
\glet
\typo_firstline_handle
\relax
}
95 96
\let
\typo_firstline_handle
\relax
97 98
% goodie, question on list
99
%
100
% \defineframed[ChapterFramed][location=low,background=color,backgroundcolor=red,frame=off]
101
%
102
% \setuphead[chapter][deeptextcommand=\applytofirstcharacter\ChapterFramed]
103 104
\unexpanded
\def
\applytofirstcharacter
#
1
%
105
{
\begingroup
106
\dowithnextbox
107
{
\clf_applytofirstcharacter
\nextbox
{
\csstring
#
1
}
%
108
\unhbox
\nextbox
109
\endgroup
}
%
110
\hbox
}
111 112
\protect
\endinput
113