Debian Codegraph @

texmf-dist/doc/latex/termsim/termsim-doc-en.tex

raw
1 \documentclass{ctxdoc}
2 \usepackage{minted}
3 \usepackage{listings}
4 \usepackage{xcolor}
5 \usepackage{xcolor-material}
6 \usepackage{termsim}
7
8 \NewDocumentCommand{\init}{+v}{\hspace{\fill}Init~=~\textcolor{blue}{\bfseries#1}}
9 \DeclareDocumentCommand\opt{m}{\texttt{#1}}
10 \DeclareDocumentCommand\kvopt{mm}
11 {\texttt{#1\breakablethinspace=\breakablethinspace#2}}
12 \def\breakablethinspace{\hskip 0.16667em\relax}
13
14 \title{\bfseries\pkg{termsim}: terminal simulation pachage}
15 \author{nangeng\\ \url{[email protected]}}
16 \date{2021/12/26\qquad v1.1.1\thanks{\url{https://github.com/registor/termsim}}\thanks{\url{https://gitee.com/nwafu_nan/termsim}}}
17
18 \begin{document}
19
20 \maketitle
21
22 \begin{abstract}
23
24 The \pkg{termsim} is a \pkg{tcolorbox}-based package developed with \LaTeX3,
25 which provides a \env{terminal} environment and a \tn{termfile} macro for simulationg
26 terminal in Win10, Mac or Ubuntu with dark, light or white color theme.
27 The \env{terminal} environment creates terminal with it's body and
28 the \tn{termfile} macro is used to read in the specified file and output it in the simulated terminal.
29 The starred \env{terminal*} environment and \tn{termfile*} macro are also provided
30 to simulate a terminal with comments at the bottom of terminal.
31 All style and color theme can be setted by \tn{termset} macro
32 or environment's and macro's key-value options.
33
34 \end{abstract}
35
36 \tableofcontents
37
38 \section{Introduction}
39
40 \pkg{termsim} is an \LaTeX package for simulating Win10, Mac or Ubuntu
41 terminal with dark, light or white color theme.
42
43 \section{Interface}
44
45 \subsection{\env{terminal} and \env{terminal*} environment}
46
47 \begin{function}[added=2021-12-17,updated=2021-12-17]{terminal,terminal*}
48 \begin{syntax}
49 \tn{begin}\{terminal\} \oarg{options} \Arg{terminal title}
50 .....
51 \tn{end}\{terminal\}
52
53 \tn{begin}\{terminal*\} \oarg{options} \oarg{comments} \Arg{terminal title}
54 .....
55 \tn{end}\{terminal*\}
56 \end{syntax}
57
58 Typesetting terminal with environment body.
59 You can set the title for the terminal by using \Arg{terminal title}.
60
61 The appearance of the terminal is set by key-value in \oarg{options}.
62
63 The starred environment \texttt{terminal*} is used to add comments at the bottom of terminal,
64 note that this needs to be done with \oarg{comments} after \oarg{options}.
65
66 Of course the key-value \oarg{options} can alse be set
67 via the comma-separated key-value list of the \tn{termset} macro.
68
69 \end{function}
70 \begin{Verbatim}[frame=none,numbers=left,gobble=5]
71 \centering
72 \termset{os=win10,theme=dark,shstretch=1.0}
73 \bgin{terminal}{terminal title}
74 Volume in drive C is SSD_files
75 Volume Serial Number is 0001-C78B
76
77 Directory of C:\Users\Administrator
78
79 2018/07/21 15:39 <DIR> .
80 2018/07/21 15:39 <DIR> ..
81 2018/07/13 08:35 <DIR> 3D Objects
82 2018/07/13 08:35 <DIR> Contacts
83 2018/08/06 07:46 <DIR> Desktop
84 2 File(s) 6,029,312 bytes
85 18 Dir(s) 14,035,107,840 bytes free
86 \end{terminal}
87 \end{Verbatim}
88
89 \begin{center}
90 \begin{minipage}{0.85\textwidth}
91 \termset{os=win10,theme=dark,shstretch=1.0}
92 \begin{terminal}{terminal title}
93 Volume in drive C is SSD_files
94 Volume Serial Number is 0001-C78B
95 Directory of C:\Users\Administrator
96 2018/07/21 15:39 <DIR> .
97 2018/07/21 15:39 <DIR> ..
98 2018/07/13 08:35 <DIR> 3D Objects
99 2018/07/13 08:35 <DIR> Contacts
100 2018/08/06 07:46 <DIR> Desktop
101 2 File(s) 6,029,312 bytes
102 18 Dir(s) 14,035,107,840 bytes free
103 \end{terminal}
104 \end{minipage}
105 \end{center}
106
107 \subsection{\tn{termfile} and \tn{termfile*} macro}
108
109 \begin{function}[added=2021-12-18,updated=2021-12-18]{\termfile,\termfile*}
110 \begin{syntax}
111 \tn{termfile} \oarg{options} \Arg{terminal title} \Arg{contents file}
112 \tn{termfile*} \oarg{options} \oarg{comments} \Arg{terminal title} \Arg{contentes file}
113 \end{syntax}
114
115 Typesetting terminal from a file.
116 You can set the title for the terminal by using \Arg{terminal title}.
117
118 The appearance of the terminal is set by key-value in \oarg{options}.
119
120 The starred macro \texttt{termfile*} is used to add comments at the bottom of terminal,
121 note that this needs to be done with \oarg{comments} after \oarg{options}.
122
123 Of course the key-value \oarg{options} can alse be set
124 via the comma-separated key-value list of the \tn{termset} macro.
125 \end{function}
126
127 \newpage
128
129 \begin{Verbatim}[frame=none,numbers=left,gobble=5]
130 \centering
131 \termfile{terminal title}{test.bat}
132 \end{Verbatim}
133
134 \begin{center}
135 \begin{minipage}{0.85\textwidth}
136 \termfile{terminal title}{test.bat}
137 \end{minipage}
138 \end{center}
139
140 \subsection{\tn{termset} macro}
141
142 \begin{function}[added=2021-12-18,updated=2021-12-18]{\termset}
143 \begin{syntax}
144 \tn{termset} \marg{key-values}
145 \end{syntax}
146 The arguments to \tn{termset} are a set of options separated by commas
147 in the form \kvopt{\meta{key}}{\meta{value}}.
148 The \meta{value} of some options can be omitted.
149 For the same option, subsequent settings will override previous settings.
150
151 Most options was initialized with default values.
152
153 \tn{termset} uses \LaTeX3 style key settings,
154 supporting different types and multiple levels of option settings.
155 In the \kvopt{\meta{key}}{\meta{value}} list, the spaces around "|=|"
156 do not affect anything; However, it should be noted that \textbf{no blank lines}
157 are allowed in the list.
158 The "|= true|" in the parameter \kvopt{\meta{option}}{true} for the Boolean type can be omitted.
159
160 \end{function}
161
162 \section{Options}
163
164 The \pkg{termsim} package provides a number of options to set the style of the terminal.
165 The following options can be set with \tn{termset} macro.
166 Also, these options can be set with the \env{terminal}(\env{terminal*}) environment's
167 or the \tn{termfile}(\tn{termfile*}) command's \oarg{options}.
168
169 \subsection{shell code engine}
170
171 \begin{function}[added=2021-12-18,updated=2021-12-18]{minted}
172 \begin{syntax}
173 minted = <\TTF> \init{true}
174 \end{syntax}
175 \opt{minted} is used to set shell code engine, if it is \textbf{true} then
176 the \pkg{minted} package is used, if it is \textbf{false} then
177 the \pkg{listings} package is used. The default value is \textbf{true}.
178 \end{function}
179
180 \subsection{os type}
181
182 \begin{function}[added=2021-12-18,updated=2021-12-18]{os}
183 \begin{syntax}
184 os = <win10|mac|ubuntu> \init{win10}
185 \end{syntax}
186 \opt{os} is used to set Operating System type. The default value is \textbf{win10}.
187 \end{function}
188
189 \subsection{color theme}
190
191 \begin{function}[added=2021-12-18,updated=2021-12-18]{theme}
192 \begin{syntax}
193 theme = <dark|light|white> \init{dark}
194 \end{syntax}
195 \opt{theme} is used to set terminal color theme. The default value is \textbf{dark}.
196 \end{function}
197
198 \subsection{shell code style}
199
200 \begin{function}[added=2021-12-18,updated=2021-12-18]{shstyle}
201 \begin{syntax}
202 shstyle = \Arg{style} \init{bw}
203 \end{syntax}
204 \opt{shstyle} is used to set shell code style, valid only for the \pkg{minted} engine.
205 The default value is \textbf{bw}.
206 \end{function}
207
208 \subsection{shell code fontsize}
209
210 \begin{function}[added=2021-12-18,updated=2021-12-18]{shsize}
211 \begin{syntax}
212 shsize = \Arg{fontsize} \init{\small}
213 \end{syntax}
214 \opt{shsize} is used to set shell code fontsize, valid only for \pkg{minted} engine.
215 The default value is\textbf{\tn{small}}.
216 \end{function}
217
218 \subsection{comment format}
219
220 \begin{function}[added=2021-12-18,updated=2021-12-18]{commentf}
221 \begin{syntax}
222 commentf = \Arg{format group} \init{\small\sffamily}
223 \end{syntax}
224 \opt{commentf} is used to set comment format at terminal bottom.
225 The default value is \textbf{\tn{small}\tn{sffamily}}.
226 \end{function}
227
228 \subsection{shell code baseline stretch}
229
230 \begin{function}[added=2021-12-18,updated=2021-12-18]{shstretch}
231 \begin{syntax}
232 shstretch = \Arg{float number} \init{1.0}
233 \end{syntax}
234 \opt{shstretch} is used to set shell code baseline stretch, valid only for \pkg{minted} engine.
235 The default value is\textbf{1.0}.
236 \end{function}
237
238 \newpage
239
240 \section{Examples}
241
242 The \pkg{termsim} package can be used in situations
243 where the operating system terminal window needs to be typeset
244 to avoid the use of screenshots.
245 Terminal windows can be with or without underline comments
246 and can be dark, light or white color themes.
247
248 \subsection{Win10 terminal}
249
250 \subsubsection{\env{terminal} or \env{terminal*} environment}
251
252 \begin{Verbatim}[frame=none,numbers=left,gobble=5]
253 \centering
254 \termset{os=win10,theme=dark,shstretch=1.0}
255 \begin{terminal}{terminal title}
256 Volume in drive C is SSD_files
257 Volume Serial Number is 0001-C78B
258 Directory of C:\Users\Administrator
259 2018/07/21 15:39 <DIR> .
260 2018/07/21 15:39 <DIR> ..
261 2018/07/13 08:35 <DIR> 3D Objects
262 2018/07/13 08:35 <DIR> Contacts
263 2018/08/06 07:46 <DIR> Desktop
264 2 File(s) 6,029,312 bytes
265 18 Dir(s) 14,035,107,840 bytes free
266 \end{terminal}
267 \end{Verbatim}
268
269 \begin{center}
270 \begin{minipage}{0.85\textwidth}
271 \termset{os=win10,theme=dark,shstretch=1.0}
272 \begin{terminal}{terminal title}
273 Volume in drive C is SSD_files
274 Volume Serial Number is 0001-C78B
275 Directory of C:\Users\Administrator
276 2018/07/21 15:39 <DIR> .
277 2018/07/21 15:39 <DIR> ..
278 2018/07/13 08:35 <DIR> 3D Objects
279 2018/07/13 08:35 <DIR> Contacts
280 2018/08/06 07:46 <DIR> Desktop
281 2 File(s) 6,029,312 bytes
282 18 Dir(s) 14,035,107,840 bytes free
283 \end{terminal}
284 \end{minipage}
285 \end{center}
286
287 \begin{Verbatim}[frame=none,numbers=left,gobble=5]
288 \centering
289 \begin{terminal*}[os=win10,theme=light][comment text]{terminal title}
290 Volume in drive C is SSD_files
291 Volume Serial Number is 0001-C78B
292 Directory of C:\Users\Administrator
293 2018/07/21 15:39 <DIR> .
294 2018/07/21 15:39 <DIR> ..
295 2018/07/13 08:35 <DIR> 3D Objects
296 2018/07/13 08:35 <DIR> Contacts
297 2018/08/06 07:46 <DIR> Desktop
298 2 File(s) 6,029,312 bytes
299 18 Dir(s) 14,035,107,840 bytes free
300 \end{terminal*}
301 \end{Verbatim}
302
303 \begin{center}
304 \begin{minipage}{0.85\textwidth}
305 \begin{terminal*}[os=win10,theme=light][comment text]{terminal title}
306 Volume in drive C is SSD_files
307 Volume Serial Number is 0001-C78B
308 Directory of C:\Users\Administrator
309 2018/07/21 15:39 <DIR> .
310 2018/07/21 15:39 <DIR> ..
311 2018/07/13 08:35 <DIR> 3D Objects
312 2018/07/13 08:35 <DIR> Contacts
313 2018/08/06 07:46 <DIR> Desktop
314 2 File(s) 6,029,312 bytes
315 18 Dir(s) 14,035,107,840 bytes free
316 \end{terminal*}
317 \end{minipage}
318 \end{center}
319
320 \subsubsection{\tn{termfile} or \tn{termfile*} macro}
321
322 \begin{Verbatim}[frame=none,numbers=left]
323 \centering
324 \termset{os=win10,theme=dark}
325 \termfile{terminal title}{test.bat}
326 \end{Verbatim}
327
328 \begin{center}
329 \begin{minipage}{0.85\textwidth}
330 \termset{os=win10,theme=dark}
331 \termfile{terminal title}{test.bat}
332 \end{minipage}
333 \end{center}
334
335 \begin{Verbatim}[frame=none,numbers=left]
336 \centering
337 \termfile*[os=win10,theme=light][comment text]{terminal title}{test.bat}
338 \end{Verbatim}
339
340 \begin{center}
341 \begin{minipage}{0.85\textwidth}
342 \termfile*[os=win10,theme=light][comment text]{terminal title}{test.bat}
343 \end{minipage}
344 \end{center}
345
346 \newpage
347 \subsection{Mac terminal}
348
349 \subsubsection{\env{terminal} or \env{terminal*} environment}
350
351 \begin{Verbatim}[frame=none,numbers=left,gobble=5]
352 \centering
353 \termset{os=mac,theme=dark}
354 \begin{terminal}{terminal title}
355 xxxxxx@xxxxxx-lap:~$ ls
356 Desktop Downloads p2 Public Templates Videos
357 Documents Music Pictures snap '#test#' workspace
358 xxxxxx@xxxxxx-lap:~$
359 \end{terminal}
360 \end{Verbatim}
361
362 \begin{center}
363 \begin{minipage}{0.85\textwidth}
364 \termset{os=mac,theme=dark}
365 \begin{terminal}{terminal title}
366 xxxxxx@xxxxxx-lap:~$ ls
367 Desktop Downloads p2 Public Templates Videos
368 Documents Music Pictures snap '#test#' workspace
369 xxxxxx@xxxxxx-lap:~$
370 \end{terminal}
371 \end{minipage}
372 \end{center}
373
374 \begin{Verbatim}[frame=none,numbers=left,gobble=5]
375 \centering
376 \begin{terminal*}[os=mac,theme=light][comment text]{terminal title}
377 xxxxxx@xxxxxx-lap:~$ ls
378 Desktop Downloads p2 Public Templates Videos
379 Documents Music Pictures snap '#test#' workspace
380 xxxxxx@xxxxxx-lap:~$
381 \end{terminal*}
382 \end{Verbatim}
383
384 \begin{center}
385 \begin{minipage}{0.85\textwidth}
386 \begin{terminal*}[os=mac,theme=light][comment text]{terminal title}
387 xxxxxx@xxxxxx-lap:~$ ls
388 Desktop Downloads p2 Public Templates Videos
389 Documents Music Pictures snap '#test#' workspace
390 xxxxxx@xxxxxx-lap:~$
391 \end{terminal*}
392 \end{minipage}
393 \end{center}
394
395 \subsubsection{\tn{termfile} or \tn{termfile*} macro}
396
397 \begin{Verbatim}[frame=none,numbers=left]
398 \centering
399 \termset{os=mac,theme=dark}
400 \termfile{terminal title}{testls}
401 \end{Verbatim}
402
403 \begin{center}
404 \begin{minipage}{0.85\textwidth}
405 \termset{os=mac,theme=dark}
406 \termfile{terminal title}{testls}
407 \end{minipage}
408 \end{center}
409 \newpage
410 \begin{Verbatim}[frame=none,numbers=left]
411 \centering
412 \termfile*[os=mac,theme=light][comment text]{terminal title}{testls}
413 \end{Verbatim}
414
415 \begin{center}
416 \begin{minipage}{0.85\textwidth}
417 \termfile*[os=mac,theme=light][comment text]{terminal title}{testls}
418 \end{minipage}
419 \end{center}
420
421 \subsection{Ubuntu terminal}
422
423 \subsubsection{\env{terminal} or \env{terminal*} environment}
424
425 \begin{Verbatim}[frame=none,numbers=left,gobble=5]
426 \centering
427 \termset{os=ubuntu,theme=dark}
428 \begin{terminal}{terminal title}
429 xxxxxx@xxxxxx-lap:~/Desktop $
430 git clone [email protected]:xxxxxx/xxxxxx
431 Cloning into 'xxxxxx'...
432 remote: Enumerating objects: 106, done.
433 remote: Counting objects: 100% (106/106), done.
434 remote: Compressing objects: 100% (105/105), done.
435 remote: Total 106 (delta 9), reused 0 (delta 0)
436 Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
437 Resolving delta: 100% (9/9), done.
438 Unpacking: 100% (75/75), done.
439 xxxxxx@xxxxxx-lap:~/Desktop $
440 \end{terminal}
441 \end{Verbatim}
442
443 \begin{center}
444 \begin{minipage}{0.85\textwidth}
445 \termset{os=ubuntu,theme=dark}
446 \begin{terminal}{terminal title}
447 xxxxxx@xxxxxx-lap:~/Desktop $
448 git clone [email protected]:xxxxxx/xxxxxx
449 Cloning into 'xxxxxx'...
450 remote: Enumerating objects: 106, done.
451 remote: Counting objects: 100% (106/106), done.
452 remote: Compressing objects: 100% (105/105), done.
453 remote: Total 106 (delta 9), reused 0 (delta 0)
454 Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
455 Resolving delta: 100% (9/9), done.
456 Unpacking: 100% (75/75), done.
457 xxxxxx@xxxxxx-lap:~/Desktop $
458 \end{terminal}
459 \end{minipage}
460 \end{center}
461
462 \begin{Verbatim}[frame=none,numbers=left,gobble=5]
463 \centering
464 \begin{terminal*}[os=ubuntu,theme=light][comment text]{terminal title}
465 xxxxxx@xxxxxx-lap:~/Desktop $
466 git clone [email protected]:xxxxxx/xxxxxx
467 Cloning into 'xxxxxx'...
468 remote: Enumerating objects: 106, done.
469 remote: Counting objects: 100% (106/106), done.
470 remote: Compressing objects: 100% (105/105), done.
471 remote: Total 106 (delta 9), reused 0 (delta 0)
472 Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
473 Resolving delta: 100% (9/9), done.
474 Unpacking: 100% (75/75), done.
475 xxxxxx@xxxxxx-lap:~/Desktop $
476 \end{terminal*}
477 \end{Verbatim}
478 \newpage
479 \begin{center}
480 \begin{minipage}{0.85\textwidth}
481 \begin{terminal*}[os=ubuntu,theme=light][comment text]{terminal title}
482 xxxxxx@xxxxxx-lap:~/Desktop $
483 git clone [email protected]:xxxxxx/xxxxxx
484 Cloning into 'xxxxxx'...
485 remote: Enumerating objects: 106, done.
486 remote: Counting objects: 100% (106/106), done.
487 remote: Compressing objects: 100% (105/105), done.
488 remote: Total 106 (delta 9), reused 0 (delta 0)
489 Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
490 Resolving delta: 100% (9/9), done.
491 Unpacking: 100% (75/75), done.
492 xxxxxx@xxxxxx-lap:~/Desktop $
493 \end{terminal*}
494 \end{minipage}
495 \end{center}
496
497 \subsubsection{\tn{termfile} or \tn{termfile*} macro}
498
499 \begin{Verbatim}[frame=none,numbers=left]
500 \centering
501 \termset{os=ubuntu,theme=dark}
502 \termfile{terminal title}{testsh}
503 \end{Verbatim}
504
505 \begin{center}
506 \begin{minipage}{0.85\textwidth}
507 \termset{os=ubuntu,theme=dark}
508 \termfile{terminal title}{testsh}
509 \end{minipage}
510 \end{center}
511
512 \begin{Verbatim}[frame=none,numbers=left]
513 \centering
514 \termfile*[os=ubuntu,theme=light][comment text]{terminal title}{testsh}
515 \end{Verbatim}
516
517 \begin{center}
518 \begin{minipage}{0.85\textwidth}
519 \termfile*[os=ubuntu,theme=light][comment text]{terminal title}{testsh}
520 \end{minipage}
521 \end{center}
522
523 You can also use the white color theme and
524 use black text on a white background for print on paper.
525
526 \begin{Verbatim}[frame=none,numbers=left,gobble=5]
527 \centering
528 \termset{os=ubuntu,theme=white}
529 \begin{terminal}{terminal title}
530 xxxxxx@xxxxxx-lap:~/Desktop $
531 git clone [email protected]:xxxxxx/xxxxxx
532 Cloning into 'xxxxxx'...
533 remote: Enumerating objects: 106, done.
534 remote: Counting objects: 100% (106/106), done.
535 remote: Compressing objects: 100% (105/105), done.
536 remote: Total 106 (delta 9), reused 0 (delta 0)
537 Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
538 Resolving delta: 100% (9/9), done.
539 Unpacking: 100% (75/75), done.
540 xxxxxx@xxxxxx-lap:~/Desktop $
541 \end{terminal}
542 \end{Verbatim}
543
544 \begin{center}
545 \begin{minipage}{0.85\textwidth}
546 \termset{os=ubuntu,theme=white}
547 \begin{terminal}{terminal title}
548 xxxxxx@xxxxxx-lap:~/Desktop $
549 git clone [email protected]:xxxxxx/xxxxxx
550 Cloning into 'xxxxxx'...
551 remote: Enumerating objects: 106, done.
552 remote: Counting objects: 100% (106/106), done.
553 remote: Compressing objects: 100% (105/105), done.
554 remote: Total 106 (delta 9), reused 0 (delta 0)
555 Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
556 Resolving delta: 100% (9/9), done.
557 Unpacking: 100% (75/75), done.
558 xxxxxx@xxxxxx-lap:~/Desktop $
559 \end{terminal}
560 \end{minipage}
561 \end{center}
562
563 \end{document}