summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/termsim/termsim-doc-en.tex
blob: 7616e696f4d94081fad346ae4501c225ad4d7918 (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
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
\documentclass{ctxdoc}
\usepackage{minted}
\usepackage{listings}
\usepackage{xcolor}
\usepackage{xcolor-material}
\usepackage{termsim}

\NewDocumentCommand{\init}{+v}{\hspace{\fill}Init~=~\textcolor{blue}{\bfseries#1}}
\DeclareDocumentCommand\opt{m}{\texttt{#1}}
\DeclareDocumentCommand\kvopt{mm}
  {\texttt{#1\breakablethinspace=\breakablethinspace#2}}
\def\breakablethinspace{\hskip 0.16667em\relax}

 \title{\bfseries\pkg{termsim}: terminal simulation pachage}
 \author{nangeng\\ \url{nangeng@nwafu.edu.cn}}
 \date{2021/12/26\qquad v1.1.1\thanks{\url{https://github.com/registor/termsim}}\thanks{\url{https://gitee.com/nwafu_nan/termsim}}}

\begin{document}

 \maketitle

 \begin{abstract}

 The \pkg{termsim} is a \pkg{tcolorbox}-based package developed with \LaTeX3,
 which provides a \env{terminal} environment and a \tn{termfile} macro for simulationg
 terminal in Win10, Mac or Ubuntu with dark, light or white color theme.
 The \env{terminal} environment creates terminal with it's body and
 the \tn{termfile} macro is used to read in the specified file and output it in the simulated terminal.
 The starred \env{terminal*} environment and \tn{termfile*} macro are also provided
 to simulate a terminal with comments at the bottom of terminal.
 All style and color theme can be setted by \tn{termset} macro
 or environment's and macro's key-value options.

 \end{abstract}

 \tableofcontents

 \section{Introduction}

 \pkg{termsim} is an \LaTeX package for simulating Win10, Mac or Ubuntu
 terminal with dark, light or white color theme.

 \section{Interface}

 \subsection{\env{terminal} and \env{terminal*} environment}

 \begin{function}[added=2021-12-17,updated=2021-12-17]{terminal,terminal*}
   \begin{syntax}
     \tn{begin}\{terminal\} \oarg{options} \Arg{terminal title}
     .....
     \tn{end}\{terminal\}

     \tn{begin}\{terminal*\} \oarg{options} \oarg{comments} \Arg{terminal title}
     .....
     \tn{end}\{terminal*\}
   \end{syntax}

   Typesetting terminal with environment body.
   You can set the title for the terminal by using \Arg{terminal title}.

   The appearance of the terminal is set by key-value in \oarg{options}.

   The starred environment \texttt{terminal*} is used to add comments at the bottom of terminal,
   note that this needs to be done with \oarg{comments} after \oarg{options}.

   Of course the key-value \oarg{options} can alse be set 
   via the comma-separated key-value list of the \tn{termset} macro.

 \end{function}
   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
     \centering
     \termset{os=win10,theme=dark,shstretch=1.0}
     \bgin{terminal}{terminal title}
       Volume in drive C is SSD_files
       Volume Serial Number is 0001-C78B

       Directory of C:\Users\Administrator

       2018/07/21  15:39    <DIR>          .
       2018/07/21  15:39    <DIR>          ..
       2018/07/13  08:35    <DIR>          3D Objects
       2018/07/13  08:35    <DIR>          Contacts
       2018/08/06  07:46    <DIR>          Desktop
                       2 File(s)      6,029,312 bytes
                  18 Dir(s) 14,035,107,840 bytes free
     \end{terminal}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termset{os=win10,theme=dark,shstretch=1.0}
\begin{terminal}{terminal title}
    Volume in drive C is SSD_files
    Volume Serial Number is 0001-C78B
    Directory of C:\Users\Administrator
  2018/07/21  15:39    <DIR>          .
  2018/07/21  15:39    <DIR>          ..
  2018/07/13  08:35    <DIR>          3D Objects
  2018/07/13  08:35    <DIR>          Contacts
  2018/08/06  07:46    <DIR>          Desktop
                  2 File(s)      6,029,312 bytes
             18 Dir(s) 14,035,107,840 bytes free
\end{terminal}
\end{minipage}
\end{center}

 \subsection{\tn{termfile} and \tn{termfile*} macro}

 \begin{function}[added=2021-12-18,updated=2021-12-18]{\termfile,\termfile*}
   \begin{syntax}
     \tn{termfile}  \oarg{options} \Arg{terminal title} \Arg{contents file}
     \tn{termfile*} \oarg{options} \oarg{comments} \Arg{terminal title} \Arg{contentes file}
   \end{syntax}

   Typesetting terminal from a file.
   You can set the title for the terminal by using \Arg{terminal title}.

   The appearance of the terminal is set by key-value in \oarg{options}.

   The starred macro \texttt{termfile*} is used to add comments at the bottom of terminal,
   note that this needs to be done with \oarg{comments} after \oarg{options}.

   Of course the key-value \oarg{options} can alse be set
   via the comma-separated key-value list of the \tn{termset} macro.
 \end{function}

 \newpage

   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
     \centering
     \termfile{terminal title}{test.bat}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termfile{terminal title}{test.bat}
\end{minipage}
\end{center}

\subsection{\tn{termset} macro}

 \begin{function}[added=2021-12-18,updated=2021-12-18]{\termset}
   \begin{syntax}
     \tn{termset} \marg{key-values}
   \end{syntax}
   The arguments to \tn{termset} are a set of options separated by commas
   in the form \kvopt{\meta{key}}{\meta{value}}.
   The \meta{value} of some options can be omitted.
   For the same option, subsequent settings will override previous settings.

   Most options was initialized with default values.

   \tn{termset}  uses \LaTeX3 style key settings,
   supporting different types and multiple levels of option settings.
   In the \kvopt{\meta{key}}{\meta{value}} list, the spaces around "|=|"
   do not affect anything; However, it should be noted that \textbf{no blank lines}
   are allowed in the list.
   The "|= true|" in the parameter \kvopt{\meta{option}}{true} for the Boolean type can be omitted.

 \end{function}

 \section{Options}

 The \pkg{termsim} package provides a number of options to set the style of the terminal.
 The following options can be set with \tn{termset} macro.
 Also, these options can be set with the \env{terminal}(\env{terminal*}) environment's
 or the \tn{termfile}(\tn{termfile*}) command's \oarg{options}.

 \subsection{shell code engine}

 \begin{function}[added=2021-12-18,updated=2021-12-18]{minted}
   \begin{syntax}
     minted = <\TTF> \init{true}
   \end{syntax}
   \opt{minted} is used to set shell code engine, if it is \textbf{true} then
   the \pkg{minted} package is used, if it is \textbf{false} then
   the \pkg{listings} package is used. The default value is \textbf{true}.
 \end{function}

 \subsection{os type}

 \begin{function}[added=2021-12-18,updated=2021-12-18]{os}
   \begin{syntax}
     os =  <win10|mac|ubuntu> \init{win10}
   \end{syntax}
   \opt{os} is used to set Operating System type. The default value is \textbf{win10}.
 \end{function}

 \subsection{color theme}

 \begin{function}[added=2021-12-18,updated=2021-12-18]{theme}
   \begin{syntax}
     theme =  <dark|light|white> \init{dark}
   \end{syntax}
   \opt{theme} is used to set terminal color theme. The default value is \textbf{dark}.
 \end{function}

 \subsection{shell code style}

 \begin{function}[added=2021-12-18,updated=2021-12-18]{shstyle}
   \begin{syntax}
     shstyle = \Arg{style} \init{bw}
   \end{syntax}
   \opt{shstyle} is used to set shell code style, valid only for the \pkg{minted} engine.
   The default value is \textbf{bw}.
 \end{function}

 \subsection{shell code fontsize}

 \begin{function}[added=2021-12-18,updated=2021-12-18]{shsize}
   \begin{syntax}
     shsize = \Arg{fontsize} \init{\small}
   \end{syntax}
   \opt{shsize} is used to set shell code fontsize, valid only for \pkg{minted} engine.
   The default value is\textbf{\tn{small}}.
 \end{function}

 \subsection{comment format}

 \begin{function}[added=2021-12-18,updated=2021-12-18]{commentf}
   \begin{syntax}
     commentf = \Arg{format group} \init{\small\sffamily}
   \end{syntax}
   \opt{commentf} is used to set comment format at terminal bottom.
   The default value is \textbf{\tn{small}\tn{sffamily}}.
 \end{function}

 \subsection{shell code baseline stretch}

 \begin{function}[added=2021-12-18,updated=2021-12-18]{shstretch}
   \begin{syntax}
     shstretch = \Arg{float number} \init{1.0}
   \end{syntax}
   \opt{shstretch} is used to set shell code baseline stretch, valid only for \pkg{minted} engine.
   The default value is\textbf{1.0}.
 \end{function}

 \newpage

 \section{Examples}

 The \pkg{termsim} package can be used in situations
 where the operating system terminal window needs to be typeset
 to avoid the use of screenshots.
 Terminal windows can be with or without underline comments
 and can be dark, light or white color themes.

 \subsection{Win10 terminal}

 \subsubsection{\env{terminal} or \env{terminal*} environment}

   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
     \centering
     \termset{os=win10,theme=dark,shstretch=1.0}
     \begin{terminal}{terminal title}
       Volume in drive C is SSD_files
       Volume Serial Number is 0001-C78B
       Directory of C:\Users\Administrator
       2018/07/21  15:39    <DIR>          .
       2018/07/21  15:39    <DIR>          ..
       2018/07/13  08:35    <DIR>          3D Objects
       2018/07/13  08:35    <DIR>          Contacts
       2018/08/06  07:46    <DIR>          Desktop
                       2 File(s)      6,029,312 bytes
                  18 Dir(s) 14,035,107,840 bytes free
     \end{terminal}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termset{os=win10,theme=dark,shstretch=1.0}
\begin{terminal}{terminal title}
  Volume in drive C is SSD_files
  Volume Serial Number is 0001-C78B
  Directory of C:\Users\Administrator
2018/07/21  15:39    <DIR>          .
2018/07/21  15:39    <DIR>          ..
2018/07/13  08:35    <DIR>          3D Objects
2018/07/13  08:35    <DIR>          Contacts
2018/08/06  07:46    <DIR>          Desktop
                2 File(s)      6,029,312 bytes
           18 Dir(s) 14,035,107,840 bytes free
\end{terminal}
\end{minipage}
\end{center}

   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
     \centering
     \begin{terminal*}[os=win10,theme=light][comment text]{terminal title}
       Volume in drive C is SSD_files
       Volume Serial Number is 0001-C78B
       Directory of C:\Users\Administrator
       2018/07/21  15:39    <DIR>          .
       2018/07/21  15:39    <DIR>          ..
       2018/07/13  08:35    <DIR>          3D Objects
       2018/07/13  08:35    <DIR>          Contacts
       2018/08/06  07:46    <DIR>          Desktop
                       2 File(s)      6,029,312 bytes
                  18 Dir(s) 14,035,107,840 bytes free
     \end{terminal*}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\begin{terminal*}[os=win10,theme=light][comment text]{terminal title}
  Volume in drive C is SSD_files
  Volume Serial Number is 0001-C78B
  Directory of C:\Users\Administrator
2018/07/21  15:39    <DIR>          .
2018/07/21  15:39    <DIR>          ..
2018/07/13  08:35    <DIR>          3D Objects
2018/07/13  08:35    <DIR>          Contacts
2018/08/06  07:46    <DIR>          Desktop
                2 File(s)      6,029,312 bytes
           18 Dir(s) 14,035,107,840 bytes free
\end{terminal*}
\end{minipage}
\end{center}

 \subsubsection{\tn{termfile} or \tn{termfile*} macro}

   \begin{Verbatim}[frame=none,numbers=left]
     \centering
     \termset{os=win10,theme=dark}
     \termfile{terminal title}{test.bat}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termset{os=win10,theme=dark}
\termfile{terminal title}{test.bat}
\end{minipage}
\end{center}

   \begin{Verbatim}[frame=none,numbers=left]
     \centering
     \termfile*[os=win10,theme=light][comment text]{terminal title}{test.bat}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termfile*[os=win10,theme=light][comment text]{terminal title}{test.bat}
\end{minipage}
\end{center}

 \newpage
 \subsection{Mac terminal}

 \subsubsection{\env{terminal} or \env{terminal*} environment}

   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
     \centering
     \termset{os=mac,theme=dark}
     \begin{terminal}{terminal title}
       xxxxxx@xxxxxx-lap:~$ ls
       Desktop     Downloads   p2         Public   Templates   Videos
       Documents   Music       Pictures   snap    '#test#'     workspace
       xxxxxx@xxxxxx-lap:~$
     \end{terminal}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termset{os=mac,theme=dark}
\begin{terminal}{terminal title}
  xxxxxx@xxxxxx-lap:~$ ls
  Desktop     Downloads   p2         Public   Templates   Videos
  Documents   Music       Pictures   snap    '#test#'     workspace
  xxxxxx@xxxxxx-lap:~$
\end{terminal}
\end{minipage}
\end{center}

   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
     \centering
     \begin{terminal*}[os=mac,theme=light][comment text]{terminal title}
       xxxxxx@xxxxxx-lap:~$ ls
       Desktop     Downloads   p2         Public   Templates   Videos
       Documents   Music       Pictures   snap    '#test#'     workspace
       xxxxxx@xxxxxx-lap:~$
     \end{terminal*}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\begin{terminal*}[os=mac,theme=light][comment text]{terminal title}
  xxxxxx@xxxxxx-lap:~$ ls
  Desktop     Downloads   p2         Public   Templates   Videos
  Documents   Music       Pictures   snap    '#test#'     workspace
  xxxxxx@xxxxxx-lap:~$
\end{terminal*}
\end{minipage}
\end{center}

 \subsubsection{\tn{termfile} or \tn{termfile*} macro}

   \begin{Verbatim}[frame=none,numbers=left]
     \centering
     \termset{os=mac,theme=dark}
     \termfile{terminal title}{testls}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termset{os=mac,theme=dark}
\termfile{terminal title}{testls}
\end{minipage}
\end{center}
 \newpage
   \begin{Verbatim}[frame=none,numbers=left]
     \centering
     \termfile*[os=mac,theme=light][comment text]{terminal title}{testls}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termfile*[os=mac,theme=light][comment text]{terminal title}{testls}
\end{minipage}
\end{center}

 \subsection{Ubuntu terminal}

 \subsubsection{\env{terminal} or \env{terminal*} environment}

   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
     \centering
     \termset{os=ubuntu,theme=dark}
     \begin{terminal}{terminal title}
       xxxxxx@xxxxxx-lap:~/Desktop $
       git clone git@gitee.com:xxxxxx/xxxxxx
       Cloning into 'xxxxxx'...
       remote: Enumerating objects: 106, done.
       remote: Counting objects: 100% (106/106), done.
       remote: Compressing objects: 100% (105/105), done.
       remote: Total 106 (delta 9), reused 0 (delta 0)
       Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
       Resolving delta: 100% (9/9), done.
       Unpacking: 100% (75/75), done.
       xxxxxx@xxxxxx-lap:~/Desktop $
     \end{terminal}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termset{os=ubuntu,theme=dark}
\begin{terminal}{terminal title}
  xxxxxx@xxxxxx-lap:~/Desktop $
  git clone git@gitee.com:xxxxxx/xxxxxx
  Cloning into 'xxxxxx'...
  remote: Enumerating objects: 106, done.
  remote: Counting objects: 100% (106/106), done.
  remote: Compressing objects: 100% (105/105), done.
  remote: Total 106 (delta 9), reused 0 (delta 0)
  Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
  Resolving delta: 100% (9/9), done.
  Unpacking: 100% (75/75), done.
  xxxxxx@xxxxxx-lap:~/Desktop $
\end{terminal}
\end{minipage}
\end{center}

   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
     \centering
     \begin{terminal*}[os=ubuntu,theme=light][comment text]{terminal title}
       xxxxxx@xxxxxx-lap:~/Desktop $
       git clone git@gitee.com:xxxxxx/xxxxxx
       Cloning into 'xxxxxx'...
       remote: Enumerating objects: 106, done.
       remote: Counting objects: 100% (106/106), done.
       remote: Compressing objects: 100% (105/105), done.
       remote: Total 106 (delta 9), reused 0 (delta 0)
       Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
       Resolving delta: 100% (9/9), done.
       Unpacking: 100% (75/75), done.
       xxxxxx@xxxxxx-lap:~/Desktop $
     \end{terminal*}
   \end{Verbatim}
\newpage
\begin{center}
\begin{minipage}{0.85\textwidth}
\begin{terminal*}[os=ubuntu,theme=light][comment text]{terminal title}
  xxxxxx@xxxxxx-lap:~/Desktop $
  git clone git@gitee.com:xxxxxx/xxxxxx
  Cloning into 'xxxxxx'...
  remote: Enumerating objects: 106, done.
  remote: Counting objects: 100% (106/106), done.
  remote: Compressing objects: 100% (105/105), done.
  remote: Total 106 (delta 9), reused 0 (delta 0)
  Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
  Resolving delta: 100% (9/9), done.
  Unpacking: 100% (75/75), done.
  xxxxxx@xxxxxx-lap:~/Desktop $
\end{terminal*}
\end{minipage}
\end{center}

 \subsubsection{\tn{termfile} or \tn{termfile*} macro}

   \begin{Verbatim}[frame=none,numbers=left]
     \centering
     \termset{os=ubuntu,theme=dark}
     \termfile{terminal title}{testsh}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termset{os=ubuntu,theme=dark}
\termfile{terminal title}{testsh}
\end{minipage}
\end{center}

   \begin{Verbatim}[frame=none,numbers=left]
     \centering
     \termfile*[os=ubuntu,theme=light][comment text]{terminal title}{testsh}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termfile*[os=ubuntu,theme=light][comment text]{terminal title}{testsh}
\end{minipage}
\end{center}

 You can also use the white color theme and
 use black text on a white background for print on paper.

   \begin{Verbatim}[frame=none,numbers=left,gobble=5]
     \centering
     \termset{os=ubuntu,theme=white}
     \begin{terminal}{terminal title}
       xxxxxx@xxxxxx-lap:~/Desktop $
       git clone git@gitee.com:xxxxxx/xxxxxx
       Cloning into 'xxxxxx'...
       remote: Enumerating objects: 106, done.
       remote: Counting objects: 100% (106/106), done.
       remote: Compressing objects: 100% (105/105), done.
       remote: Total 106 (delta 9), reused 0 (delta 0)
       Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
       Resolving delta: 100% (9/9), done.
       Unpacking: 100% (75/75), done.
       xxxxxx@xxxxxx-lap:~/Desktop $
     \end{terminal}
   \end{Verbatim}

\begin{center}
\begin{minipage}{0.85\textwidth}
\termset{os=ubuntu,theme=white}
\begin{terminal}{terminal title}
  xxxxxx@xxxxxx-lap:~/Desktop $
  git clone git@gitee.com:xxxxxx/xxxxxx
  Cloning into 'xxxxxx'...
  remote: Enumerating objects: 106, done.
  remote: Counting objects: 100% (106/106), done.
  remote: Compressing objects: 100% (105/105), done.
  remote: Total 106 (delta 9), reused 0 (delta 0)
  Receiving objects: 100% (106/106), 237.88 MiB | 730.00 KiB/s, done.
  Resolving delta: 100% (9/9), done.
  Unpacking: 100% (75/75), done.
  xxxxxx@xxxxxx-lap:~/Desktop $
\end{terminal}
\end{minipage}
\end{center}

\end{document}