%%%==============================================================================
%% Copyright 2022-present by Alceu Frigeri
%%
%% This work may be distributed and/or modified under the conditions of
%%
%% * The [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
%%   version 1.3c (or later), and/or
%% * The [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html),
%%   version 3 (or later)
%%
%% This work has the LPPL maintenance status *maintained*.
%%
%% The Current Maintainer of this work is Alceu Frigeri
%%
%% This is version {2.10} {2024/04/20}
%%
%% The list of files that compose this work can be found in the README.md file at
%% https://ctan.org/pkg/ufrgscca
%%
%%%==============================================================================
%% UFRGS stands for "Federal University of Rio Grande do Sul" in south Brazil
%% EE    stands for "Engineering School"
%% CCA   stands for "Control and Automation Engineering Course" (Portuguese acronym)
%%%==============================================================================
\NeedsTeXFormat{LaTeX2e}[2023/11/01]


\ProvidesExplPackage
    {ufrgscca-lists}
    {2024/04/20}
    {2.10}
    {UFRGS/CCA auxiliary lists commands}


%%%%%%%
%%%
%%% Just an attempt of having my packages info in a regular way
%%% Idea being: { <pck-name> / pkg info } for each and all.
%%%
%%%%%%%
\keys_define:nn { ufrgscca-lists / pkg info}
  {
     name        .code:n = {ufrgscca-lists} ,
     prefix      .code:n = {ufrgscca} ,
     date        .code:n = {2024/04/20} ,
     version     .code:n = {2.10} ,
     description .code:n = {UFRGS/CCA~Auxiliary~ lists~ commands}
  }
\cs_if_exist:NF \PkgInfo 
  {
    \NewDocumentCommand \PkgInfo {mm} { \keys_set:nn {#1 / pkg info}{#2} } 
    \NewDocumentCommand \PkgDescription {m} 
      { \noindent Package~ \textbf{\PkgInfo{#1}{name}}~Version:~\PkgInfo{#1}{version}~ -~ \PkgInfo{#1}{date}\par \emph{\PkgInfo{#1}{description}}~\par } 
  }  
%%%%%%%
%%% End of cut-n-paste
%%%%%%%



%==============================================================================
% Declaração de opções
%==============================================================================
\keys_define:nn { ufrgscca  / lists}
  {
    relnum      .usage:n        = load ,
	relnum      .bool_set:N     = \l__ufrgscca_relnum_bool ,
  }

\ProcessKeyOptions[ufrgscca / lists]\relax


%%%%%%%%%%%%%%%%%%%%%
%%% Packages Loading
%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{newfloat}
\RequirePackage{listings}
\RequirePackage{xcolor}

%%%
%%% command to declare a new 'list of ...' things {package newfloat}
%%%
\NewDocumentCommand{\DeclareNewFloat}{mmmm}{
 \DeclareFloatingEnvironment[
  fileext={#2},
	listname={#4},
	name={#3},
	placement=htb,
	chapterlistsgaps=off]{#1} 
    \bool_if:NTF \l__ufrgscca_relnum_bool
        { \SetupFloatingEnvironment{#1}{within=chapter} }
        { \SetupFloatingEnvironment{#1}{within=none} }
}


%
%%%%\def\listoflistings{\lstlistoflistings}%
\definecolor{lstgray}{rgb}{0.965,0.965,0.965}
\lstset{basicstyle=\ttfamily\small,
  columns=fullflexible,
  keepspaces=true,
  frame=tb,
  inputencoding=latin1,
%  inputencoding=utf8,
  extendedchars=true,
  backgroundcolor=\color{lstgray},
	breaklines=true,
%	xleftmargin=7pt,
%	xrightmargin=7pt
}


\def\listingname{Listing}
\def\listlistingname{List~ of~ Listings}
\DeclareNewFloat{codelist}{lox}{\listingname}{\listlistingname}



