diff options
author | Karl Berry <karl@freefriends.org> | 2017-09-05 21:56:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-09-05 21:56:47 +0000 |
commit | a62f77790bf4d66905f22ad01203d3b08301f6e5 (patch) | |
tree | 553ed7ec1840ccfe6cab7e2425874def4ea43215 /Master/texmf-dist/tex/latex/algobox/algobox.sty | |
parent | 4bc5b2eef4dde44c1ae2a1f191b7bb5ddee7c121 (diff) |
algobox (5sep17)
git-svn-id: svn://tug.org/texlive/trunk@45223 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/algobox/algobox.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/algobox/algobox.sty | 135 |
1 files changed, 90 insertions, 45 deletions
diff --git a/Master/texmf-dist/tex/latex/algobox/algobox.sty b/Master/texmf-dist/tex/latex/algobox/algobox.sty index 86be6ae0a29..b8d65ad15fb 100644 --- a/Master/texmf-dist/tex/latex/algobox/algobox.sty +++ b/Master/texmf-dist/tex/latex/algobox/algobox.sty @@ -6,7 +6,7 @@ %% %% algobox.dtx (with options: `package') %% -%% File: algobox.dtx (C) Copyright 2016 RIVAUD Julien +%% File: algobox.dtx (C) Copyright 2016-2017 RIVAUD Julien %% %% It may be distributed and/or modified under the conditions of the %% General Public License (GPL), either version 3 of this @@ -15,8 +15,8 @@ \RequirePackage{expl3}[2016/01/19] \def\ExplFileName{algobox} \def\ExplFileDescription{Typeset Algobox programs} -\def\ExplFileDate{2017/09/03} -\def\ExplFileVersion{1.1} +\def\ExplFileDate{2017/09/04} +\def\ExplFileVersion{1.2a} \ProvidesExplPackage {\ExplFileName}{\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription} \RequirePackage{xparse} @@ -31,14 +31,16 @@ \int_new:N \l__algobox_level_int + \definecolor{algoboxarbre}{RGB}{146,146,146} -\colorlet {algoboxcommentaire}{algoboxarbre!70!black} -\definecolor{algoboxstructure}{RGB}{134,0,0} -\definecolor{algoboxmotclef}{RGB}{25,3,180} -\definecolor{algoboxsialors}{RGB}{147,0,128} -\definecolor{algoboxpour}{RGB}{187,136,0} -\definecolor{algoboxtantque}{RGB}{222,111,6} -\definecolor{algoboxnormal}{RGB}{0,0,0} +\definecolor{algoboxColorStandard}{HTML}{000000} +\definecolor{algoboxColorComment}{HTML}{606060} +\definecolor{algoboxColorBloc}{HTML}{800000} +\definecolor{algoboxColorCommande}{HTML}{0000CC} +\definecolor{algoboxColorSi}{HTML}{800080} +\definecolor{algoboxColorTantQue}{HTML}{DD6F06} +\definecolor{algoboxColorPour}{HTML}{BB8800} +\definecolor{algoboxColorFonction}{HTML}{9A4D00} \tikzset{ every~algobox/.style=, @@ -52,31 +54,35 @@ algobox~indent/.style={xshift=2em}, algobox~normal/.style={ font=\sffamily, - color=algoboxnormal, + color=algoboxColorStandard, }, algobox~commentaire/.style={ algobox~normal/.try, - color=algoboxcommentaire, + color=algoboxColorComment, }, - algobox~motclef/.style={ + algobox~commande/.style={ algobox~normal/.try, - color=algoboxmotclef, + color=algoboxColorCommande, }, algobox~structure/.style={ font=\sffamily\bfseries, - color=algoboxstructure + color=algoboxColorBloc }, algobox~sialors/.style={ algobox~structure/.try, - color=algoboxsialors, + color=algoboxColorSi, }, algobox~pour/.style={ algobox~structure/.try, - color=algoboxpour, + color=algoboxColorPour, }, algobox~tantque/.style={ algobox~structure/.try, - color=algoboxtantque, + color=algoboxColorTantQue, + }, + algobox~fonctions/.style={ + algobox~structure/.try, + color=algoboxColorFonction, }, } @@ -192,38 +198,26 @@ } } -\NewDocumentCommand \__algobox_VARIABLES:w {} { - \__algobox_indent:nn {structure} {VARIABLES} -} - \NewDocumentCommand \__algobox_ESTDUTYPE:w { +u{\ESTDUTYPE} +u{\;} } { \__algobox_block:nn {normal} { \ignorespaces #1 \unskip\c_space_token\null } - \__algobox_node:nn {motclef}{EST_DU_TYPE} + \__algobox_node:nn {commande}{EST_DU_TYPE} \__algobox_node:nn {normal}{\null\c_space_token#2} } -\NewDocumentCommand \__algobox_DEBUTALGORITHME:w {} { - \int_compare:nNnT \l__algobox_level_int = \c_one { - % if there was a VARIABLES before - \__algobox_unindent: - } - \__algobox_indent:nn {structure} {DEBUT_ALGORITHME} -} - \NewDocumentCommand \__algobox_FINALGORITHME:w {} { - \int_compare:nNnT \l__algobox_level_int = \c_one { + \int_while_do:nNnn \l__algobox_level_int > \c_zero { \__algobox_unindent: - \__algobox_block:nn {structure} {FIN_ALGORITHME} } + \__algobox_block:nn {structure} {FIN_ALGORITHME} } \NewDocumentCommand \__algobox_PRENDLAVALEUR:w { u{\PRENDLAVALEUR} m } { \__algobox_block:nn {normal} { \ignorespaces#1\unskip\c_space_token\null } - \__algobox_node:nn {motclef}{PREND_LA_VALEUR} + \__algobox_node:nn {commande}{PREND_LA_VALEUR} \__algobox_node:nn {normal}{\null\c_space_token#2} } @@ -278,6 +272,14 @@ \__algobox_unindent: } +\NewDocumentCommand \__algobox_FONCTION:w { +u{\;} } { + \int_while_do:nNnn \l__algobox_level_int > \c_one { + \__algobox_unindent: + } + \__algobox_indent:nn {fonctions} {FONCTION} + \__algobox_node:nn {normal}{\null\c_space_token#1} +} + \NewDocumentCommand \__algobox_LINE:w { s O{normal} m } { \IfBooleanTF {#1} { \__algobox_indent:nn {#2} {#3} @@ -292,6 +294,52 @@ } +\cs_new_protected_nopar:Nn \__algobox_make_keyword:n { + \tl_set:Nn \l_tmpa_tl {#1} + \tl_replace_all:Nnn \l_tmpa_tl {_} {} + \cs_set:cpn {\l_tmpa_tl} {\__algobox_keyword:nw {#1}} +} + +\NewDocumentCommand \__algobox_keyword:nw {m +u{\;}} { + \__algobox_block:nn {commande} {#1} + \__algobox_node:nn {normal}{\null\c_space_token#2} +} + +\cs_new_protected_nopar:Nn \__algobox_make_structure:nn { + \tl_set:Nn \l_tmpa_tl {#2} + \tl_replace_all:Nnn \l_tmpa_tl {_} {} + \cs_set:cpn {\l_tmpa_tl} {\__algobox_topstructure:nn {#1}{#2}} +} + +\cs_new_protected_nopar:Nn \__algobox_topstructure:nn { + \int_while_do:nNnn \l__algobox_level_int > \c_zero { + \__algobox_unindent: + } + \__algobox_indent:nn {#1} {#2} +} + +\cs_new_protected_nopar:Nn \__algobox_make_func_structure:nn { + \tl_set:Nn \l_tmpa_tl {#1} + \tl_replace_all:Nnn \l_tmpa_tl {_} {} + \cs_set:cpn {\l_tmpa_tl} {\__algobox_funcstructure:nn {#1}{#2}} +} + +\cs_new_protected_nopar:Nn \__algobox_funcstructure:nn { + \int_while_do:nNnn \l__algobox_level_int > \c_two { + \__algobox_unindent: + } + \bool_if:nTF {#2}{\__algobox_indent:nn}{\__algobox_block:nn} {fonctions} {#1} +} + +\clist_const:Nn \c__algobox_keywords_clist { + PAUSE, LIRE, AFFICHERCALCUL, AFFICHER, + TRACER_POINT, TRACER_POINT_Rouge, TRACER_POINT_Vert, + TRACER_POINT_Bleu, TRACER_POINT_Blanc, + TRACER_SEGMENT, TRACER_SEGMENT_Rouge, TRACER_SEGMENT_Vert, + TRACER_SEGMENT_Bleu, TRACER_SEGMENT_Blanc, + RENVOYER, APPELER_FONCTION +} + \cs_new_protected_nopar:Nn \__algobox_begincode:n { \int_zero:N \l__algobox_level_int \begin{tikzpicture}[#1] @@ -301,27 +349,24 @@ \cs_set_eq:NN \; \prg_do_nothing: \cs_set_eq:NN \LINE \__algobox_LINE:w \cs_set_eq:NN \NODE \__algobox_NODE:w - \cs_set_eq:NN \VARIABLES \__algobox_VARIABLES:w - \cs_set_eq:NN \DEBUTALGORITHME \__algobox_DEBUTALGORITHME:w \cs_set_eq:NN \FINALGORITHME \__algobox_FINALGORITHME:w \cs_set_eq:NN \SI \__algobox_SI:w \cs_set_eq:NN \POUR \__algobox_POUR:w \cs_set_eq:NN \TANTQUE \__algobox_TANTQUE:w - \cs_set:Npn \AFFICHER {\__algobox_keyword:nw {AFFICHER}} - \cs_set:Npn \AFFICHERCALCUL {\__algobox_keyword:nw {AFFICHERCALCUL}} - \cs_set:Npn \LIRE {\__algobox_keyword:nw {LIRE}} - \cs_set:Npn \PAUSE {\__algobox_block:nn{motclef}{PAUSE}} + \cs_set_eq:NN \FONCTION \__algobox_FONCTION:w \cs_set:Npn \//##1\; {\__algobox_block:nn{commentaire}{//##1}} + \clist_map_function:NN \c__algobox_keywords_clist \__algobox_make_keyword:n + \__algobox_make_structure:nn {structure} {VARIABLES} + \__algobox_make_structure:nn {structure} {DEBUT_ALGORITHME} + \__algobox_make_structure:nn {fonctions} {FONCTIONS_UTILISEES} + \__algobox_make_func_structure:nn {VARIABLES_FONCTION} \c_true_bool + \__algobox_make_func_structure:nn {DEBUT_FONCTION} \c_false_bool + \__algobox_make_func_structure:nn {FIN_FONCTION} \c_false_bool } \cs_new_protected_nopar:Nn \__algobox_closecode: { \end{tikzpicture} } -\NewDocumentCommand \__algobox_keyword:nw {m +u{\;}} { - \__algobox_block:nn {motclef} {#1} - \__algobox_node:nn {normal}{\null\c_space_token#2} -} - \NewDocumentCommand \smalgobox { O{} m } { \group_begin: \__algobox_begincode:n {every~smalgobox/.try,#1} |