summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/termsim/termsim.sty
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-12-23 21:34:53 +0000
committerKarl Berry <karl@freefriends.org>2021-12-23 21:34:53 +0000
commit80812a87ec3d7bc0df221d11eca867fd38f3e221 (patch)
treea17e3b482b40289037f8b967a6270b0fd3574f1c /Master/texmf-dist/tex/latex/termsim/termsim.sty
parent9707e058fdbd13c19117545d85584ef84abc75f3 (diff)
termsim (23dec21)
git-svn-id: svn://tug.org/texlive/trunk@61391 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/termsim/termsim.sty')
-rw-r--r--Master/texmf-dist/tex/latex/termsim/termsim.sty562
1 files changed, 562 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/termsim/termsim.sty b/Master/texmf-dist/tex/latex/termsim/termsim.sty
new file mode 100644
index 00000000000..f48b51c2629
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/termsim/termsim.sty
@@ -0,0 +1,562 @@
+%%
+%% This is file `termsim.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% termsim.dtx (with options: `package')
+%%
+%% Copyright (C) 2020-2021 by Nan Geng <nangeng@nwafu.edu.cn>
+%% --------------------------------------------------------------------------
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3c of this license or (at your option) any later
+%% version. This version of this license is in
+%% http://www.latex-project.org/lppl/lppl-1-3c.txt
+%% and the latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2005/12/01 or later.
+%%
+%% This work has the LPPL maintenance status "maintained".
+%%
+%% The Current Maintainer of this work is Nan Geng.
+%%
+%% --------------------------------------------------------------------------
+%%
+\NeedsTeXFormat{LaTeX2e}[2020/10/01]
+\RequirePackage{expl3}
+\GetIdInfo$Id: termsim.dtx 1.0.0 2021-12-14 08:00:00 +0800 Nan Geng <nangeng@nwafu.edu.cn> $
+ {Terminal simulation with tcolorbox and minted/listings.}
+\ProvidesExplPackage{\ExplFileName}
+ {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
+\RequirePackage { xtemplate, l3keys2e, xparse }
+\RequirePackage {fontawesome5, tcolorbox, varwidth, amssymb, xcolor, etoolbox}
+\ExplSyntaxOff
+\patchcmd
+{\tcb@input@library@in}
+ {%
+ \input\tcbpkgprefix#1\relax%
+ }
+ {%
+ \@pushfilename
+ \input\tcbpkgprefix#1\relax%
+ \@popfilename
+ }
+ {}{}
+
+\patchcmd
+{\pgfutil@InputIfFileExists}
+ {\input #1}
+ {%
+ \@pushfilename
+ \xdef\@currname{#1}%
+ \input #1 %
+ \@popfilename
+ }
+ {}{}
+\ExplSyntaxOn
+\ExplSyntaxOff
+\RequirePackage {regexpatch} % for starred \xpatchcmd which can replace all
+\makeatletter
+\def\minted@use@FancyVerbStartNum{\the\numexpr\FancyVerbStartNum}
+\def\minted@use@FancyVerbStopNum{\the\numexpr\FancyVerbStopNum}
+
+\xpatchcmd*\minted@pygmentize
+ {\ifx\FancyVerbStartNum\z@ 0\else\FancyVerbStartNum\fi}
+ {\minted@use@FancyVerbStartNum}
+ {}{\PatchFailed}
+\xpatchcmd*\minted@pygmentize
+ {\ifx\FancyVerbStopNum\z@ 0\else\FancyVerbStopNum\fi}
+ {\minted@use@FancyVerbStopNum}
+ {}{\PatchFailed}
+
+\xpatchcmd\minted@autogobble
+ {\ifx\FancyVerbStartNum\z@ 0\else\FancyVerbStartNum\fi}
+ {\minted@use@FancyVerbStartNum}
+ {}{\PatchFailed}
+\xpatchcmd\minted@autogobble
+ {\ifx\FancyVerbStopNum\z@ 0\else\FancyVerbStopNum\fi}
+ {\minted@use@FancyVerbStopNum}
+ {}{\PatchFailed}
+\makeatother
+\ExplSyntaxOn
+\tcbuselibrary{skins, xparse, breakable}
+\usetikzlibrary{shapes.geometric}
+\definecolor{mpurple}{RGB}{48,10,36}
+\definecolor{mgray}{RGB}{70,72,67}
+\definecolor{ogray}{RGB}{148,147,141}
+\definecolor{oorange}{RGB}{233,101,56}
+\definecolor{termimal}{RGB}{80,78,70}
+\definecolor{linux}{RGB}{0,39,51}
+\definecolor{windows}{HTML}{00B294}
+\definecolor{cvgrayc}{RGB}{247,247,247}
+\definecolor{cvgray}{RGB}{220,220,220}
+\definecolor{cvgrayb}{RGB}{153,153,153}
+\definecolor{cvblue}{RGB}{223,238,255}
+\definecolor{zhanqing}{RGB}{0,51,113}
+\definecolor{chengse}{RGB}{250,140,53}
+
+\definecolor{AppleRed}{RGB}{255,95,86}
+\definecolor{AppleYellow}{RGB}{255,189,46}
+\definecolor{AppleGreen}{RGB}{39,201,63}
+\definecolor{AppleGray}{HTML}{D8D6D9}
+
+\definecolor{WinGray}{HTML}{FFFFFF}
+\definecolor{WinBlue}{HTML}{1883D7}
+\newcommand{\UbuntuMin}{%
+ \begin{tikzpicture}[x=2.4ex,y=2.4ex,line~width=0.15ex,scale=1]
+ \shade[shading=ball,left~color=ogray,right~color=ogray!50!white] (0,0) circle (0.5);
+ \draw[termimal](-0.3,0)--(0.3,0);
+ \end{tikzpicture}
+}
+\newcommand{\UbuntuClose}{%
+ \begin{tikzpicture}[x=2.4ex,y=2.4ex,line~width=0.15ex,scale=1]
+ \shade[shading=ball,left~color=oorange,right~color=oorange!70!white] (0,0) circle (0.5);
+ \draw[termimal](-0.25,-0.25)--(0.25,0.25);
+ \draw[termimal](-0.25,0.25)--(0.25,-0.25);
+ \end{tikzpicture}
+}
+\newcommand{\UbuntuMax}{%
+ \begin{tikzpicture}[x=2.4ex,y=2.4ex,line~width=0.15ex,scale=1]
+ \shade [shading=ball,left~color=ogray,right~color=ogray!50!white] (0,0) circle (0.5);
+ \draw[termimal](-0.25,-0.2)rectangle(0.25,0.2);
+ \end{tikzpicture}
+}
+\newcommand{\WindowsLogo}{%
+ \begin{tikzpicture}[square/.style={regular~polygon,regular~polygon~sides=4},
+ scale=0.65, every~node/.style={scale=0.65}]
+ \node[square,draw,fill=black,text=white] at (0, 0) (a) {\small\faTerminal};
+ \end{tikzpicture}
+}
+\tcbset{%
+ skin=enhanced,%
+ apple/.style={%
+ halign~title=center,%
+ skin=bicolor,%
+ boxrule=0.5mm,%
+ breakable,%
+ frame~style={%
+ draw=AppleGray,%
+ left~color=AppleGray,%
+ right~color=AppleGray%
+ },%
+ overlay~unbroken = {%
+ \node[inner~sep=0pt,anchor=north~west,yshift=-4pt,xshift=10pt,text=white]
+ at (frame.north~west) {\textcolor{AppleRed}{\faCircle}$\,$
+ \textcolor{AppleYellow}{\faCircle}$\,$
+ \textcolor{AppleGreen}{\faCircle}};
+ },%
+ overlay~first = {%
+ \node[inner~sep=0pt,anchor=north~west,yshift=-4pt,xshift=10pt,text=white]
+ at (frame.north~west) {\textcolor{AppleRed}{\faCircle}$\,$
+ \textcolor{AppleYellow}{\faCircle}$\,$
+ \textcolor{AppleGreen}{\faCircle}};
+ },%
+ fonttitle=\sffamily,%\bfseries,%
+ fontupper=\small\sffamily,%
+ fontlower=\small\sffamily%
+ },
+ appledark/.style={%
+ apple,%
+ colback=black,%
+ colupper=white,%
+ colbacktitle=AppleGray,%
+ colframe=AppleGray,%
+ coltitle=black%
+ %coltext=MyLightGray
+ },
+ applelight/.style={%
+ apple,%
+ colback=cvgrayc,%
+ colupper=black,%
+ colbacktitle=AppleGray,%
+ colframe=AppleGray,%
+ coltitle=black%
+ },%
+ applewhite/.style={%
+ apple,%
+ colback=white,%
+ colupper=black,%
+ colbacktitle=AppleGray,%
+ colframe=AppleGray,%
+ coltitle=black%
+ },%
+}%
+\tcbset{%
+ skin=enhanced,%
+ win10/.style={%
+ skin=bicolor,%
+ boxrule=0.1mm,%
+ %toptitle=1ex,
+ sharp~corners,
+ breakable,%
+ colbacktitle=WinGray,%
+ colframe=WinGray,%
+ coltitle=black,%
+ fonttitle=\sffamily,%\bfseries,
+ fontupper=\small\sffamily,
+ fontlower=\small\sffamily,
+ frame~style={%
+ draw=WinBlue,%
+ left~color=WinBlue,%
+ right~color=WinBlue%
+ },%
+ overlay~unbroken = {%
+ \node[inner~sep=0pt,anchor=north~west,yshift=-3pt,xshift=1.2pt,text=black]
+ at (frame.north~west){\WindowsLogo};
+ \node[inner~sep=0pt,anchor=north~east,yshift=-5pt,xshift=-8pt,text=black]
+ at (frame.north~east){\rule{0.8em}{0.6pt}\quad$\square$\quad{\Large$\times$}};
+ },%
+ overlay~first = {%
+ \node[inner~sep=0pt,anchor=north~west,yshift=-3pt,xshift=1.0pt,text=black]
+ at (frame.north~west){\WindowsLogo};
+ \node[inner~sep=0pt,anchor=north~east,yshift=-5pt,xshift=-8pt,text=black]
+ at (frame.north~east){\rule{0.8em}{0.6pt}\quad$\square$\quad{\Large$\times$}};
+ }%
+ },
+ win10dark/.style={
+ win10,%
+ colback=black,%
+ colupper=white,%
+ %coltext=white%
+ },
+ win10light/.style={
+ win10,%
+ colback=white,%
+ colupper=black,%
+ %coltext=black%
+ },
+ win10white/.style={
+ win10,%
+ colback=white,%
+ colupper=black,%
+ %coltext=white%
+ },
+}%
+\tcbset{%
+ skin=enhanced,%
+ ubuntu/.style={%
+ halign~title=center,%
+ skin=bicolor,%
+ boxrule=0.5mm,%
+ breakable,%
+ overlay~unbroken = {%
+ \node[inner~sep=0pt,anchor=north~east,yshift=-3.5pt,xshift=-5pt,text=white]
+ at (frame.north~east){\UbuntuMin$\,$\UbuntuMax$\,$\UbuntuClose};%
+ },%
+ overlay~first = {%
+ \node[inner~sep=0pt,anchor=north~east,yshift=-3.5pt,xshift=-5pt,text=white]
+ at (frame.north~east){\UbuntuMin$\,$\UbuntuMax$\,$\UbuntuClose};%
+ },%
+ fonttitle=\sffamily,%
+ fontupper=\small\sffamily,%
+ fontlower=\small\sffamily%
+ },
+ udark/.style={%
+ ubuntu,%
+ frame~style={%
+ draw=mgray,%
+ left~color=mgray,%
+ right~color=mgray%
+ },%
+ colback=mpurple,%
+ colupper=white,%
+ colbacktitle=mgray,%
+ colframe=mgray,%
+ coltitle=white%
+ %coltext=MyLightGray
+ },
+ ulight/.style={%
+ ubuntu,%
+ frame~style={%
+ draw=cvgrayb,%
+ left~color=cvgrayb,%
+ right~color=cvgrayb%
+ },%
+ colback=cvgrayc,%
+ colupper=black,%
+ colbacktitle=cvgrayb,%
+ colframe=cvgrayb,%
+ coltitle=black%
+ },%
+ uwhite/.style={%
+ ubuntu,%
+ frame~style={%
+ draw=cvgrayb,%
+ left~color=cvgrayb,%
+ right~color=cvgrayb%
+ },%
+ colback=white,%
+ colupper=black,%
+ colbacktitle=cvgrayb,%
+ colframe=cvgrayb,%
+ coltitle=black%
+ },%
+}%
+\bool_new:N \l__termsim_minted_bool
+\bool_new:N \l__termsim_comment_bool
+\int_new:N \l__termsim_os_type_int
+\int_new:N \l__termsim_color_theme_int
+\tl_new:N \l__termsim_shell_style_tl
+\tl_new:N \l__termsim_shell_fontsize_tl
+\tl_new:N \l__termsim_comment_format_tl
+\tl_new:N \l__termsim_shell_baseline_stretch_tl
+\tl_new:N \l__termsim_linenumber_sep_tl
+\keys_define:nn { termsim }
+ {
+ minted .bool_set:N = \l__termsim_minted_bool,
+ minted .default:n = true,
+ minted .initial:n = true,
+ os .choice:,
+ os .value_required:n = true,
+ os .choices:nn =
+ { win10, mac, ubuntu }
+ { \int_set_eq:NN \l__termsim_os_type_int \l_keys_choice_int },
+ os .initial:n = win10,
+ theme .choice:,
+ theme .value_required:n = true,
+ theme .choices:nn =
+ { dark, light, white }
+ { \int_set_eq:NN \l__termsim_color_theme_int \l_keys_choice_int },
+ theme .initial:n = dark,
+ shstyle .tl_set:N = \l__termsim_shell_style_tl,
+ shstyle .initial:n = bw,
+ shsize .tl_set:N = \l__termsim_shell_fontsize_tl,
+ shsize .initial:n = \small,
+ commentf .tl_set:N = \l__termsim_comment_format_tl,
+ commentf .initial:n = \small\sffamily,
+ shstretch .tl_set:N = \l__termsim_shell_baseline_strech_tl,
+ shstretch .initial:n = 1.0,
+ unknown .code:n = { \__termsim_error:n { unknown-option } }
+ }
+\msg_new:nnn { termsim } { unknown-option }
+ { package~ option~ "\l_keys_key_tl"~ is~ unknown. }
+\keys_set:nn { termsim }
+ {
+ minted = true,
+ os = win10,
+ theme = dark,
+ }
+\NewDocumentCommand \termset { m }
+ { \keys_set:nn { termsim } {#1} }
+\cs_new:Npn \__termsim_minted_tcbset:n #1
+ {
+ \tcbset{
+ listing~engine=minted,%
+ minted~style=\tl_use:N \l__termsim_shell_style_tl,%
+ minted~options={%
+ breaklines,%
+ fontsize=\tl_use:N \l__termsim_shell_fontsize_tl,%
+ baselinestretch=#1,%
+ breaksymbolleft={},%
+ linenos=false,%
+ },%
+ minted~language=bash%
+ }
+ }
+\cs_generate_variant:Nn \__termsim_minted_tcbset:n {V}
+\cs_new:Npn \__termsim_listings_tcbset:
+ {
+ \lstset{% general command to set parameter(s)
+ basicstyle=\ttfamily\tl_use:N \l__termsim_shell_fontsize_tl, % print whole listing small
+ keywordstyle=\color{chengse}\bfseries,%
+ identifierstyle=, % nothing happens
+ breaklines=true,
+ commentstyle=\itshape\color{gray},
+ stringstyle=\ttfamily, % typewriter type for strings
+ numbers=left,%
+ numberstyle=\tl_use:N \l__termsim_shell_fontsize_tl\sffamily\color[rgb]{0.5,0.5,1.0},%
+ }%
+ }
+\cs_generate_variant:Nn \__termsim_minted_tcbset:n {V}
+\cs_new:Npn \__termsim_comment_tcbset:n #1
+ {
+ \bool_if:NTF { \l__termsim_comment_bool }
+ {
+ \tcbset{%
+ listing~and~comment,%
+ colbacklower=tcbcolback!5!yellow!10!white,%
+ collower=linux,%
+ comment={\tl_use:N \l__termsim_comment_format_tl~#1},%
+ }
+ }{
+ \tcbset{ listing~only,}
+ }
+ }
+\cs_new:Npn \__termsim_terminal_theme_select:
+ {
+ \int_case:nn {\l__termsim_os_type_int}
+ {
+ {1}{
+ \int_case:nn {\l__termsim_color_theme_int}
+ {
+ {1}{
+ \tcbset{ win10dark, }
+ }
+ {2}{
+ \tcbset{ win10light, }
+ }
+ {3}{
+ \tcbset{ win10white, }
+ }
+ }
+ }
+ {2}{
+ \int_case:nn {\l__termsim_color_theme_int}
+ {
+ {1}{
+ \tcbset{ appledark, }
+ }
+ {2}{
+ \tcbset{ applelight, }
+ }
+ {3}{
+ \tcbset{ applewhite, }
+ }
+ }
+ }
+ {3}{
+ \int_case:nn {\l__termsim_color_theme_int}
+ {
+ {1}{
+ \tcbset{ udark, }
+ }
+ {2}{
+ \tcbset{ ulight, }
+ }
+ {3}{
+ \tcbset{ uwhite, }
+ }
+ }
+ }
+ }
+ }
+\bool_if:NTF \l__termsim_minted_bool
+ {
+ \tcbuselibrary{minted}
+ \NewDocumentEnvironment{ terminal }{O{} O{} m }
+ {
+ \bool_set_false:N \l__termsim_comment_bool
+ \group_begin:
+ \IfNoValueF{#1}{ \keys_set:nn { termsim } { #1 } }
+ \__termsim_comment_tcbset:n { #2 }
+ \__termsim_terminal_theme_select:
+ \__termsim_minted_tcbset:V \l__termsim_shell_baseline_stretch_tl
+ \tcbset{ title={#3} }%
+ \tcblisting{}
+ }{
+ \endtcblisting
+ \group_end:
+ }
+ \NewDocumentEnvironment{ terminal* }{O{} O{} m }
+ {
+ \bool_set_true:N \l__termsim_comment_bool
+ \group_begin:
+ \IfNoValueF{#1}{ \keys_set:nn { termsim } { #1 } }
+ \__termsim_comment_tcbset:n { #2 }
+ \__termsim_terminal_theme_select:
+ \__termsim_minted_tcbset:V \l__termsim_shell_baseline_stretch_tl
+ \tcbset{ title={#3} }%
+ \tcblisting{}
+ }{
+ \endtcblisting
+ \group_end:
+ }
+ \NewDocumentCommand \termfile { s O{} O{} m m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \bool_set_true:N \l__termsim_comment_bool
+ }{
+ \bool_set_false:N \l__termsim_comment_bool
+ }
+
+ \group_begin:
+ \IfNoValueF{#2}{ \keys_set:nn { termsim } { #2 } }
+ \__termsim_comment_tcbset:n { #3 }
+ \__termsim_terminal_theme_select:
+ \__termsim_minted_tcbset:V \l__termsim_shell_baseline_stretch_tl
+ \tcbset{
+ title={#4},
+ listing~file={#5},
+ }%
+ \tcbinputlisting{ }
+ \group_end:
+ }
+ }{
+ \tcbuselibrary{listings}% 用listings排版代码
+
+ \__termsim_listings_tcbset:
+
+ \NewDocumentEnvironment{ terminal }{O{} O{} m }
+ {
+ \bool_set_false:N \l__termsim_comment_bool
+ \group_begin:
+ \IfNoValueF{#1}{ \keys_set:nn { termsim } { #1 } }
+ \__termsim_comment_tcbset:n { #2 }
+ \__termsim_terminal_theme_select:
+ \tcbset{
+ title={#3},
+ listing~options={
+ language=bash,
+ numbers=none,
+ }
+ }%
+ \tcblisting{}
+ }{
+ \endtcblisting
+ \group_end:
+ }
+ \NewDocumentEnvironment{ terminal* }{O{} O{} m }
+ {
+ \bool_set_true:N \l__termsim_comment_bool
+ \group_begin:
+ \IfNoValueF{#1}{ \keys_set:nn { termsim } { #1 } }
+ \__termsim_comment_tcbset:n { #2 }
+ \__termsim_terminal_theme_select:
+ \tcbset{
+ title={#3},
+ listing~options={
+ language=bash,
+ numbers=none,
+ }
+ }%
+ \tcblisting{}
+ }{
+ \endtcblisting
+ \group_end:
+ }
+ \NewDocumentCommand \termfile { s O{} O{} m m }
+ {
+ \IfBooleanTF{#1}
+ {
+ \bool_set_true:N \l__termsim_comment_bool
+ }{
+ \bool_set_false:N \l__termsim_comment_bool
+ }
+ \group_begin:
+ \IfNoValueF{#2}{ \keys_set:nn { termsim } { #2 } }
+ \__termsim_comment_tcbset:n { #3 }
+ \__termsim_terminal_theme_select:
+ \tcbset{
+ title={#4},
+ listing~file={#5},
+ listing~options={
+ language=bash,
+ numbers=none,
+ },%
+ }%
+ \tcbinputlisting{ }
+ \group_end:
+ }
+ }
+%%
+%% This package consists of the file termsim.dtx,
+%% and the derived files termsim.sty,
+%% termsim.pdf,
+%% termsim.ins,
+%% README.md.
+%%
+%% End of file `termsim.sty'.