\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{yslistings}
\RequirePackage{listings}
\RequirePackage{lstautogobble}
\RequirePackage{fontawesome}

\newbox\codebreakbox
\setbox\codebreakbox=\hbox{\textcolor[gray]{.75}{\scriptsize\upshape\faChevronCircleRight}}

\lstset{upquote=true,basicstyle=\ttfamily\NoAutoSpacing, keepspaces=true,  columns=fullflexible, showstringspaces=false, commentstyle=\slshape, mathescape=true, stepnumber = 1, numberstyle=\scriptsize, numbersep=10pt, firstnumber=auto, breaklines=true, breakatwhitespace=true, prebreak={\copy\codebreakbox}, postbreak={\copy\codebreakbox}, autogobble, includerangemarker=false}
\lstset{literate=
  {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
  {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
  {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
  {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
  {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
  {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
  {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
  {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
  {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
  {ű}{{\H{u}}}1 {Ű}{{\H{U}}}1 {ő}{{\H{o}}}1 {Ő}{{\H{O}}}1
  {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
  {€}{{\euro}}1 {£}{{\pounds}}1 {«}{{\guillemotleft}}1
  {»}{{\guillemotright}}1 {ñ}{{\~n}}1 {Ñ}{{\~N}}1 {¿}{{?`}}1
}
\lstdefinestyle{numbers}{numbers = left}
\lstdefinestyle{nonumbers}{numbers = none}
\let\nm\|

\lstdefinelanguage{mybash}[]{bash}
{ morekeywords={ls, stat}}

\lstdefinelanguage{mysql}[]{sql}
{ }

\lstdefinelanguage{mypython}[]{python}
{ morekeywords={yield, as}}

\lstdefinelanguage{mycaml}[Objective]{caml}
{ morekeywords={raise}}

\def\|{\lstinline[language=mypython, name=inlinepython]|} %|
\def\°{\lstinline[language={mycaml}, name=inlinecaml]°} %°
\def\§{\lstinline[language=mysql, name=inlinesql]§} %§
\def\>{\lstinline[language=mybash, name=inlineshell]>} %>
\def\£{\lstinline[language={[x86masm]Assembler}]£} %£
\lstnewenvironment{lstpython}[1][]{\leavevmode\lstset{language=mypython, frame=single, frameround=tttt, #1}}{}
\lstnewenvironment{lstcaml}[1][]{\leavevmode\lstset{language=mycaml, frame=single, frameround=tttt, #1}}{}
\lstnewenvironment{lstsql}[1][]{\leavevmode\lstset{language=mysql, frame=single, frameround=tttt, #1}}{}
\lstnewenvironment{lstshell}[1][]{\leavevmode\lstset{language=mybash, frame=single, frameround=tttt, #1}}{}
\newcommand\lstinputcaml[1][]{\leavevmode\lstinputlisting[language={mycaml}, frame=single, frameround=tttt, rangeprefix=(***\ , rangesuffix=\ ***), #1]}
\newcommand\lstinputpython[1][]{\leavevmode\lstinputlisting[language={mypython}, frame=single, frameround=tttt, rangeprefix=\#\#\#\ , rangesuffix=\ \#\#\#, #1]}
\newcommand\lstinputsql[1][]{\leavevmode\lstinputlisting[language={mysql}, frame=single, frameround=tttt, rangeprefix=---\ , rangesuffix=\ ---, #1]}


\lstdefinelanguage{algorithme}{%
  morekeywords={Si, alors, TantQue, faire, PourChaque, FinSi, FinPour, FinTantQue, Fonction, Renvoyer, Sinon},
  sensitive=true,
  morestring=[b]",
  morecomment=[s]{/*}{*/},
  literate=*{:=}{{\hbox{\textbf{prend la valeur de}}}}{18}{Créer}{{\hbox{\textbf{Créer}}}}{5}{Définir}{{\hbox{\textbf{Définir}}}}{7}{<-result->}{{\hbox{\textbf{Le résultat est}}}}{15}
}
\lstnewenvironment{lstalgo}[1][]{\leavevmode\lstset{columns=fullflexible, basicstyle=\rmfamily\NoAutoSpacing, language=algorithme, frame=single, frameround=tttt, #1}}{}

\newbox\hoareboxB
\newbox\hoareboxC
\newbox\hoareboxA
%\newenvironment{trhoare}[2]{\setbox\hoarebox=\hbox\begingroup\begin{lstpython}[frame=none, basicstyle=\ttfamily\scriptsize]
%}{\end{lstpython}\endgroup}\left\{#1\vphantom{\copy\hoarebox}\right\}\quad\copy\hoarebox\quad\left\{\vphantom{\copy\hoarebox}#3\right\}}

%\long\def\trhoare#1\trhcode{\setbox\hoareboxB=\hbox{#1}}

\endinput