Home | Modules | Class Hierarchy | Alphabetical List | Compound List | Related Pages

# BaseEditor Class Reference
[Editor]

Inheritance diagram for BaseEditor:

## Detailed Description

Base Editor functionality.

This class implements basic functionality, which could be useful in application's editing system. This includes automatic top-level caching of hilighting state, outline structure creation, pair constructions search. This class has event-oriented structure. Each editor event is passed into this object and gets internal processing.

## Public Methods

| BaseEditor (ParserFactory *pf, LineSource *lineSource)
| Initial constructor.
void | setRegionCompact (bool compact)
| This method informs handler about internal form of requeried LineRegion lists, which is returned after the parsing process.
void | setRegionMapper (RegionMapper *rm)
| Installs specified RegionMapper, which maps HRC Regions into color data.
void | setRegionMapper (const String *hrdClass, const String *hrdName)
| Installs specified RegionMapper, which is created with ParserFactory methods and maintained internally by this handler.
void | setBackParse (int backParse)
| Specifies number of lines, for which parser would be able to run continual processing without highlight invalidation.
void | setFileType (FileType *ftype)
| Initial HRC type, used for parse processing.
FileType * | setFileType (const String &fileType)
| Initial HRC type, used for parse processing.
FileType * | chooseFileType (const String *fileName)
| Tries to choose appropriate file type from HRC database using passed fileName and first line of text (if available through lineSource).
FileType * | getFileType ()
| Returns currently used HRC file type.
void | addRegionHandler (RegionHandler *rh)
| Adds specified RegionHandler object into parse process.
void | removeRegionHandler (RegionHandler *rh)
| Removes previously added RegionHandler object.
PairMatch * | getPairMatch (int lineNo, int pos)
| Searches and creates pair match object.
PairMatch * | getEnwrappedPairMatch (int lineNo, int pos)
| Searches and creates pair match object of first enwrapping block.
void | releasePairMatch (PairMatch *pm)
| Frees previously allocated PairMatch object.
void | searchLocalPair (PairMatch *pm)
| Searches pair match in currently visible text.
void | searchGlobalPair (PairMatch *pm)
| Searches pair match in all available text, possibly, making additional processing.
LineRegion * | getLineRegions (int lno)
| Return parsed and colored LineRegions of requested line.
void | validate (int lno)
| Validates current state of the editor and runs parser, if needed.
void | idleJob (int time)
| Tries to do some parsing job while user is doing nothing.
void | modifyEvent (int topLine)
| Informs BaseEditor object about text modification event.
void | modifyLineEvent (int line)
| Informs about single line modification event.
void | visibleTextEvent (int wStart, int wSize)
| Informs about changes in visible range of text lines.
void | lineCountEvent (int newLineCount)
| Informs about total lines count change.
void | startParsing (int lno)
void | endParsing (int lno)
void | clearLine (int lno, String *line)
void | addRegion (int lno, String *line, int sx, int ex, const Region *region)
void | enterScheme (int lno, String *line, int sx, int ex, const Region *region, const Scheme *scheme)
void | leaveScheme (int lno, String *line, int sx, int ex, const Region *region, const Scheme *scheme)

## Data Fields

const Region * | def_Text
| Basic HRC region - default text (background color).
const Region * | def_Syntax
| Basic HRC region - syntax checkable region.
const Region * | def_Special
| Basic HRC region - special region.
const Region * | def_PairStart
| Basic HRC region - Paired region start.
const Region * | def_PairEnd
| Basic HRC region - Paired region end.
const RegionDefine * | rd_def_Text
| Basic HRC region mapping.
const RegionDefine * | rd_def_HorzCross
| Basic HRC region mapping.
const RegionDefine * | rd_def_VertCross
| Basic HRC region mapping.

## Protected Attributes

ErrorHandler * | feh

## Constructor & Destructor Documentation

BaseEditor::BaseEditor | ( | ParserFactory * | pf,
|  | LineSource * | lineSource
| ) |

Initial constructor.

Creates uninitialized base editor functionality support.

Parameters:

  pf | ParserFactory, used as source of all created parsers (HRC, HRD, Text parser). Can't be null.
  lineSource | Object, that provides parser with text data in line-separated form. Can't be null.

## Member Function Documentation

void BaseEditor::setRegionCompact | ( | bool | compact | ) |

This method informs handler about internal form of requeried LineRegion lists, which is returned after the parsing process.

Compact regions are guaranteed not to overlap with each other (this is achieved with more internal processing and more extensive cpu usage); non-compact regions are placed directly as they created by the TextParser and can be overlapped.

Note:
  By default, if method is not called, regions are not compacted.

Parameters:

  compact | Creates LineRegionsSupport (false) or LineRegionsCompactSupport (true) object to store lists of RegionDefine's

