The base class for all source code formaters. More...
#include <format.h>
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 CodeViewStyle & | GetStyle (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... | |
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()
|
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.
cLine | A line parse. |
nOldFoldLevel | Set 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.
|
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".
cText | The line to analyze. |
bUseTabs | Use TABs to indent. |
nTabSize | Length of each TAB. |
Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.
|
pure virtual |
Get the character index of the next word limit.
What is considered a word is up to the format.
nLine | The line to analyze. |
nChr | The character index to start from. |
Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.
|
pure virtual |
Get the character index of the previous word limit.
What is considered a word is up to the format.
nLine | The line to analyze. |
nChr | The character index to start from. |
Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.
|
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.
nStyle | The number of the style to return. |
Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.
|
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.
Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.
|
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.
style | The number of the style to return. |
Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.
|
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.
text | The line of text to parse. |
style | A string to put the styles into. |
context | A value representing the current context. |
Implemented in cv::Format_C, cv::Format_java, cv::Format_Ruby, cv::Format_HTML, and cv::Format_Perl.
|
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.
nStyle | The number of the style to set. |
cStyle | 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.