# eric6.Plugins.VcsPlugins.vcsGit.GitDiffHighlighter

Module implementing a syntax highlighter for diff outputs.

### Global Attributes

None

### Classes

E5GenericDiffHighlighter | Class implementing a generic diff highlighter.
GitDiffHighlighter | Class implementing a diff highlighter for Git.

### Functions

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

## E5GenericDiffHighlighter

Class implementing a generic diff highlighter.

### Derived from

QSyntaxHighlighter

### Class Attributes

None

### Class Methods

None

### Methods

E5GenericDiffHighlighter | Constructor
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.

### Static Methods

None

#### E5GenericDiffHighlighter (Constructor)

E5GenericDiffHighlighter(doc)

Constructor

doc
  reference to the text document (QTextDocument)

#### E5GenericDiffHighlighter.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))

#### E5GenericDiffHighlighter.formats

formats(line)

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

line
  text line to be highlighted (string)

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

#### E5GenericDiffHighlighter.generateRules

generateRules()

Public method to generate the rule set.

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

#### E5GenericDiffHighlighter.highlightBlock

highlightBlock(text)

Public method to highlight a block of text.

text
  text to be highlighted (string)

#### E5GenericDiffHighlighter.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)

Returns:
  format definiton (QTextCharFormat)

Up

## GitDiffHighlighter

Class implementing a diff highlighter for Git.

### Derived from

E5GenericDiffHighlighter

### Class Attributes

None

### Class Methods

None

### Methods

GitDiffHighlighter | Constructor
generateRules | Public method to generate the rule set.

### Static Methods

None

#### GitDiffHighlighter (Constructor)

GitDiffHighlighter(doc, whitespace=True)

Constructor

doc
  reference to the text document (QTextDocument)
whitespace
  flag indicating to highlight whitespace at the end of a line (boolean)

#### GitDiffHighlighter.generateRules

generateRules()

Public method to generate the rule set.

Up

## TERMINAL

TERMINAL(pattern)

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

pattern
  pattern to be marked (string)

Returns:
  marked pattern (string)

Up