Quantcast
Channel: Highlight variables prefixed with % and $ lstlisting - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

Highlight variables prefixed with % and $ lstlisting

$
0
0

I'm trying to get syntaxhighlighting comparable to this: Sample highlighting

(with $-prefixed variables as well)But I'm having issues with the %-prefixed identifiers. I tried doing it with

moredelim=*[s][\color{variableColor}]{\%}{\ }

Which has the obvious issue that it doesn't stop highlighting it if you seperate keywords with a dot. I also tried the solution proposed bu Jubobs here but I could not make it work with the % or $ marks.

This is my current code:

\lstnewenvironment{TorqueScript}{\lstset{ style=TS }}{}\definecolor{variableColor}{HTML}{AA7700}\definecolor{globalColor}{HTML}{FF1493}%\colorlet{globalColor}{ForestGreen!100}\colorlet{commentSColor}{ForestGreen!100}\colorlet{commentMColor}{ForestGreen!100}\colorlet{stringColor}{Blue!100}\colorlet{tagColor}{Blue!80!black}\definecolor{concatColor}{HTML}{008200}\colorlet{thisColor}{Red!100}\colorlet{identifierColor}{Blue}\definecolor{datablocksColor}{HTML}{444444}\definecolor{declarationColor}{HTML}{006699}\colorlet{functionColor}{white!30!black}\lstdefinelanguage{TorqueScript}{    basicstyle=\ttfamily,    showstringspaces=false    sensitive=false,    keywords=[0]{if, else, },    keywords=[1]{StaticShapeData, ParticleEmitterData, ParticleEmitterNodeData, ParticleData, ParticleEmitterNode,ClientGroup, SimGroup, SimObject,        GuiControl, GuiBitmapBorderControl, GuiBitmapControl, GuiControlProfile, GuiTextListCtrl, GuiScrollCtrl, GuiTextCtrl, GuiPanel, PlayerData, Material, StaticShapeData,}    keywords=[2]{SPC,@,TAB},    keywords=[3]{this},    keywords=[4]{delete, messageboxok, exec, echo, getcount, commandtoclient, commandtoserver, schedule, getObject, addObject, bind, getRowNumById, addRow, sortNumerical, clearSelection, setRowById, removeRowById, getWord, setWord, getWordCount, getField, setField, StripMLControlChars},     keywords=[5]{function, datablock, singleton, new},    morestring=[s][\color{stringColor}]{"}{"},    morestring=[s][\color{tagColor}]{'}{'},    morecomment=[l][\color{commentSColor}]{//},    morecomment=[s][\color{commentMColor}]{/*}{*/},    % Variables    moredelim=*[s][\color{variableColor}]{\%}{\ },    moredelim=*[s][\color{globalColor}]{\$}{\ },}\lstdefinestyle{TS}{    language=TorqueScript,    % Actual keywords    keywordstyle=[0]{\color{identifierColor}},    % Datablocks    keywordstyle=[1]{\color{datablocksColor}},    % Concatenators    keywordstyle=[2]{\color{concatColor}},    % this    keywordstyle=[3]{\color{thisColor}},    % functions    keywordstyle=[4]{\color{functionColor}},    % Actual keywords    keywordstyle=[5]{\bfseries \color{declarationColor}},%    xleftmargin=\parindent,    %identifierstyle=\color{blue}}

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images