summaryrefslogtreecommitdiff
path: root/texmf-dist/tex/latex/pmdb/pmdb.sty
blob: 9140cff6e2f7bf2ee303d4e80f3075146b4e051a (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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
%%
%% This is file `pmdb.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pmdb.dtx  (with options: `copyright,package')
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% pmdb.sty package,,                                    %%
%% Copyright (C) 2019-2021  D. P. Story                       %%
%%   dpstory@uakron.edu  dpstory@acrotex.net             %%
%%                                                       %%
%% This program can redistributed and/or modified under  %%
%% the terms of the LaTeX Project Public License         %%
%% Distributed from CTAN archives in directory           %%
%% macros/latex/base/lppl.txt; either version 1.2 of the %%
%% License, or (at your option) any later version.       %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pmdb}
 \ProvidesPackage{pmdb}[2021/06/07 v1.0 Mark for input files]
\edef\th@dquoteCat{\the\catcode`\"}
\catcode`\"=12\relax
\newif\ifpmdbmode \pmdbmodetrue
\DeclareOption{dbmode}{\pmdbmodetrue}
\DeclareOption{!dbmode}{\pmdbmodefalse}
\newif\ifpmdbtight \pmdbtightfalse
\DeclareOption{tight}{\pmdbtighttrue}
\DeclareOption{!tight}{\pmdbtightfalse}
\ProcessOptions
\RequirePackage{eforms}
\def\pmdb@ckThor{\@ifundefined{essayQ}{\let\essayQ\@gobble}{}}
\AtBeginDocument{\pmdb@ckThor}
\newif\ifpmdbFP \pmdbFPfalse
\newif\ifpmdbDQs \pmdbDQsfalse
\newif\ifeditSource \editSourcefalse
\def\editSourceOn{\editSourcetrue}
\def\editSourceOff{\editSourcefalse}
\newcount\pmdb@Cnt
\newcommand{\editSourceBtn}[3][]{\def\@editSourceBtn##1{%
    \pushButton[\A{/S/Launch/F(##1)}\protect\A#1
    ]{editPb.\the\pmdb@Cnt}{#2}{#3}}}
\newcommand{\editSourceLnk}[4][]{\def\@editSourceLnk##1{%
    \raisebox{1bp}{\setLinkBbox[\A{/S/Launch/F(##1)}
      \protect\A#1]{#2}{#3}[c]{\makebox[#2][l]{\thinspace#4}}}}}
\editSourceBtn[\TU{View in default editor}\S{S}]{11bp}{11bp}
\editSourceLnk[\linktxtcolor{red}\H{N}]{11bp}{11bp}{E}
\def\useEditBtn{\def\@editSourceBorL{\@editSourceBtn}}
\def\useEditLnk{\def\@editSourceBorL{\@editSourceLnk}}
\useEditBtn
\def\pmCBPresets#1{\def\pm@CBPresets{#1}}
\pmCBPresets{}
\def\cbSelectInput#1{\mbox{\checkBox[\TU{#1}\presets{\pm@CBPresets}
  \cmd{\bParams{#1}{\the\pmdb@Cnt}\eParams}
  \AAmouseup{\ccBoxMU}]{pmdbCkBx.\the\pmdb@Cnt}{11bp}{11bp}{On}%
  \ifeditSource\olBdry\@editSourceBorL{#1}\fi}\global
  \advance\pmdb@Cnt\@ne
}
\def\insertCkBx#1{\def\@insertCkBx##1{#1}}
\def\setCBsMarg{%
  \ifpmdbtight
    \if@reversemargin
      \def\pmAlignCBAlt{\ifodd\value{page}\leavevmode
        \hfill\else\fi}\else
      \def\pmAlignCBAlt{\ifodd\value{page}\else\hfill\fi}\fi
  \else
    \if@reversemargin
      \def\pmAlignCBAlt{\ifodd\value{page}\hfil\else\hfil\fi}\else
      \def\pmAlignCBAlt{\ifodd\value{page}\hfill\else\fi}\fi
  \fi
}
\def\altCBMargins{\let\pmAlignCB\pmAlignCBAlt}
\def\pmAlignCB{%
  \if@reversemargin
    \ifpmdbtight\hfill\else\fi
  \else
    \ifpmdbtight\else\hfill\fi
  \fi
}
\@ifundefined{chapter}{}{\AtBeginDocument{\setCBsMarg\altCBMargins}}
\newif\ifqzInput \qzInputfalse
\def\InputParas{\global\qzInputfalse
  \insertCkBx{\ifpmdbmode
  \everypar{\marginpar{\pmAlignCB
    \cbSelectInput{##1}}\global\everypar{}}\fi}}
\InputParas
\def\InputProbs{\global\qzInputfalse
  \insertCkBx{\ifpmdbmode
  \def\prior@questionsHook{\marginpar
    {\pmAlignCB\cbSelectInput{##1}}}\fi}}
\newcount\saveQNo \saveQNo\z@
\def\pmHook@qzItems{%
  \let\item@pmOld\item
  \def\item@pmNew{\item@pmOld\itemhook\let\item\item@pmOld}%
  \let\item\item@pmNew}
\def\InputQuizItems{\global\qzInputtrue
  \let\pmHook\pmHook@qzItems
  \saveQNo\z@
  \insertCkBx{\def\cbInQzMargin{\cbSelectInput{##1}}}%
  \ItemHook{\leavevmode\ifpmdbmode
  \ifnum\saveQNo<\value{eqquestionnoi}%
    \marginpar{\pmAlignCB\cbInQzMargin}\fi
  \saveQNo=\arabic{eqquestionnoi}\fi}}
\def\pmHook@item{\let\item@pmOld\item
  \def\item@pmNew{%
    \ifx\pmiarg\@empty
      \ifx\pm@Brk\ef@YES
        \def\pm@next{\item@pmOld[]}\else
        \let\pm@next\item@pmOld
      \fi
    \else
      \def\pm@next{\item@pmOld[\pmiarg]}%
    \fi\pm@next\itemhook\let\item\item@pmOld}%
  \let\item\item@pmNew
}
\def\ItemHook#1{\def\itemhook{#1}}
\def\InputItems{\global\qzInputfalse
  \let\pmHook\pmHook@item
  \insertCkBx{\def\cbInQzMargin{\cbSelectInput{##1}}}%
  \ItemHook{\leavevmode\ifpmdbmode
  \marginpar{\pmAlignCB\cbInQzMargin}\fi}}
\let\pmHook\relax
\def\ckBxInput#1{\@insertCkBx{#1}%
  \ifpmdbDQs\def\donext{\pmHook\input{"#1"}}\else
    \def\donext{\pmHook\input{#1}}\fi
  \donext}
\newcommand{\displayChoices}[3][]{\pushButton[\TU{\displayChoice@TU}
  \CA{\displayChoice@CA}#1\AAmouseup{\sldInputs}\protect\AA
]{sldInputs}{#2}{#3}}
\def\displayChoiceCA#1{\def\displayChoice@CA{#1}}
\def\displayChoiceTU#1{\def\displayChoice@TU{#1}}
\displayChoiceCA{Display Choices}
\displayChoiceTU{Display all choices in the console window}
\newcommand{\clrChoices}[3][]{\pushButton[\TU{\clrChoices@TU}
  \CA{\clrChoices@CA}#1\AAmouseup{\clrAction}\protect\AA
]{Inputs}{#2}{#3}}
\def\clrChoicesCA#1{\def\clrChoices@CA{#1}}
\def\clrChoicesTU#1{\def\clrChoices@TU{#1}}
\clrChoicesCA{Clear Choices}
\clrChoicesTU{Clear all check boxes created by pmdb}
\newcommand\@gobbleOR[2][]{}
\def\pmInput{\@ifstar{\@gobbleOR}{\pmInput@i}}
\def\pmInput@i{\@ifnextchar[%]
  {\let\pm@Brk\ef@YES\inputConta}
  {\let\pm@Brk\ef@NO\inputConta}}
\let\pm@Brk\ef@NO
\def\inputConta{\bgroup\@makeother\"\inputContb}
\newcommand\inputContb[2][]{\egroup\def\pmiarg{#1}\inputConti#2;;}
\def\inputConti{\@ifnextchar"%
  {\global\pmdbDQstrue\removedqs}
  {\global\pmdbDQsfalse\removesemis}}
\def\removedqs"#1";;{\inputContii{#1}}
\def\removesemis#1;;{\inputContii{#1}}
\def\inputContii#1{\isItFullPath#1:\@nil\doinput{#1}}
\def\isItFullPath#1:#2\@nil{%
  \def\@rgii{#2}\ifx\@rgii\@empty
    \global\pmdbFPfalse\else
    \global\pmdbFPtrue\fi}
\def\doinput#1{\ifpmdbmode\def\donext{\ckBxInput{#1}}\else
  \ifpmdbDQs\def\donext{\input{"#1"}}\else
    \def\donext{\input{#1}}\fi\fi
  \donext}
\def\pmInputWarni{\PackageWarningNoLine{pmdb}{The command
  \string\Input\space is already defined.\MessageBreak
  The checkboxes may not appear in the margins.\MessageBreak
  Use the supported command \string\pmInput\space instead}}
\def\pmInputWarnii{\PackageWarningNoLine{pmdb}{Letting
  \string\Input\space to \string\pmInput. You are \MessageBreak
  encouraged to use the supported\MessageBreak
  command \string\pmInput\space instead}}
\def\pmInputChk{%
  \@ifundefined{Input}{%
  \gdef\Input{\pmInputWarnii
    \global\let\pmInputWarnii\relax
    \global\let\pmInputWarni\relax
    \pmInput}}{\pmInputWarni}}
\AtBeginDocument{\pmInputChk}
\begin{defineJS}[\makeesc\@\makecmt\%]{\ccBoxMU}
@ifpmdbFP%
event.target.userName=("@p(1)");
@else%
// device independent path
var pos=this.path.lastIndexOf("/");
var thispath=this.path.substring(0,pos+1);
pos=thispath.indexOf("/",1);
var drive=thispath.substring(1,pos);
var platform=app.platform;
if (platform=="WIN")
  thispath=drive+":/"+thispath.substring(pos+1);
if (platform=="MAC")
  thispath=drive+"/"+thispath.substring(pos+1);
event.target.userName=thispath+("@p(1)");@fi
if (event.modifier){
  event.target.checkThisBox(0,!event.target.isBoxChecked(0));
  try {
    aebTrustedFunctions(this,aebLaunchURL,%
{cURL: "file:///"+event.target.userName});
  } catch(e) {
    console.show();
    console.println("The Ctrl+Click action is not supported, %
installation of aeb\_pro.js or aeb-reader.js is required.");
  }
}
if (event.shift) {
event.target.checkThisBox(0,!event.target.isBoxChecked(0));%
@ifqzInput
  this.gotoNamedDest("@currQuiz."+(@p(2)+1));@fi
} else {
  if (event.target.isBoxChecked(0)){
    _oSPaths["pmdbCkBx.@p(2)"]=%
[("@p(1)"),@ifpmdbDQs true@else false@fi];
    _aInputs[@p(2)]=true;
    _numInputs++;
  }else{
    _oSPaths["pmdbCkBx.@p(2)"]=null;
    _aInputs[@p(2)]=false;
    _numInputs--;
  }
  event.target["_boxState"]=!!event.target.isBoxChecked(0);
}
\end{defineJS}
\begin{defineJS}[\makecmt\%]{\sldInputs}
console.clear();console.show();
if (_numInputs==0) console.println("No inputs selected");
else {
  for(var i=0;i<_aInputs.length;i++){
    if (!!_aInputs[i]){
      if(_oSPaths["pmdbCkBx."+i][1])
        console.println('\\\\input\{\\"'+(_oSPaths["pmdbCkBx."+i][0])%
+'\\"\}');
      else
        console.println('\\\\input\{'+(_oSPaths["pmdbCkBx."+i][0])%
+'\}');
    }
  }
}
\end{defineJS}
\begin{defineJS}{\clrAction}
var _oSPaths=new Object;
var _aInputs=new Array;
var _numInputs=0;
this.resetForm("pmdbCkBx");
\end{defineJS}
\begin{insDLJS}{mrki}{Supporting JavaScript for pmdb}
var _oSPaths=new Object;
var _aInputs=new Array;
var _numInputs=0;
\end{insDLJS}
\catcode`\"=\th@dquoteCat
\endinput
%%
%% End of file `pmdb.sty'.