void BaseEditor::setRegionMapper | ( | RegionMapper * | rm | ) |

Installs specified RegionMapper, which maps HRC Regions into color data.

Parameters:

  rm | RegionMapper object to map region values into colors.

void BaseEditor::setRegionMapper | ( | const String * | hrdClass,
|  | const String * | hrdName
| ) |

Installs specified RegionMapper, which is created with ParserFactory methods and maintained internally by this handler.

If no one of two overloads of setRegionMapper is called, all work is started without mapping of extended region information.

Parameters:

  hrdClass | Class of RegionMapper instance
  hrdName | Name of RegionMapper instance

void BaseEditor::setBackParse | ( | int | backParse | ) |

Specifies number of lines, for which parser would be able to run continual processing without highlight invalidation.

Parameters:

  backParse | Number of lines. If <= 0, dropped into default value.

void BaseEditor::setFileType | ( | FileType * | ftype | ) |

| Initial HRC type, used for parse processing. If changed during processing, all text information is invalidated.

FileType * BaseEditor::setFileType | ( | const String & | fileType | ) |

| Initial HRC type, used for parse processing. If changed during processing, all text information is invalidated.

PairMatch * BaseEditor::getPairMatch | ( | int | lineNo,
|  | int | pos
| ) |

Searches and creates pair match object.

Returned object can be used later in the pair search methods. This object is valid only until reparse of it's line occured. After that event information about line region's references in it becomes invalid and, if used, can produce faults.

Parameters:

  lineNo | Line number, where to search paired region.
  pos | Position in line, where paired region to be searched. Paired Region is found, if it includes specified position or ends directly at one char before line position.

PairMatch * BaseEditor::getEnwrappedPairMatch | ( | int | lineNo,
|  | int | pos
| ) |

Searches and creates pair match object of first enwrapping block.

Returned object could be used as with getPairMatch method. Enwrapped block is the first meeted start of block, if moving from specified position to the left and top.

Parameters:

  lineNo | Line number, where to search paired region.
  pos | Position in line, where paired region to be searched.

void BaseEditor::releasePairMatch | ( | PairMatch * | pm | ) |

Frees previously allocated PairMatch object.

Parameters:

  pm | PairMatch object

void BaseEditor::searchLocalPair | ( | PairMatch * | pm | ) |

Searches pair match in currently visible text.

Parameters:

  pm | Unmatched pair match

void BaseEditor::searchGlobalPair | ( | PairMatch * | pm | ) |

Searches pair match in all available text, possibly, making additional processing.

Parameters:

  pm | Unmatched pair match

LineRegion * BaseEditor::getLineRegions | ( | int | lno | ) |

Return parsed and colored LineRegions of requested line.

This method validates current cache state and, if needed, calls Colorer parser to validate modified block of text. Size of reparsed text is choosed according to information about visible text range and modification events.

Todo:
  If number of lines, to be reparsed is more, than backParse parameter, then method will return null, until validate() method is called.

void BaseEditor::validate | ( | int | lno | ) |

Validates current state of the editor and runs parser, if needed.

This method can be called periodically in background thread to make possible background parsing process.

Parameters:

  lno | Line number, for which validation is requested. If this number is in the current visible window range, the part of text is validated, which is required for visual repaint. If this number is equals to -1, all the text is validated. If this number is not in visible range, optimal partial validation is used

void BaseEditor::idleJob | ( | int | time | ) |

Tries to do some parsing job while user is doing nothing.

Parameters:

  time | integer between 0 and 100, shows an abount of time, available for this job.

void BaseEditor::modifyEvent | ( | int | topLine | ) |

Informs BaseEditor object about text modification event.

All the text becomes invalid after the specified line.

Parameters:

  topLine | Topmost modified line of text.

void BaseEditor::modifyLineEvent | ( | int | line | ) |

Informs about single line modification event.

Generally, this type of event can be processed much faster because of pre-checking line's changed structure and cancelling further parsing in case of unmodified text structure.

Parameters:

  line | Modified line of text.

Todo:
  Not used yet! This must include special 'try' parse method.

void BaseEditor::visibleTextEvent | ( | int | wStart,
|  | int | wSize
| ) |

Informs about changes in visible range of text lines.

This information is used to make assumptions about text structure and to make faster parsing.

Parameters:

  wStart | Topmost visible line of text.
  wSize | Number of currently visible text lines. This number must includes all partially visible lines.

void BaseEditor::lineCountEvent | ( | int | newLineCount | ) |

| Informs about total lines count change. This must include initial lines number setting.

Colorer-take5 Library. Copyright © 1999-2003 Cail Lomecb.
Generated at Fri Sep 12 18:54:55 2003 by doxygen 1.3-rc2.