summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkii/scrn-hlp.mkii
blob: c526f51ebb4df02c56dbae44e275ae02cbae7e4c (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
%D \module
%D   [       file=scrn-hlp,
%D        version=1998.10.10,
%D          title=\CONTEXT\ Screen Macros,
%D       subtitle=Help (Experimental),
%D         author={Hans Hagen \& Ton Otten},
%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.

% todo : dedicated vide/hide voor helps

\writestatus{loading}{ConTeXt Screen Macros / Help popups}

%D This is an experimental and private module, so the interface
%D and functionality can change. Pieces of code will be moved
%D to other modules. More features are possible but will be
%D interfaces later. See m-chart for an application as well
%D as the second tno-tpd manual (graphic in margin, click
%D on it, pop up big one, use menu with hides, as well as
%D background, etc. etc.

\unprotect

\defineframedtext
  [\v!helptext]

\setupframedtexts
  [\v!helptext]
  [\c!width=.75\textwidth,
   \c!align=\v!normal,
   \c!frame=\v!off,
   \c!background=\v!screen]

\newcounter     \nofhelpdataentries
\newconditional \somehelpdatadefined

\appendtoks \getpagehelpdata         \to \beforeeverypage
\appendtoks \synchronizepagehelpdata \to \aftereverypage

% will be proper state variable

\let\pagehelpdata\empty

\def\dontresetpagedata
  {\let\synchronizepagehelpdata\relax}

\def\resetpagehelpdata
  {\iflocation
     \let\synchronizepagehelpdata\resetpagehelpdata
     \global\let\pagehelpdata\empty
     \resetreference[HideHelp]%
   \fi}

\let\synchronizepagehelpdata\resetpagehelpdata

\resetreference[HideHelp]

\def\getpagehelpdata
  {\iflocation\ifcase\nofhelpdataentries\else
     \let\pagehelpdata\empty
     \ifconditional\somehelpdatadefined
       \definetwopasslist{hlp:\realfolio}%
       \doloop
         {\gettwopassdata{hlp:\realfolio}%
          \iftwopassdatafound
            \addtocommalist\twopassdata\pagehelpdata
          \else
            \exitloop
          \fi}%
     \fi
     \ifx\pagehelpdata\empty \else
       \useJSscripts[fld]%
       \definereference[HideHelp][JS(Hide_Fields)]% for the moment
     \fi
   \fi\fi}

\def\setpagehelpdata[#1]%
  {\iflocation\expanded{\dosetpagehelpdata{#1}}\fi}

\def\dosetpagehelpdata#1%
  {\doglobal\increment\nofhelpdataentries
   \savetwopassdata{hlp:\realfolio}{\nofhelpdataentries}{#1}}

\setvalue{\e!start\v!helptext}[#1]%
  {\iflocation
     \global\settrue\somehelpdatadefined
     \setvalue{\e!stop\v!helptext}%
      %{\definesymbol[helpinfo:#1][{\doframedtext[\v!helptext]{\getbuffer[\v!helptext]}}]%
      % \dopresetfieldsymbol{helpinfo:#1}}%
       {\definesymbol[\v!helptext:#1][{\doframedtext[\v!helptext]{\getbuffer[\v!helptext]}}]%
        \dopresetfieldsymbol{\v!helptext:#1}}%
   \else
     \letvalue{\e!stop\v!helptext}\relax
   \fi
   \dostartbuffer[\v!helptext][\e!start\v!helptext][\e!stop\v!helptext]}

\long\def\helptext[#1]#2%
  {\iflocation
     \global\settrue\somehelpdatadefined
    %\definesymbol[helpinfo:#1][{\doframedtext[\v!helptext]{#2}}]%
    %\dopresetfieldsymbol{helpinfo:#1}%
     \definesymbol[\v!helptext:#1][{\doframedtext[\v!helptext]{#2}}]%
     \dopresetfieldsymbol{\v!helptext:#1}%
   \fi}

\let\definehelptext\helptext % for backward compabilities sake

\def\dohelpdata#1%
  {\setbox\scratchbox\hbox
     {\startoverlay
        {\box\scratchbox}
       %{\definemainfield[help:#1][check][helpsetup][helpinfo:#1][helpinfo:#1]%
        {\definemainfield[help:#1][check][helpsetup][\v!helptext:#1][\v!helptext:#1]%
         \fitfield[help:#1]}
      \stopoverlay}}

\def\helpdata
  {\iflocation
     \bgroup
    %\getpagehelpdata
     \ifx\pagehelpdata\empty \else
       \setupfields[\v!reset]%
       \setupfield
         [helpsetup]
         [\c!width=\v!fit,
          \c!height=\v!fit,
          \c!frame=\v!off,
          \c!clickin=JS(Hide_Fields),
          \c!option={\v!readonly,\v!hidden}]%
       \setbox\scratchbox\emptybox
       \processcommacommand[\pagehelpdata]\dohelpdata
       \box\scratchbox
     \fi
     \egroup
   \fi}

\def\helpbutton % also gobble spaces between [][]
  {\dodoubleempty\dohelpbutton}

\def\dohelpbutton
  {\ifsecondargument
     \expandafter\donohelpbutton
   \else
     \expandafter\dodohelpbutton
   \fi}

\def\dodohelpbutton[#1][#2]#3[#4]% #2 is space gobbling dummy
  {\iflocation
     \setpagehelpdata[#4]%
     \useJSscripts[fld]%
     \button[#1]{#3}[JS(Vide_Hide_Fields{help:#4})]%
   \fi}

\def\donohelpbutton[#1][#2]%
  {\dodohelpbutton[#1][]{}[#2]}

\def\doifhelpinfo#1#2%
  {\iflocation
     \doifsymboldefinedelse{helpinfo:#1}{#2}\donothing
   \fi}

\def\doifelsehelpinfo#1#2#3%
  {\iflocation
     \doifsymboldefinedelse{helpinfo:#1}{#2}{#3}%
   \fi}

\protect \endinput