TRegExHighlighter component
PlusMemo Help Send comments on this topic.
TRegExHighlighter component

Glossary Item Box

 


Unit

RegExHilit (add U suffix for Unicode version)

 

Declaration (partial)

type

    TRegExHighlighter = class(TExtHighlighter);

  

Description

TRegExHighlighter is a non visual component to achieve extended keyword and section highlighting based on regular expressions in a TPlusMemo.  This is a component very similar to TExtHighlighter, except that keywords you enter are matched based regular expressions algorithms instead of plain keywords.  For example, if you define a keyword as "b.?se", all of the following tokens will be highlighted in the TPlusMemo text:

  bse

  base

  bose

 

It can also optionally consider start-stop sections with regular expressions (by setting property RegExStartStop to True).

 

TRegExHighlighter uses internally the RegExpr.pas unit and contained classes from Andrey V. Sorokin.  Electro-Concept Mauricie grants Mr. Sorokin credit for the regular expressions parsing code used in TRegExHighlighter.  Users who need to familiarize with regular expressions syntax are invited to consult the help file "TRegExpr.hlp", also from Mr. Sorokin.

 

How to use

To use this component, place a TRegExHighlighter on a form or datamodule.  Set TPlusMemo.Highlighter property to this TRegExHighlighter instance (named "RegExHighlighter1" by default).  Then define keywords and start-stop keys by doubleclicking the Keywords or StartStopKeys properties in the Object Inspector.

 

TRegExHighlighter is a descendant of TExtHighlighter, from which it inherits many of its properties and methods.  See topics 

TExtHighlighter component  for informations on extended highlighting in a TPlusMemo;

TExtKeywordList class  for information on positional dependency options;

TExtStartStopList class   for information on delimiter termination conditions; 

Collapsible blocks in TPlusMemo for the collapsible functionality.

 

It should be kept in mind that regular expression parsing is a much more compute intensive task than strict keyword matching.  The number of keywords (plus start-stop keys if RegExStartStop is True) should be kept reasonable to ensure responsiveness to typing.  It has been verified that modern platforms can handle over ten complex keywords without responsiveness degradation.  

 

Key properties

  Run-time only

  Active A boolean property that controls if the effect of the TExtHighlighter is on or off (inherited from TExtHighlighter);
  ExtendedSyntax A Boolean property that controls the regular expressions parsing engine;
  GreedyStyle A Boolean property that controls the regular expression parsing engine;
  Keywords A TExtKeywordList property that defines the regular expression keywords (inherited from TExtHighlighter);
  RegExStartStop A Boolean property that determines if start-stop sections are defined by as regular expressions or strict identifiers;
  RussianAlphaChars A Boolean property that controls the regular expressions parsing engine;
  Separators A string property that contains the word delimiters (inherited from TExtHighlighter);
  StartStopKeys A TExtStartStopList property to define the start-stop keys (inherited from TExtHighlighter);
  SubHighlighter A TPlusHighglighter property to further achieve highlighting provided by another highlighter component (inherited from TExtHighlighter).

 

Key events

  OnKeyword An event that occurs when a keyword is found, giving a chance to your application to reject it (inherited from TExtHighlighter);
  OnStart An event that occurs when a start key is found; like preceeding, your application can reject it (inherited from TExtHighlighter);
  OnStop Likewise, your application can reject the stop key just found (inherited from TExtHighlighter).