CodeView  Version0.4
 All Classes Functions Variables
Public Member Functions | List of all members
cv::Format Class Referenceabstract

The base class for all source code formaters. More...

#include <format.h>

Inheritance diagram for cv::Format:
cv::Format_C cv::Format_HTML cv::Format_java cv::Format_Perl cv::Format_Ruby

Public Member Functions

virtual uint GetStyleCount ()=0
 Get the number of different styles supported by this format. More...
 
virtual const os::String & GetStyleName (char nStyle)=0
 Get the name of the given style. More...
 
virtual void SetStyle (char nStyle, const CodeViewStyle &cStyle)=0
 Set the color used to display the given style. More...
 
virtual const CodeViewStyleGetStyle (char nStyle)=0
 Get the color used to display the given style. More...
 
virtual CodeViewContext Parse (const os::String &cText, os::String &cStyle, CodeViewContext nContext)=0
 Parse a line and assign styles to each character. More...
 
virtual os::String GetIndentString (const os::String &cText, bool bUseTabs, uint nTabSize)=0
 Get the string used to prefix the next line. More...
 
virtual uint GetPreviousWordLimit (const os::String &cLine, uint nChr)=0
 Get the character index of the previous word limit. More...
 
virtual uint GetNextWordLimit (const os::String &cLine, uint nChr)=0
 Get the character index of the next word limit. More...
 
virtual int GetFoldLevel (const os::String &cLine, int nOldFoldLevel)
 Find foldable sections. More...
 

Detailed Description

The base class for all source code formaters.

To implement syntax coloring and other features for a new language, you must write a class inheriting from this and set it on the CodeView with CodeView::SetFormat()

Author
Andreas Engh-Halstvedt (aeh@o.nosp@m.pera.nosp@m.mail..nosp@m.com)

Member Function Documentation

virtual int cv::Format::GetFoldLevel ( const os::String &  cLine,
int  nOldFoldLevel 
)
inlinevirtual

Find foldable sections.

Returns nOldFoldLevel + 1 if cLine contains something that can start a foldable section. Returns nOldFoldLevel - 1 if the line contains something that can end a foldable section. If the line doesn't contain any of those, nOldFoldLevel is returned unchanged.

Parameters
cLineA line parse.
nOldFoldLevelSet to 0 in the first call. In subsequent calls, it should be passed the value returned by the previous call.

Reimplemented in cv::Format_C, and cv::Format_java.

virtual os::String cv::Format::GetIndentString ( const os::String &  cText,
bool  bUseTabs,
uint  nTabSize 
)
pure virtual

Get the string used to prefix the next line.

The format will analyze the given line and return a string to be used as prefix to the next line. This may be used to implement auto indenting of code.

As an example, for C++ the line "\t\tFlush();" may return the string "\t\t".

Parameters
cTextThe line to analyze.
bUseTabsUse TABs to indent.
nTabSizeLength of each TAB.
Returns
The string to prefix the next string with.
See Also
CodeView::setTabSize()
CodeView::getTabSize()
CodeView::setUseTab()
CodeView::getUseTab()

Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.

virtual uint cv::Format::GetNextWordLimit ( const os::String &  cLine,
uint  nChr 
)
pure virtual

Get the character index of the next word limit.

What is considered a word is up to the format.

Parameters
nLineThe line to analyze.
nChrThe character index to start from.
Returns
The character index of the next word limit, or the length if the string if none are found.

Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.

virtual uint cv::Format::GetPreviousWordLimit ( const os::String &  cLine,
uint  nChr 
)
pure virtual

Get the character index of the previous word limit.

What is considered a word is up to the format.

Parameters
nLineThe line to analyze.
nChrThe character index to start from.
Returns
The character index of the previous word limit, or 0 if the string if none are found.

Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.

virtual const CodeViewStyle& cv::Format::GetStyle ( char  nStyle)
pure virtual

Get the color used to display the given style.

This method must return a color for each of the styles in the range from 0 through getStyleCount()-1. The method is not defined for methods outside of this range, but implementors are encouraged to handle this gracefully.

Parameters
nStyleThe number of the style to return.
Returns
The color to display the given style with.

Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.

virtual uint cv::Format::GetStyleCount ( )
pure virtual

Get the number of different styles supported by this format.

Each format has a maximum number of styles it may use. This number can be in the range 1-255, and should not change during use, but the format is not required to actually use all of them.

Returns
The number of styles supported by this format.

Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.

virtual const os::String& cv::Format::GetStyleName ( char  nStyle)
pure virtual

Get the name of the given style.

This method must return a name for each of the styles in the range from 0 through getStyleCount()-1. The method is not defined for styles outside of this range, but implementors are encouraged to handle this gracefully.

The names are intended used in configuration dialogs.

Parameters
styleThe number of the style to return.
Returns
A string containing the display name of the given style.

Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.

virtual CodeViewContext cv::Format::Parse ( const os::String &  cText,
os::String &  cStyle,
CodeViewContext  nContext 
)
pure virtual

Parse a line and assign styles to each character.

The method will parse a single line of text and store the correct style to use for each character. After the method returns, character text[n] should be displayed using the style stored in style[n].

The format is responsible for resizing the style string to the correct size.

To correctly parse constructs spanning multiple lines, the format may store per-line context information in a 32-bit value. For the first line this value is defined to be 0, but for all other lines the value returned for the previous line should be passed as the context parameter.

Parameters
textThe line of text to parse.
styleA string to put the styles into.
contextA value representing the current context.
Returns
A value representing the new context.

Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.

virtual void cv::Format::SetStyle ( char  nStyle,
const CodeViewStyle cStyle 
)
pure virtual

Set the color used to display the given style.

This method must accept a color for each of the styles in the range from 0 through getStyleCount()-1. The method is not defined for methods outside of this range, but implementors are encouraged to handle this gracefully.

Parameters
nStyleThe number of the style to set.
cStyleThe color to display the given style with.

Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.


The documentation for this class was generated from the following file: