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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
|
%\iffalse
% makeindex -s gglo.ist -o pmdb.gls pmdb.glo
% makeindex -s gind.ist -o pmdb.ind pmdb.idx
%<*copyright>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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. %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%</copyright>
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{pmdb}
%<package> \ProvidesPackage{pmdb}[2021/06/07 v1.0 Mark for input files]
%<*driver>
\documentclass{ltxdoc}
\usepackage[colorlinks,hyperindex=false,linktocpage,bookmarksnumbered]{hyperref}
\usepackage{calc}
%\def\texorpdfstring#1#2{#1}
%\pdfstringdefDisableCommands{\let\\\textbackslash}
\OnlyDescription % comment out for implementation details
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\gdef\brpr#1{\texttt{\char123\relax#1\char125\relax}}
\let\darg\brpr
\let\env\texttt
\let\opt\texttt
\let\app\textsf
\let\pkg\textsf
\let\uif\textsf
\let\tops\texorpdfstring
\def\EXCL{!}
\def\nmpsep#1{\hskip-\marginparsep\texttt{#1}}
\def\visispace{\symbol{32}}
\def\ameta#1{\ensuremath{\langle\textit{\texttt{#1}}\rangle}}
\def\meta#1{\textsl{\texttt{#1}}}
\def\SUB#1{\ensuremath{{}_{\mbox{\scriptsize\ttfamily#1}}}}
\def\CMD#1{\textbackslash#1}
\makeatletter
\renewcommand{\paragraph}
{\@startsection{paragraph}{4}{0pt}{6pt}{-3pt}{\bfseries}}
\renewcommand{\subparagraph}
{\@startsection{subparagraph}{5}{\parindent}{6pt}{-3pt}%
{\normalfont\normalsize\bfseries}}
\let\@latex@warning\@gobble
\makeatother
\InputIfFileExists{aebdocfmt.def}{\PackageInfo{pmdb}{Inputting aebdocfmt.def}}
{\def\IndexOpt{\DescribeMacro}\def\IndexKey{\DescribeMacro}\let\setupFullwidth\relax
\PackageInfo{pmdb}{aebdocfmt.def cannot be found}}
\begin{document}
\addtolength{\marginparwidth}{3pt}
\GetFileInfo{pmdb.sty}
\title{The \textsf{pmdb} Package}
\author{D. P. Story\\
Email: \texttt{dpstory@acrotex.net}}
\date{processed \today}
\maketitle
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\bgroup
\value{secnumdepth}=3
\value{tocdepth}=3
\tableofcontents
\egroup
\DocInput{pmdb.dtx}
\IfFileExists{\jobname.ind}{\newpage\setupFullwidth\par\PrintIndex}
{\paragraph*{Index} The index goes here. Execute
\begin{quote}\texttt{makeindex -s gind.ist -o pmdb.ind pmdb.idx}\end{quote}
on the command line and recompile
\texttt{pmdb.dtx}.}
\IfFileExists{\jobname.gls}{\PrintChanges}
{\paragraph*{Change History} The list of changes goes here. Execute
\begin{quote}
\texttt{makeindex -s gglo.ist -o pmdb.gls pmdb.glo}
\end{quote}
on the command line and recompile \texttt{pmdb.dtx}.}
\end{document}
%</driver>
% \fi
% \MakeShortVerb{|}
% \InputIfFileExists{aebdonotindex.def}{\PackageInfo{web}{Inputting aebdonotindex.def}}
% {\PackageInfo{web}{cannot find aebdonotindex.def}}
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% \section{Introduction}
% This package addresses the issue of a poor-man's database. Educators who use {\LaTeX} to construct
% exams and homework sometimes have a collection of problems. Each problem is in its own TEX file. The educator
% creates a document and \cs{inputs} several of these packaged questions. This package attempts to provide some
% ``user interface'' to the questions and provides a mechanism of selecting which questions are to be included in the
% document.
%
%\paragraph*{What does this package do?} For a document that inputs content using the {\LaTeX} command \cs{input},
%the same content can be input using the command \cs{pmInput} (capitalized). When content is input by \cs{pmInput}, a check
%box is created in the margin at the insertion point of the content. The check boxes so created can be checked or cleared.
%When the user clicks on push button provided by this package, a list of all \emph{selected} \cs{input} statements are listed
%in the JavaScript console. This list can then be copied and pasted into another document the author is developing. If you
%\uif{Ctrl+Click} on a check box, the associated content is opened in the default TEX editor. In this way, the document author
%can see a typeset of the content and decide whether the content should be included in the developing document.
%
%\paragraph*{The DB stage:} When you have a collection of questions (or content) in various files and want to use
%this package to \cs{input} them into your document, the following comments are apropos:
%
%\subparagraph*{PDF creators:} Any PDF creator current in the {\LaTeX} world is valid for use with this package.
%
%\subparagraph*{PDF viewers:}
%The ideal viewer is \app{Acrobat}, however, \app{Adobe Reader} and \app{PDF-XChange Editor} can also be used.
%In the case of \app{Adobe Reader}, there is an annoying security dialog box that appears each time you use the
%\uif{Ctrl+Click} feature of the check box; the \uif{Ctrl+Click} feature does not WORK with \app{PDF-XChange Editor}.
%
%\paragraph*{The production stage:} After the document has been assembled (using \pkg{pmdb}), and you build your final document
%(perhaps an \pkg{exerquiz} quiz), the end user can use an appropriate PDF reader. If an \pkg{exerquiz} quiz is used, then
%a minimum of \app{Adobe Acrobat Reader} is required.
%\changes{v1.0}{2021/06/07}{Upgrading v0.6 to v1.0 for publication}
% \section{The main code}
% \begin{macrocode}
\edef\th@dquoteCat{\the\catcode`\"}
\catcode`\"=12\relax
\newif\ifpmdbmode \pmdbmodetrue
% \end{macrocode}
%\subsection{Package options and package requirements}
%
%\leavevmode\IndexOpt{dbmode}^^A
% The default option is \opt{dbmode}. When in effect, check boxes
% appear in the margins at each \cs{pmInput} point.
% \begin{macrocode}
\DeclareOption{dbmode}{\pmdbmodetrue}
% \end{macrocode}
%\leavevmode\IndexOpt[\protect\EXCL]{!dbmode}^^A
% A convenient way to turn off the creation of the check boxes
% is to simply place an exclamation point (!) in front of the \opt{dbmode} option.
% \begin{macrocode}
\DeclareOption{!dbmode}{\pmdbmodefalse}
% \end{macrocode}
%\leavevmode\IndexOpt{tight}^^A
% When this option is taken, the checkboxes are tight against the text box
% area.
% \begin{macrocode}
\newif\ifpmdbtight \pmdbtightfalse
\DeclareOption{tight}{\pmdbtighttrue}
% \end{macrocode}
%\leavevmode\IndexOpt[\protect\EXCL]{!tight}^^A
%The default for the package, the checkboxes are placed
%to extreme left (or right) in the margins.
% \begin{macrocode}
\DeclareOption{!tight}{\pmdbtightfalse}
\ProcessOptions
\RequirePackage{eforms}
% \end{macrocode}
%\subsection{Special attention to Thor}
% One motivation for this package is to support the \pkg{thorshammer} package, to that end
% we make the following assignment, if Thor is not present.
% This is to prevent stoppage:
% if you are inputting a \cs{RespBoxEssay} question that is accompanied by the
% \cs{essayQ} command, defined in \pkg{thorshammer}.
% \begin{macrocode}
\def\pmdb@ckThor{\@ifundefined{essayQ}{\let\essayQ\@gobble}{}}
\AtBeginDocument{\pmdb@ckThor}
% \end{macrocode}
%\subsection{Some switches}
% \textbf{Some Booleans and counters.}
% The \cs{ifpmdbFP} switch is set to true when the path to the resource is a full path; otherwise, it is set to false.
% The \cs{ifpmdbDQs} switch is set to true of double-quotes are detected; otherwise it is false.
% \begin{macrocode}
\newif\ifpmdbFP \pmdbFPfalse
\newif\ifpmdbDQs \pmdbDQsfalse
% \end{macrocode}
%\subsection{Form field creation}
% In version dated 2021/01/03, we introduce a button to edit the resource directly in the default application.
% If can be turned on with \DescribeMacro\editSourceOn\cs{editSourceOn} and off again with \DescribeMacro\editSourceOff
% \cs{editSourceOff}. The default is off. These commands can be placed
% anywhere in the document and affect all subsequent insertions of \cs{cbSelectInput}.
% \changes{v0.6}{2021/01/03}{Added \string\cs{editSourceOn} and \string\cs{editSourceOff}}
% \begin{macrocode}
\newif\ifeditSource \editSourcefalse
\def\editSourceOn{\editSourcetrue}
\def\editSourceOff{\editSourcefalse}
\newcount\pmdb@Cnt
% \end{macrocode}
%
%\subsubsection{Marginal edit source creation}
%
% First up is the design for the edit pushbutton or link annotation.
% \begin{macro}{\editSourceBtn}\hskip-\marginparsep\texttt{[\ameta{options}]\darg{\ameta{wd}}\darg{\ameta{ht}}}
% The button to show the current referenced content in the default application.
% \changes{v0.6}{2021/01/03}{Added \string\cs{editSourceBtn}}
% \begin{macrocode}
\newcommand{\editSourceBtn}[3][]{\def\@editSourceBtn##1{%
\pushButton[\A{/S/Launch/F(##1)}\protect\A#1
]{editPb.\the\pmdb@Cnt}{#2}{#3}}}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\editSourceBtn}\hskip-\marginparsep\texttt{[\ameta{options}]\darg{\ameta{wd}}\darg{\ameta{ht}}\darg{\ameta{txt}}}
% The link version of the button.
% \changes{v0.6}{2021/01/03}{Added \string\cs{editSourceLnk}}
% \begin{macrocode}
\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}}}}}
% \end{macrocode}
% Declare the appearance of this push button and link
% \begin{macrocode}
\editSourceBtn[\TU{View in default editor}\S{S}]{11bp}{11bp}
\editSourceLnk[\linktxtcolor{red}\H{N}]{11bp}{11bp}{E}
% \end{macrocode}
% We provide a control for setting the annot used to edit the source:
% \DescribeMacro\useEditBtn\cs{useEditBtn}, a pushbutton is used;
% \DescribeMacro\useEditLnk\cs{useEditLnk}, a link is used. The default
% is to use a pushbutton.
% \changes{v0.6}{2021/01/03}{Added \string\cs{useEditBtn} and \string\cs{useEditLnk}}
% \begin{macrocode}
\def\useEditBtn{\def\@editSourceBorL{\@editSourceBtn}}
\def\useEditLnk{\def\@editSourceBorL{\@editSourceLnk}}
\useEditBtn
% \end{macrocode}
%\subsubsection{Marginal checkbox creation}
%\DescribeMacro\cbSelectInput\nmpsep{\darg{\ameta{path}}} creates a check box with a tool tip of \ameta{path}
%The mouse up action \cs{ccBoxMU} fixes up relative paths, and defines a \uif{Ctrl+Click} action. When the check box
%is so clicked, the \ameta{path} is opened in the default browser. The \ameta{path} can be relative or absolute.
%This command is used within \cs{insertCkBx}; its \ameta{path} argument is passed to it from \cs{insertCkBx}.
%\changes{v0.6}{2021/01/03}{Added hard wired action to launch the default application.}
% \begin{macrocode}
\def\pmCBPresets#1{\def\pm@CBPresets{#1}}
\pmCBPresets{}
% \end{macrocode}
% Here is the check box that appears in the margins and the edit source button
% \cs{ifeditSource} is true.
% \begin{macrocode}
\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
}
% \end{macrocode}
% \end{macro}
%\leavevmode\DescribeMacro\insertCkBx\nmpsep{\darg{\ameta{method}}}
% The argument of this macro describes the method
%of inserting the checkbox. The default definition works well for a straightforward document, where you are inputting
%ordinary {\LaTeX} code (such as sections or chapters).\smallskip
% \begin{macrocode}
\def\insertCkBx#1{\def\@insertCkBx##1{#1}}
% \end{macrocode}
% Placement of check boxes in the margin. \DescribeMacro\pmAlignCB\cs{pmAlignCB} controls the marginpar placement.
% \DescribeMacro\altCBMargins\cs{altCBMargins} alternates the margin placement, forces the check box to the
% extreme left (on odd pages) and extreme right (on even pages).
% \begin{macrocode}
\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}}
% \end{macrocode}
% This is the default declaration. It works well when you are inputting content
% that goes into horizontal mode. We insert the check box at the beginning of the
% first paragraph. When you are inputting files that come into a list environment, this method
% does not work satisfactory.
%
%\section{\tops{\cs}{\textbackslash}{pmInput} states}
% The switch \cs{ifqzInput} is set to true when \cs{InputQuizItems} is expanded;
% otherwise, it is set to false.
% \begin{macrocode}
\newif\ifqzInput \qzInputfalse
% \end{macrocode}
% \DescribeMacro\InputParas This macro declares that the next \cs{pmInput} macros are for paragraph content.
%This is the default state of the package.
% \begin{macrocode}
\def\InputParas{\global\qzInputfalse
\insertCkBx{\ifpmdbmode
\everypar{\marginpar{\pmAlignCB
\cbSelectInput{##1}}\global\everypar{}}\fi}}
% \end{macrocode}
% Set the default to be \cs{InputParas}
% \begin{macrocode}
\InputParas
% \end{macrocode}
% The \DescribeMacro\InputProbs\cs{InputProbs} is a command that declares
% the next \cs{pmInput} is for questions for an \pkg{eqexam}
% document. Currently this command is still under development.
% \begin{macrocode}
\def\InputProbs{\global\qzInputfalse
\insertCkBx{\ifpmdbmode
\def\prior@questionsHook{\marginpar
{\pmAlignCB\cbSelectInput{##1}}}\fi}}
% \end{macrocode}
%\leavevmode
%\DescribeMacro\InputQuizItems The macro declares that the next \cs{pmInput} is for items in
%a \env{quiz} environment of \pkg{exerquiz}
%\changes{v0.4}{2019/12/09}{Modified to work when no points are specified}
% \begin{macrocode}
\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}}
% \end{macrocode}
%\leavevmode
%\DescribeMacro\InputItems This command declares that the next \cs{pmInput} macros are for items in
%an list environment 2019/12/09 v0.4
%\changes{v0.4}{2019/12/09}{Added \string\cs{InputItems}}
% \begin{macrocode}
\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}}
% \end{macrocode}
%
%\paragraph*{Place checkbox and input \ameta{path}}\leavevmode\par\medskip
%\noindent
%\DescribeMacro\ckBxInput\nmpsep{\darg{\ameta{path}}} Places the check box and inputs the \ameta{path}.
% \begin{macrocode}
\let\pmHook\relax
\def\ckBxInput#1{\@insertCkBx{#1}%
\ifpmdbDQs\def\donext{\pmHook\input{"#1"}}\else
\def\donext{\pmHook\input{#1}}\fi
\donext}
% \end{macrocode}
%\subsection{Other pushbutton creations}
%This package provides two form fields that are used for the DB step.\par\medskip
%\noindent
%\DescribeMacro\displayChoices\nmpsep{[\ameta{options}]\darg{\ameta{wd}}\darg{\ameta{ht}}} inserts a push button
%whose action is to display the selections in the console window. The argument \ameta{wd} can be empty, in which
%case, the width of the field is determined from the \cs{CA} key.
% \begin{macrocode}
\newcommand{\displayChoices}[3][]{\pushButton[\TU{\displayChoice@TU}
\CA{\displayChoice@CA}#1\AAmouseup{\sldInputs}\protect\AA
]{sldInputs}{#2}{#3}}
% \end{macrocode}
% Easy access to the \cs{CA} and \cs{TU} keys, for language localization, are provided.
% These are \DescribeMacro\displayChoiceCA\cs{displayChoiceCA\darg{\ameta{text}}} and
% \DescribeMacro\displayChoiceTU\cs{displayChoiceTU\darg{\ameta{text}}}.
% \begin{macrocode}
\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}
% \end{macrocode}
%\DescribeMacro\clrChoices\nmpsep{[\ameta{options}]\darg{\ameta{wd}}\darg{\ameta{ht}}} inserts a push button
% whose action is to clear all check boxes (and underlying JavaScript variables) created by this package.
% The argument \ameta{wd} can be empty, in which
% case, the width of the field is determined from the \cs{CA} key.
% \begin{macrocode}
\newcommand{\clrChoices}[3][]{\pushButton[\TU{\clrChoices@TU}
\CA{\clrChoices@CA}#1\AAmouseup{\clrAction}\protect\AA
]{Inputs}{#2}{#3}}
% \end{macrocode}
% Easy access to the \cs{CA} and \cs{TU} keys, for language localization, are provided.
% These are \DescribeMacro\clrChoicesCA\cs{clrChoicesCA\darg{\ameta{text}}} and
% \DescribeMacro\clrChoicesTU\cs{clrChoicesTU\darg{\ameta{text}}}.
% \begin{macrocode}
\def\clrChoicesCA#1{\def\clrChoices@CA{#1}}
\def\clrChoicesTU#1{\def\clrChoices@TU{#1}}
% \end{macrocode}
% The default declarations for these two.
% \begin{macrocode}
\clrChoicesCA{Clear Choices}
\clrChoicesTU{Clear all check boxes created by pmdb}
% \end{macrocode}
%
%\subsection{Defining the \tops{\protect\cs}{}{pmInput} command}
%
%\DescribeMacro\pmInput\nmpsep{*[\ameta{arg}]\darg{\ameta{path}}} is the main user-interface for inputting a file; here,
%the macro's name is \cs{pmInput}, ultimately it calls \cs{input} with the same path. Paths with spaces
%must be enclosed in double quotes (|\pmInput{my cool problem.tex}|) and the extensions must always be used.
%It the \texttt* option is specified, \cs{pmInput} gobbles up all remaining arguments and does nothing otherwise.
%The optional argument \ameta{arg} is only obeyed when \cs{InputItems} is in affect; it is passed on to
%the underlying \cs{item}, as in \cs{item[\ameta{arg}]}. The \ameta{path} argument is the path to the content to be input;
%if the \ameta{path} contains spaces, then the path must be enclosed in double quotes (\texttt{"my cool path/file.tex"}).
% \begin{macrocode}
\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;;}
% \end{macrocode}
% Determine if double quotation marks are used.
% \begin{macrocode}
\def\inputConti{\@ifnextchar"%
{\global\pmdbDQstrue\removedqs}
{\global\pmdbDQsfalse\removesemis}}
\def\removedqs"#1";;{\inputContii{#1}}
\def\removesemis#1;;{\inputContii{#1}}
% \end{macrocode}
% Determine if this is a full path, we do this by searching for a colon (\texttt:).
% Following the search for the colon, pass on to the final step of \cs{doinput}.
% \begin{macrocode}
\def\inputContii#1{\isItFullPath#1:\@nil\doinput{#1}}
% \end{macrocode}
% A command to detect presence of a colon.
% \begin{macrocode}
\def\isItFullPath#1:#2\@nil{%
\def\@rgii{#2}\ifx\@rgii\@empty
\global\pmdbFPfalse\else
\global\pmdbFPtrue\fi}
% \end{macrocode}
% Final step, if the switch \cs{ifpmdbmode} is true, we insert the check box
% \cs{ckBxInput}; otherwise, we pass \ameta{path} to \cs{input}.
% \begin{macrocode}
\def\doinput#1{\ifpmdbmode\def\donext{\ckBxInput{#1}}\else
\ifpmdbDQs\def\donext{\input{"#1"}}\else
\def\donext{\input{#1}}\fi\fi
\donext}
% \end{macrocode}
% During the development of this package, the original command name used was \cs{Input}.
% There are a few users that use this old definition; the command \cs{Input} is defined
% in other package, in particular in the \pkg{srcltx}. So we allow the use of \cs{Input}
% if \cs{Input} is not otherwise defined.
% \begin{macrocode}
\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}
% \end{macrocode}
%
% \section{Field JavaScript}
% \leavevmode
%\DescribeMacro\ccBoxMU
% This is the JavaScript action of the check box, used in \cs{cbSelectInput}
% This code uses two parameters \cs{p(1)=\ameta{path}} and \cs{p(2)=\ameta{cnt}} (|\the\pmdb@Cnt|).
% \begin{macrocode}
\begin{defineJS}[\makeesc\@\makecmt\%]{\ccBoxMU}
@ifpmdbFP%
event.target.userName=("@p(1)");
@else%
% \end{macrocode}
% This part of the code is Windows specific. Don't know enough about Mac OS
% to form the proper path.
% \begin{macrocode}
// device independent path
var pos=this.path.lastIndexOf("/");
var thispath=this.path.substring(0,pos+1);
% \end{macrocode}
% \enspace|/<drive>/user/documents/.../myfolder/|
% \begin{macrocode}
pos=thispath.indexOf("/",1);
var drive=thispath.substring(1,pos);
var platform=app.platform;
% \end{macrocode}
% \uif{Windows} platform
% \begin{macrocode}
if (platform=="WIN")
% \end{macrocode}
% \enspace|<drive>:/user/documents/.../myfolder/|
% \begin{macrocode}
thispath=drive+":/"+thispath.substring(pos+1);
% \end{macrocode}
% \uif{MacOS} platform: I'm not familiar with the \uif{MacOS} file system, so we'll just
% assume it is the same as with Windows.
% \begin{macrocode}
if (platform=="MAC")
% \end{macrocode}
% \enspace|<drive>/user/documents/.../myfolder/|
% \begin{macrocode}
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.");
}
% \end{macrocode}
% (2020/04/29) Add a shift event for quizzes.
% \changes{v0.5}{2020/04/29}{Added \string\texttt{event.shift} for quizzes}
% \begin{macrocode}
}
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}
% \end{macrocode}
%\leavevmode
%\DescribeMacro\sldInputs
% This is the mouse up action for a push button. It lists all selected content
% and displays them in the console window of \app{Acrobat/Reader}, used in
% \cs{displayChoices}.
% \begin{macrocode}
\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}
% \end{macrocode}
%\leavevmode
%\DescribeMacro\clrAction
% Mouse up action to clear the checkboxes and to re-initialize internal
% internal JS variables. Used in \cs{clrChoices}.
% \begin{macrocode}
\begin{defineJS}{\clrAction}
var _oSPaths=new Object;
var _aInputs=new Array;
var _numInputs=0;
this.resetForm("pmdbCkBx");
\end{defineJS}
% \end{macrocode}
% \section{Document JavaScript}
% \begin{macrocode}
\begin{insDLJS}{mrki}{Supporting JavaScript for pmdb}
var _oSPaths=new Object;
var _aInputs=new Array;
var _numInputs=0;
\end{insDLJS}
% \end{macrocode}
% \begin{macrocode}
\catcode`\"=\th@dquoteCat
%</package>
% \end{macrocode}
%\Finale
|