1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Screen Macros Help popups}
15
16
17
18
19
20
21\registerctxluafile{scrnhlp}{}
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\unprotect
55
56
57
58\newbox \b_scrn_help_box
59\newcount\c_scrn_help_n
60
61\definesystemattribute[help][public]
62
63\installcorenamespace{popuphelp}
64
65\installframedcommandhandler \??popuphelp {help} \??popuphelp
66
67\setuphelp
68 [\c!frame=\v!off,
69 \c!align=\v!normal,
70 \c!background=\v!color,
71 \c!backgroundcolor=gray]
72
73\appendtoks
74 \setuevalue \currenthelp {\scrn_help_argument{\currenthelp}}
75 \setuevalue{\e!start\currenthelp}{\scrn_help_start {\currenthelp}}
76 \setuevalue{\e!stop \currenthelp}{\scrn_help_stop }
77\to \everydefinehelp
78
79\unexpanded\def\scrn_help_argument#category
80 {\def\currenthelp{#category}
81 \global\advance\c_scrn_help_n\plusone
82 \edef\currenthelpname{help:\number\c_scrn_help_n}
83 \doifelselocation
84 {\dosingleempty\scrn_help_argument_indeed}
85 {\dosingleempty\scrn_help_argument_ignore}}
86
87\def\scrn_help_argument_indeed[#reference]#text#target
88 {\edef\currenthelpreference{#reference}
89 \dontleavehmode \hbox \bgroup
90 \dontcomplain
91 \setbox\b_scrn_help_box\hbox{\strut#text}
92 \scrn_help_register{#target}
93 \egroup
94 \goto
95 {\helpsignal{\number\c_scrn_help_n}#target}
96 [\helpaction{\number\c_scrn_help_n}]}
97
98\def\scrn_help_argument_ignore[#reference]#text#target
99 {#target}
100
101\unexpanded\def\scrn_help_start#category
102 {\def\currenthelp{#category}
103 \global\advance\c_scrn_help_n\plusone
104 \edef\currenthelpname{help:\number\c_scrn_help_n}
105 \dosingleempty\scrn_help_start_indeed}
106
107\def\scrn_help_start_indeed[#reference]
108 {\edef\currenthelpreference{#reference}
109 \grabbufferdatadirect\currenthelp{\e!start\currenthelp}{\e!stop\currenthelp}}
110
111\unexpanded\def\scrn_help_stop
112 {\iflocation
113 \scrn_help_register{\getbuffer[\currenthelp]}
114 \fi}
115
116\def\scrn_help_register#text
117 {\setbox\b_scrn_help_box\hbox{\inheritedhelpframed{#text}}
118 \definesymbol
119 [\currenthelpname]
120 [\copy\b_scrn_help_box]
121 \definefieldbody
122 [\currenthelpname]
123 [\c!type=push,
124 \c!width=\wd\b_scrn_help_box,
125 \c!height=\ht\b_scrn_help_box,
126 \c!depth=\dp\b_scrn_help_box,
127 \c!option=\v!hidden,
128 \c!clickin=action(hide{\currenthelpname}),
129 \c!closepage=action(hide{\currenthelpname}),
130 \c!values=\currenthelpname]
131 \setbox\b_scrn_help_box\hbox
132 {\fieldbody[\currenthelpname]}
133 \clf_registerhelp
134 number \c_scrn_help_n
135 name {\currenthelpreference}
136 box \b_scrn_help_box
137 \relax}
138
139\unexpanded\def\doifelsehelp
140 {\ifcase\c_scrn_help_n
141 \expandafter\firstoftwoarguments
142 \else
143 \expandafter\secondoftwoarguments
144 \fi}
145
146\let\doifhelpelse\doifelsehelp
147
148\unexpanded\def\placehelp
149 {\ifinpagebody\ifcase\c_scrn_help_n\else
150 \clf_collecthelp\normalpagebox
151 \fi\fi}
152
153\def\helpreference#category
154 {\clf_helpreference{#category}}
155
156\def\helpaction#category
157 {\clf_helpaction{#category}}
158
159\unexpanded\def\helpsignal#category
160 {\hbox attr \helpattribute \helpreference{#category}{}}
161
162\unexpanded\def\showhelp#target[#category]
163 {\goto{\helpsignal{#category}#target}[#category]}
164
165\definehelp[\v!helptext]
166
167\protect \endinput
168 |