summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/sim-os-menus/doc/sim-os-menus-doc.tex
blob: 229d36370097fedc4c7d0206f9088070b01e90a3 (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
% !TeX TXS-program:compile = txs:///pdflatex

\documentclass[11pt,a4paper]{ltxdoc}
\usepackage{sim-os-menus}
\usepackage{graphicx}
\usepackage{fancyvrb}
\usepackage{fancyhdr}
\usepackage{hyperref}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
%\rhead{\sffamily\small\affloetalab[Legende]}
\lfoot{\sffamily\small [sim-os-menus]}
\rfoot{\sffamily\small - \thepage{} -}
%\rfoot{\hyperlink{matoc}{\small\faArrowAltCircleUp[regular]}}
\usepackage{hologo}
\providecommand\tikzlogo{Ti\textit{k}Z}
\providecommand\TeXLive{\TeX{}Live\xspace}
\providecommand\PSTricks{\textsf{PSTricks}\xspace}
\let\pstricks\PSTricks
\let\TikZ\tikzlogo

\urlstyle{same}
\hypersetup{pdfborder=0 0 0}
\usepackage[margin=2cm]{geometry}
\setlength{\parindent}{0pt}
\def\TPversion{0.1.1}
\def\TPdate{14/11/2023}
\usepackage{soul}
\sethlcolor{lightgray!25}
\NewDocumentCommand\MontreCode{ m }{%
	\hl{\vphantom{\texttt{pf}}\texttt{#1}}%
}

\begin{document}

\pagestyle{fancy}

\thispagestyle{empty}

\begin{center}
	\begin{minipage}{0.88\linewidth}
	\begin{tcolorbox}[colframe=yellow,colback=yellow!15]
		\begin{center}
			\begin{tabular}{c}
				{\Huge \texttt{sim-os-menus}}\\
				\\
				{\LARGE Simulate 'windows', 'terminal' or} \\
				{\LARGE 'context menu' like in an OS.} \\
				\\
				{\small \texttt{Version \TPversion{} -- \TPdate}}
		\end{tabular}
		\end{center}
	\end{tcolorbox}
\end{minipage}
\end{center}

\begin{center}
	\begin{tabular}{c}
	\texttt{Cédric Pierquet}\\
	{\ttfamily c pierquet -- at -- outlook . fr}\\
	\texttt{\url{https://github.com/cpierquet/sim-os-menus}} \\
\end{tabular}
\end{center}

\hrule

\vfill

\begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
\ContextMenu[Font=\sffamily,ListSeps={1,3/1/4/1/},ListOffsets={1,2,1,0}]{%
	Menu1(>),Menu2,Menu3(>)(*),Menu4 §
	SubMenuA(>),SubMenuB(>)(*) §
	SubSubMenu1,SubSubMenu2,SubSubMenu3(>)(*),SubSubMenu4,SubSubMenu5(>) §
	SSSSMa,SSSSMa(>)(*),SSSSMc §
	OK(*),KO
}
\end{tcolorbox}

\begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
\begin{TermUnix}[Width=12cm,Align=center]{}
test@DESKTOP:~$ ping -c 2 ctan.org
PING ctan.org (5.35.249.60) 56(84) bytes of data.
\end{TermUnix}
\end{tcolorbox}

\begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
\begin{IMGViewer}[Width=12cm]{}
\includegraphics[width=5cm]{example-image-b}
\end{IMGViewer}
\end{tcolorbox}

\begin{tcolorbox}[colframe=lightgray,colback=lightgray!5]
\begin{TermMac}[Width=14cm,Align=flush left]{}
[test@server]$ ping -c 2 ctan.org
PING ctan.org (5.35.249.60) 56(84) bytes of data.
\end{TermMac}
\end{tcolorbox}

\vfill~

\pagebreak

\phantomsection

\hypertarget{matoc}{}

\tableofcontents

\vspace*{5mm}

\hrule

\vspace*{5mm}

\section{Introduction}

\subsection{Description}

With this package you can create context menu, or terminal, or doc viewer, like in an OS.

Global styles are mostly fixed, but some customizations are possible.

\subsection{Loading}

To load the package, simply use :

\begin{quote}
\begin{verbatim}
\usepackage{sim-os-menus}
\end{verbatim}
\end{quote}

The package loads the packages :

\begin{itemize}
	\item \MontreCode{tikz} (with \MontreCode{calc,positioning}), \MontreCode{pgf}, \MontreCode{pgffor} ;
	\item \MontreCode{calc}, \MontreCode{fontawesome5} ;
	\item \MontreCode{simplekv}, \MontreCode{xintexpr}, \MontreCode{listofitems}, \MontreCode{xstring} ;
	\item \MontreCode{settobox}, \MontreCode{tabularray} ;
	\item \MontreCode{tcolorbox} (with \MontreCode{breakable,fitting,skins,listings,listingsutf8,hooks}).
\end{itemize}

\vfill

\subsection{History}

\begin{quote}
\begin{verbatim}
0.1.1 : French version of the commands
0.1.0 : Initial version
\end{verbatim}
\end{quote}

\pagebreak

\section{The macros}

\subsection{Context menu}

I order to create a context menu, the command is :

\begin{quote}
\begin{verbatim}
%----contextual menu
\ContextMenu[keys]{list of items}<tikz options>
\end{verbatim}
\end{quote}

Optional keys, between \MontreCode{[...]} are :

\begin{itemize}
	\item \MontreCode{ColBack} := background color ;
	\item \MontreCode{ColHL} : = highlight color ;
	\item \MontreCode{Rounded} := boolean for rounded corners (\MontreCode{true} by default) ;
	\item \MontreCode{Font} := font for the items (\MontreCode{\textbackslash normalsize\textbackslash normalfont} by default) ;
	\item \MontreCode{ColItems} := color(s) for the items (\MontreCode{black} by default) ;
	\item \MontreCode{MarginV} := vertical margin of the lines (\MontreCode{6pt} by default) ;
	\item \MontreCode{MarginH} := horizontal margin of the lines (\MontreCode{12pt} by default) ;
	\item \MontreCode{Arrow} := character for the arrow (\MontreCode{\textbackslash faCaretRight} by default) ;
	\item \MontreCode{ListSeps} := list for the possible sep lines (empty or for all the levels !) ;
	\item \MontreCode{ListIcons} := list for the possible icons (empty or for all the levels/items !) ;
	\item \MontreCode{ListOffsets} := list for the possible vertical offset of levels (from 2, \ldots !) (empty or for all the sub-levels !) ;
	\item \MontreCode{Icons} := boolean for icons (\MontreCode{false} by default) ;
	\item \MontreCode{Bar} := boolean for small vertical bar with icons (\MontreCode{true} by default) ;
	\item \MontreCode{Space} := horizontal space between levels (\MontreCode{-0.125} by default).
\end{itemize}

\medskip

The mandatory argument, between \MontreCode{\{...\}}, is given as :

\smallskip

\hfill\MontreCode{item1A,item1B,... § item2A,itemp2B,... § ...}\hfill~

\begin{itemize}
	\item if an item ends with \MontreCode{(*)}, this is the beginning of the next level (\underline{only one} by level !) ;
	\item if an item ends with \MontreCode{(>)} (\underline{before} optional \MontreCode{(*)}), an arrow is written at the end of the line.
\end{itemize}

A correct usage of the syntax is necessary for the code !

\vspace{5mm}

A few tips, due to \MontreCode{ListIcons}, \MontreCode{ListOffsets} and \MontreCode{ListSeps} keys, which are \textit{sensitive} :

\begin{itemize}
	\item \MontreCode{ListIcons} must have the same number of elements than the number of levels/items (with possible empty items) ;
	\item \MontreCode{ListSeps} must have the same number of elements than the number of levels (with possible empty items) ;
	\item \MontreCode{ListOffsets} must have the same number of elements than the numbers of sub-levels (with 0 si no offset !).
\end{itemize}

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
%default style
\ContextMenu{Item1A(>),Item1B,Item1C(>)(*),Item1D § Item2A(*),Item2B(>),Item2C}
\end{tcblisting}

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
%custom style
\ContextMenu[Rounded=false,ColBack=yellow,ColHL=teal,%
  ListSeps={1,3/2},ColItems={black/white},Icons,Space=0,%
  ListIcons={\faCut,\faIcon[regular]{copy},\faCopy,\faPaste / \faNotEqual}]
  {Item1A(>)(*),Item1B,Item1C(>),Item1D § Item2A(*),Item2B(>),Item2C}
\end{tcblisting}

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
\ContextMenu[Font=\sffamily,ListSeps={1,3/1/4/1/},ListOffsets={1,2,1,0}]{%
  Menu1(>),Menu2,Menu3(>)(*),Menu4 §
  SubMenuA(>),SubMenuB(>)(*) §
  SubSubMenu1,SubSubMenu2,SubSubMenu3(>)(*),SubSubMenu4,SubSubMenu5(>) §
  SSSSMa,SSSSMa(>)(*),SSSSMc §
  OK(*),KO
}
\end{tcblisting}

\pagebreak

\subsection{Terminal}

In order to create a terminal (Win/UNiX/Mac), environments are :

\begin{quote}
\begin{verbatim}
%----Windows like terminal
\begin{TermWin}[keys]{tcbox options}
    ...
\end{TermWin}

%----UNiX like terminal
\begin{TermUnix}[keys]{tcbox options}
    ...
\end{TermUnix}

%----OSX like terminal
\begin{TermMac}[keys]{tcbox options}
    ...
\end{TermMac}
\end{verbatim}
\end{quote}

Optional keys, between \MontreCode{[...]} are :

\begin{itemize}
	\item \MontreCode{Title} := title of the terminal (\MontreCode{Terminal Win/UNiX/Mac} by default) ;
	\item \MontreCode{Align} := horizontal alignment of the box (\MontreCode{center} by default) ;
	\item \MontreCode{Width} := width of the box (\MontreCode{\textbackslash linewidth} by default).
\end{itemize}

\medskip

The mandatory argument, between \MontreCode{\{...\}}, are options to give to the tcbox.

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
\begin{TermWin}{}
Microsoft Windows [version 10.0.22000.493]
(c) Microsoft Corporation. Tous droits réservés.
C:\Users\test>ping ctan.org
Envoi d'une requête 'ping' sur ctan.org [5.35.249.60] avec 32 octets de données :
Réponse de 5.35.249.60 : octets=32 temps=35 ms TTL=51
Réponse de 5.35.249.60 : octets=32 temps=37 ms TTL=51
Réponse de 5.35.249.60 : octets=32 temps=35 ms TTL=51
Réponse de 5.35.249.60 : octets=32 temps=39 ms TTL=51
Statistiques Ping pour 5.35.249.60:
Paquets : envoyés = 4, reçus = 4, perdus = 0 (perte 0%),
Durée approximative des boucles en millisecondes :
Minimum = 35ms, Maximum = 39ms, Moyenne = 36ms
\end{TermWin}
\end{tcblisting}

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
\begin{TermUnix}[Align=flush right]{hbox}
test@DESKTOP:~$ ping -c 2 ctan.org
PING ctan.org (5.35.249.60) 56(84) bytes of data.
\end{TermUnix}
\end{tcblisting}

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
\begin{TermMac}[Width=14cm,Align=flush left]{}
[test@server]$ ping -c 2 ctan.org
PING ctan.org (5.35.249.60) 56(84) bytes of data.
\end{TermMac}
\end{tcblisting}

\pagebreak

\subsection{Viewers}

In order to create a 'fake' viewer (for \textsf{pdf} or \textsf{img}), environments are :

\begin{quote}
\begin{verbatim}
%----PDF Viewer like
\begin{PDFViewer}[keys]{tcbox options}
    ....
\end{PDFViewer}

%----Image Viewer like
\begin{IMGViewer}[keys]{tcbox options}
    ....
\end{IMGViewer}
\end{verbatim}
\end{quote}

Optional keys, between \MontreCode{[...]} are :

\begin{itemize}
	\item \MontreCode{Title} := title of the terminal (\MontreCode{Terminal Windows} by default) ;
	\item \MontreCode{Align} := horizontal alignment of the box (\MontreCode{center} by default) ;
	\item \MontreCode{Width} := width of the box (\MontreCode{\textbackslash linewidth} by default) ;
	\item \MontreCode{Halign} := horizontal alignment fot the content (\MontreCode{left} by default) ;
	\item \MontreCode{Icons} := boolean for the icons (\MontreCode{true} by default).
\end{itemize}

\medskip

The mandatory argument, between \MontreCode{\{...\}}, are options to give to the tcbox.

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
\begin{PDFViewer}{hbox}
\fbox{\includegraphics[page=35,width=6cm]{ProfLycee-doc.pdf}}%
\fbox{\includegraphics[page=36,width=6cm]{ProfLycee-doc.pdf}}
\end{PDFViewer}
\end{tcblisting}

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
\begin{PDFViewer}[Width=14cm,Icons=false]{}
\fbox{\includegraphics[page=65,width=4.75cm]{ProfLycee-doc.pdf}}
\end{PDFViewer}
\end{tcblisting}

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
\begin{IMGViewer}[Icons=false]{hbox}
\includegraphics[width=5cm]{example-image-b}
\end{IMGViewer}
\end{tcblisting}

\begin{tcblisting}{colframe=lightgray,colback=lightgray!5}
\begin{IMGViewer}[Width=12cm]{}
\includegraphics[width=3cm]{example-image}
\end{IMGViewer}
\end{tcblisting}

\end{document}