\ThisIsLanguage{C}
\input highlighting_common.tex

%%%%%%%%%%*******    Setting up macros for fonts    *******%%%%%%%%%%

%We never use \bfseries and \itshape. Instead, we use \Clight, \Cbold, \itlight, \itbold,
% that default to the former but can be redefined to fast switch the font. E.g., as by
%
% \input Tutils-fastfonts-2.tex
% All formats below start with one of these so as not to rely on a default font (that would be the \Clight font).

\unless\ifdefined\Clight		\let\Clight=\relax\fi %Change nothing
\ifdefined\bfseries
  \unless\ifdefined\Cbold		\protected\def\Cbold{\bfseries}\fi
  \unless\ifdefined\itbold	\protected\def\itbold{\bfseries\slshape}\fi
  \unless\ifdefined\itlight	\protected\def\itlight{\slshape}\fi
\else
  \unless\ifdefined\Cbold		\protected\def\Cbold{\bf}\fi
  \unless\ifdefined\itbold	\protected\def\itbold{\bf\sl}\fi %Probably this ends up as just \sl
  \unless\ifdefined\itlight	\protected\def\itlight{\sl}\fi
\fi

%%%%%%%%%%*******    Definition of colours and styles for each category    *******%%%%%%%%%%

\DefineColor{comment}{.55, 0, .48}
\DefineGray{gray4}{0.33} %For obsolescent
\DefineColor{midyellow}{0.66, 0.66, 0.0} %For [deprecated] and the splice char
\DefineColor{blue}{0,0,1} % Named constant
\DefineColor{otherwords}{0.16, 0.16, 0.36}
\DefineColor{typedef}{0, 0, .55}
\DefineColor{member}{0, 0, .45} %Struct and union members. Slightly darker than typedef because they are not bold.
\DefineColor{constant}{0.15,0.72,0.50} %enum constants and constexpr identifiers
\DefineColor{function}{0, .35, 0}
\DefineColor{tgfunction}{0.33, .4, 0}
\DefineColor{macro}{.55, 0, 0}
\DefineColor{pragma}{.38, 0, .25}
\DefineColor{tag}{.38, 0.15, .38} %Struct, union and enum tags
\DefineColor{string}{.42, .1, .05}
\DefineColor{wstring}{.33, 0, .14}

%Althought puncturators do not get recognized as words by the macros (obviously), it imay be useful
% to have \FormatC@+, say, defined. This can be achieved by \MakeWord'ing them {Punctuator}.
% # and ## are permanent (according to C23-prepro.tex)
\TcodeEdefFormat{Punctuator}{\Clight} %Operator is already in use
\TcodeEdefFormat{PPPunctuator}{\Clight} %For # and ##
\TcodeEdefFormat{SpliceChar}{\Clight\ColFill{midyellow}} %A \ at end of line

%We use \color for comments and strings instead of \ColFill because they may contain handcrafted rules.
\TcodeEdefFormat{Comment}{\Clight\color{comment}}

%Character literals the same as strings
\TcodeEdefFormat{String}{\Clight\color{string}}	\TcodeEdefFormat{StringWide}{\Clight\color{wstring}}
\TcodeEdefFormat{CharLit}{\Clight\color{string}}	\TcodeEdefFormat{CharLitW}{\Clight\color{wstring}}

\TcodeEdefFormat{Number}{\Clight}
	\TCopyFormat{IntegerSuffix}{Number}
	\TCopyFormat{FloatingSuffix}{Number}
\TcodeEdefFormat{OtherWords}{\Clight\ColFill{otherwords}}

\TcodeEdefFormat{PPDirective}{\Cbold}
	\TCopyFormat{PPOperator}{PPDirective}
\TcodeEdefFormat{Pragma}{\Cbold\ColFill{pragma}}
\TcodeEdefFormat{PragmaValue}{\Clight\ColFill{pragma}}
\TcodeEdefFormat{PPParameter}{\Cbold\ColFill{pragma}}

\TcodeEdefFormat{Keyword}{\Cbold}
\TcodeEdefFormat{NamedConstant}{\Cbold\ColFill{blue}} %true, false, nullptr

\TcodeEdefFormat{Function}{\Cbold\ColFill{function}}
\TcodeEdefFormat{TGFunction}{\Cbold\ColFill{tgfunction}} %type generic functions
	\TCopyFormat{QGFunction}{TGFunction}

%Identifiers that are both function and TG-function, like acos, may be defined to either of them or to
%FuncTGFunc. But this is not defined. The user must redirect them to Function or to TGFunction.
%We route them by default to TGFunction.
\TcodeRedirect{FuncTGFunc}{TGFunction}

\TcodeEdefFormat{Typedef}{\Cbold\ColFill{typedef}}
\TcodeEdefFormat{StandsForType}{\itbold\ColFill{typedef}}
\TcodeEdefFormat{Macro}{\Cbold\ColFill{macro}}
\TCopyFormat{NamedIdent}{Macro} %__func__, errno, stdin...

\TcodeEdefFormat{Attribute}{\Cbold\ColFill{tag}}
\TcodeEdefFormat{Struct}{\Cbold\ColFill{tag}} %Struct tag
\TcodeEdefFormat{Union}{\Cbold\ColFill{tag}} %Union tag
\TcodeEdefFormat{Enum}{\Cbold\ColFill{tag}} %Enum tag
\TcodeEdefFormat{StrMember}{\Clight\ColFill{member}}
\TcodeEdefFormat{UnionMember}{\Clight\ColFill{member}}
\TcodeEdefFormat{EnumConst}{\Clight\ColFill{constant}}

\TcodeEdefFormat{Obsolete}{\Cbold\ColFill{gray4}} %Obsolescent
\TcodeEdefFormat{Deprecated}{\Cbold\ColFill{midyellow}} %Identifiers marked [deprecated]

\input C_subcategories.tex