本文整理汇总了C++中IEditor::GetCharAtPos方法的典型用法代码示例。如果您正苦于以下问题:C++ IEditor::GetCharAtPos方法的具体用法?C++ IEditor::GetCharAtPos怎么用?C++ IEditor::GetCharAtPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEditor
的用法示例。
在下文中一共展示了IEditor::GetCharAtPos方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnCodeComplete
void PHPCodeCompletion::OnCodeComplete(clCodeCompletionEvent& e)
{
e.Skip(true);
if(PHPWorkspace::Get()->IsOpen()) {
IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor());
if(editor && IsPHPFile(editor)) {
e.Skip(false);
// Update the settings
TagsOptionsData d;
clConfig ccConfig("code-completion.conf");
ccConfig.ReadItem(&d);
m_lookupTable.SetSizeLimit(d.GetCcNumberOfDisplayItems());
// Check if the code completion was triggered due to user
// typing '(', in this case, call OnFunctionCallTip()
wxChar charAtPos = editor->GetCharAtPos(editor->GetCurrentPosition() - 1);
if(charAtPos == '(') {
OnFunctionCallTip(e);
} else {
// Perform the code completion here
PHPExpression::Ptr_t expr(new PHPExpression(editor->GetTextRange(0, e.GetPosition())));
bool isExprStartsWithOpenTag = expr->IsExprStartsWithOpenTag();
PHPEntityBase::Ptr_t entity = expr->Resolve(m_lookupTable, editor->GetFileName().GetFullPath());
if(entity) {
// Suggets members for the resolved entity
PHPEntityBase::List_t matches;
expr->Suggest(entity, m_lookupTable, matches);
if(!expr->GetFilter().IsEmpty() && (expr->GetCount() == 0)) {
// Word completion
PHPEntityBase::List_t keywords = PhpKeywords(expr->GetFilter());
// Preprend the keywords
matches.insert(matches.end(), keywords.begin(), keywords.end());
// Did user typed "<?ph" or "<?php" ??
// If so, clear the matches
if(isExprStartsWithOpenTag && (expr->GetFilter() == "ph" || expr->GetFilter() == "php")) {
matches.clear();
}
}
// Remove duplicates from the list
if(!matches.empty()) {
// Show the code completion box
DoShowCompletionBox(matches, expr);
}
}
}
}
}
}
示例2: OnCodeComplete
void PHPCodeCompletion::OnCodeComplete(clCodeCompletionEvent& e)
{
if(PHPWorkspace::Get()->IsOpen()) {
if(!CanCodeComplete(e)) return;
IEditor* editor = dynamic_cast<IEditor*>(e.GetEditor());
if(editor) {
// we handle only .php files
if(IsPHPFile(editor)) {
// Check if the code completion was triggered due to user
// typing '(', in this case, call OnFunctionCallTip()
wxChar charAtPos = editor->GetCharAtPos(editor->GetCurrentPosition() - 1);
if(charAtPos == '(') {
OnFunctionCallTip(e);
} else {
// Perform the code completion here
PHPExpression::Ptr_t expr(new PHPExpression(editor->GetTextRange(0, e.GetPosition())));
PHPEntityBase::Ptr_t entity = expr->Resolve(m_lookupTable, editor->GetFileName().GetFullPath());
if(entity) {
// Suggets members for the resolved entity
PHPEntityBase::List_t matches;
expr->Suggest(entity, m_lookupTable, matches);
// Remove duplicates from the list
if(!matches.empty()) {
// Show the code completion box
DoShowCompletionBox(matches, expr);
}
}
}
}
}
} else {
e.Skip();
}
}