Created
October 14, 2019 07:59
-
-
Save schors/e56679852e8bb0774fa75ec9397ce18f to your computer and use it in GitHub Desktop.
Реализация btLstHL для подсветки строк и оверлея
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\makeatletter | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% | |
% \btIfInRange{number}{range list}{TRUE}{FALSE} | |
% | |
% Test in int number <number> is element of a (comma separated) list of ranges | |
% (such as: {1,3-5,7,10-12,14}) and processes <TRUE> or <FALSE> respectively | |
\newcount\bt@rangea | |
\newcount\bt@rangeb | |
\newcommand\btIfInRange[2]{% | |
\global\let\bt@inrange\@secondoftwo% | |
\edef\bt@rangelist{#2}% | |
\foreach \range in \bt@rangelist {% | |
\afterassignment\bt@getrangeb% | |
\bt@rangea=0\range\relax% | |
\pgfmathtruncatemacro\result{ ( #1 >= \bt@rangea) && (#1 <= \bt@rangeb) }% | |
\ifnum\result=1\relax% | |
\breakforeach% | |
\global\let\bt@inrange\@firstoftwo% | |
\fi% | |
}% | |
\bt@inrange% | |
} | |
\newcommand\bt@getrangeb{% | |
\@ifnextchar\relax% | |
{\bt@rangeb=\bt@rangea}% | |
{\@getrangeb}% | |
} | |
\def\@getrangeb-#1\relax{% | |
\ifx\relax#1\relax% | |
\bt@rangeb=100000% \maxdimen is too large for pgfmath | |
\else% | |
\bt@rangeb=#1\relax% | |
\fi% | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% | |
% \btLstHL<overlay spec>{range list} | |
% | |
% TODO BUG: \btLstHL commands can not yet be accumulated if more than one overlay spec match. | |
% | |
\newcommand<>{\btLstHL}[1]{% | |
\only#2{\btIfInRange{\value{lstnumber}}{#1}{\color{acmel1}\def\lst@linebgrdcmd{\color@block}}{\def\lst@linebgrdcmd####1####2####3{}}}% | |
}% | |
\makeatother |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment