# eric7.EricGui.EricGenericDiffHighlighter

Module implementing a syntax highlighter for diff outputs.

### Global Attributes

_REGEX_CACHE

### Classes

EricGenericDiffHighlighter | Class implementing a generic diff highlighter.

### Functions

TERMINAL | Function to mark a pattern as the final one to search for.

## EricGenericDiffHighlighter

Class implementing a generic diff highlighter.

### Derived from

QSyntaxHighlighter

### Class Attributes

None

### Class Methods

None

### Methods

EricGenericDiffHighlighter | Constructor
__initColours | Private method to initialize the highlighter colours.
createRules | Public method to create the highlighting rules.
formats | Public method to determine the highlighting formats for a line of text.
generateRules | Public method to generate the rule set.
highlightBlock | Public method to highlight a block of text.
makeFormat | Public method to generate a format definition.
regenerateRules | Public method to initialize or regenerate the syntax highlighter rules.

### Static Methods

None

#### EricGenericDiffHighlighter (Constructor)

EricGenericDiffHighlighter(doc)

Constructor

doc
  reference to the text document (QTextDocument)

#### EricGenericDiffHighlighter.__initColours

__initColours()

Private method to initialize the highlighter colours.

#### EricGenericDiffHighlighter.createRules

createRules(*rules)

Public method to create the highlighting rules.

rules
  set of highlighting rules (list of tuples of rule pattern (string) and highlighting format (QTextCharFormat))

#### EricGenericDiffHighlighter.formats

formats(line)

Public method to determine the highlighting formats for a line of text.

line
  text line to be highlighted (string)

Return:
  list of matched highlighting rules (list of tuples of match object and format (QTextCharFormat))

#### EricGenericDiffHighlighter.generateRules

generateRules()

Public method to generate the rule set.

Note: This method must me implemented by derived syntax highlighters.

#### EricGenericDiffHighlighter.highlightBlock

highlightBlock(text)

Public method to highlight a block of text.

text
  text to be highlighted (string)

#### EricGenericDiffHighlighter.makeFormat

makeFormat(fg=None, bg=None, bold=False)

Public method to generate a format definition.

fg
  foreground color (QColor)
bg
  background color (QColor)
bold
  flag indicating bold text (boolean)

Return:
  format definiton (QTextCharFormat)

#### EricGenericDiffHighlighter.regenerateRules

regenerateRules()

Public method to initialize or regenerate the syntax highlighter rules.

Up

## TERMINAL

TERMINAL(pattern)

Function to mark a pattern as the final one to search for.

pattern
  pattern to be marked (string)

Return:
  marked pattern (string)

Up