%% This is file `bfh-layout-tabular.cfg' version 2.2.1 (2024-03-11),
%% it is part of
%% BFH-CI -- Corporate Design for Bern University of Applied Sciences
%% ----------------------------------------------------------------------------
%%
%%  Copyright (C) 2021–2024 by
%%      Marei Peischl <marei@peitex.de>
%%      Andreas Habegger <andreas.habegger@bfh.ch>
%%
%% ============================================================================
%% 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.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008/05/04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainers of this work are
%%   Marei Peischl <bfh-ci@peitex.de>
%%   Andreas Habegger <andreas.habegger@bfh.ch>
%%
%% The development respository can be found at
%% https://gitlab.ti.bfh.ch/bfh-latex/bfh-ci/
%% Please use the issue tracker for feedback!
%%
%% ============================================================================
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{bfh-layout-terminal.cfg}[2024-03-11 v2.2.1 terminal configuration for bfhlayout]

\RequirePackage{bfhcolors}
\RequirePackage{tcolorbox}
\RequirePackage{url}

\tcbuselibrary{skins,xparse,listings}

\colorlet{ubuntu-terminalBackground}{violet!50!black}
\colorlet{ubuntu-terminalText}{white}
\colorlet{ubuntu-terminalFrame}{gray!65!black}
\colorlet{ubuntu-terminalFirstBullet}{orange}
\colorlet{ubuntu-terminalSecondBullet}{gray}
\colorlet{ubuntu-terminalThirdBullet}{gray}

%define key because we receive an error for setting them in case minted isn't loaded
\csname @ifpackageloaded\endcsname{minted}{}{
	\tcbset{minted options/.style={}}
}



\tcbset{
	ptxcd/terminal/default/.style={
		listing only,
		listing options={style=tcblatex,language=sh,escapeinside=``,},
	  listing inputencoding=utf8,
	  minted options={escapeinside=\\`\\`,autogobble,formatcom=\BFHterminalFormatLine,breaklines,breaksymbol=\quad},
	  every listing line={\BFHterminalPrompt{}},
	  size=small,
	  halign title=flush left,
	},
	ptxcd/terminal/macos/.style={
	  colback=macosx-terminalBackground,
		colupper=macosx-terminalText,
		colframe=macosx-terminalFrame,
		title={\textcolor{macosx-terminalFirstBullet}{\huge\ttfamily\bfseries{$\bullet$}\textcolor{macosx-terminalSecondBullet}{\huge\ttfamily\bfseries{$\bullet$}\textcolor{macosx-terminalThirdBullet}{\huge\ttfamily\bfseries{$\bullet$}}}}},
	},
	ptxcd/terminal/ubuntu/.style={
	  colback=ubuntu-terminalBackground,
		colupper=ubuntu-terminalText,
		colframe=ubuntu-terminalFrame,
		title={\textcolor{ubuntu-terminalFirstBullet}{\huge{$\bullet$}}{\textcolor{ubuntu-terminalSecondBullet}{\huge{$\bullet$}}}{\textcolor{ubuntu-terminalThirdBullet}{\huge{$\bullet$}}}},
	}
}


\newcommand{\BFHterminalFormatLine}{%
	\def\FancyVerbFormatLine##1{\BFHterminalPrompt{}##1}%
}

\newtcblisting{ubuntu}{
	ptxcd/terminal/default,
	ptxcd/terminal/ubuntu
}

\newtcblisting{ubuntu*}[1]{
	ptxcd/terminal/default,
	ptxcd/terminal/ubuntu,
	#1
}

\newcommand{\setupLinuxPrompt}[1]{\pgfkeys{/terminal/.cd,host=ubuntu,#1}%
  \gdef\BFHterminalPrompt{\textcolor{\TerminalColor}{\small\ttfamily\bfseries \TerminalUser\url{@}\TerminalHost{\textcolor{ubuntu-terminalText}:}\textcolor{ubuntu-terminalText}{\url{~}}{\textcolor{ubuntu-terminalText}\TerminalPromptChar}\,}}
  \lstset{backgroundcolor=}
  \lstset{frame=}
  \lstset{numberstyle=}
  \lstset{numbers=none}
} %%tabular

\colorlet{macosx-terminalBackground}{white}
\colorlet{macosx-terminalText}{black}
\colorlet{macosx-terminalFrame}{gray!25}
\colorlet{macosx-terminalFirstBullet}{red!65}
\colorlet{macosx-terminalSecondBullet}{orange!52!yellow}
\colorlet{macosx-terminalThirdBullet}{green!80!black}

\newtcblisting{macos}{
	ptxcd/terminal/default,
	ptxcd/terminal/macos
}

\newtcblisting{macos*}[1]{
	ptxcd/terminal/default,
	ptxcd/terminal/macos,
	#1
}

\newcommand{\setupOSXPrompt}[1]{\pgfkeys{/terminal/.cd,host=macintosh,#1}%
  \gdef\BFHterminalPrompt{\textcolor{\TerminalColor}{\small\ttfamily\bfseries \TerminalUser\url{@}\TerminalHost{\textcolor{macosx-terminalText}:}\textcolor{macosx-terminalText}{\url{~}}{\textcolor{macosx-terminalText}\TerminalPromptChar}\,}}
  \lstset{backgroundcolor=}
  \lstset{frame=}
  \lstset{numberstyle=}
  \lstset{numbers=none}
} %%


\pgfkeys{
  /terminal/.cd,
  user/.code={\gdef\TerminalUser{#1}},user={},
  host/.code={\gdef\TerminalHost{#1}},host={},
  color/.code={\gdef\TerminalColor{#1}},color=white,
  prompt char/.code={\gdef\TerminalPromptChar{#1}},
  prompt char=\$,
  root/.style={user=root,color=BFH-MediumRed,prompt char=\#},
  student/.style={user=student,color=BFH-LightGreen,prompt char=\$},
  remote/.style={user=user,host=remotehost,color=BFH-LightPurple,prompt char=\$},
} %%

\newcommand{\StartConsole}{\gdef\BFHterminalPrompt{}}

\endinput