Objective Edit : Chapter 6 Customization : Working with Text
Working with Text
Inserting Text at Current Location In Edit Control
To get the current selection in the control to replace the selected text or (if nothing is selected) to insert itself at the current caret location, use the following code:
void SECEditView::InsertText(LPCTSTR strText)
{
SECEditController* pCtrl = GetSECEditController();
ASSERT(pCtrl != NULL);
SECEditLineCol lcCaret = pCtrl->GetCaretPos();
GetEditModel()->Insert(lcCaret.line, lcCaret.col, strText);
}
Add a pCtrl->Clear() call right before the GetCaretPos() function so that any selected text will be removed before the new text is inserted.
Indenting Text
The only indention feature Objective Edit supports is AutoIndent, which allows the new line (when you hit the <Enter> key) to start with the same amount of white space as the previous line.
To enable this feature, call:
 
GetEdit()->GetLangPtr()->SetAutoIndent(TRUE);
To disable it, call:
 
GetEdit()->GetLangPtr()->SetAutoIndent(FALSE);
Line Highlighting
Objective Edit now provides a way to color highlight a line. Highlighting a line is very similar to adding a bookmark in that it acts by adding the data flag ID_SECEDIT_ITEMDATA_HIGHLIGHT to the line. You also need to define a color group for highlighting in the .ini file. Here is an example:
 
[Highlight]
Foreground = 255,255,255
Background = 128,0,0
DisplayName = Highlight
This color group only needs three lines:
1. Foreground defines the foreground color of the highlighted line.
2. Background defines the background color of the highlighted line.
3. DisplayName has to be “Highlight” in order to be recognized by SECEditLangConfig.
A new command ID has been added for toggling the highlight flag: ID_SECEDIT_HIGHLIGHT_TOGGLE
Find and Replace
 
Regular Expressions
A regular expression is a pattern of text characters (such as the letters a through z, or special characters such as *) that describes a string to match when performing a search of text.
VBScript RegExp
Objective Edit’s Find/Replace Dialog uses VBScript’s Regular Expression (RegExp) object, which provides simple regular expression support.
In the function BOOL SECEditRegExp::Create(), the CreateDispatch(_T(“VBScript.RegExp”)) method serves as a connection to VBScript regular expressions. (In VBScript, the regular expression engine was implemented as a COM object so it could be called from sources outside VBScript.)
Search MSDN (http://msdn.microsoft.com/library/) for details on the VBScript RegExp object.
NOTE >> As discussed in “HTML Output” Objective Edit depends on the Regex++ (regular expression) libraries. However, Regex++ is used for HTML output only--not the Find and Replace functionality.