Detecting if the current line is inside an {$IfDef} / {$Endif} Block. lazarus / 69-SynEdit ---------------------------------------------------------------------- EganSolo · 2016-12-24 09:39 Consider this admittedly contrived bit of code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$Define Debug} {$IfDef Debug}{.$Define DebugXYZ} {$IfDef DebugXYZ} procedure XYZ;begin  {Some code here...}  Counter := Counter + 1; {first instance}end; {$Else} Procedure XYZ;begin  {Some other code...}  Counter := Counter + 1; {second instance}end; {$Endif} {$Else} Procedure OptimizedXYZ;   {Some code...}   Counter := Counter + 1; {3rd instance}end; {$EndIf} {$EndIf}   Code which is not active should be shown as dimmed. So assume the highlighter is working on the first instance of Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Counter := Counter + 1; To determine if the highlighting should be dimmed or not, it needs to find out the conditional context this line is in. If I can write a method that returns a list of pairs as in : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function ConditionalDirectiveContext(const aLineNumber: LineNumber): ; Which returns a list of pairs as follows: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i (  (xcfbt_IfDefDirective, 'DebugXYZ'),  (xcfbt_IfDefDirective, 'Debug'   )) Then, I could quickly determine that the directive DebugXYZ is active but the directive Debug is not, therefore I should return a dimmed attribute. That would do it. If I could subclass TSynCustomCodeFoldBlock and add a text property called DirectiveName then I should be home free. But I'm a bit stumped. I know I can subclass TSynCustomCodeFoldBlock.I also know I can override override the GetRangeClass in TSynCustomFoldHighlighter to get replace TSynCustomHighlighterRange with my descendant. Where I'm stumped is that I can't figure out how subclassing TSynCustomHighlighterRange would help. There doesn't seem to be a way to tell this class to use my subclass of TSynCustomCodeFoldBlock. What am I missing?