本文整理汇总了C++中SearchResult::GetLen方法的典型用法代码示例。如果您正苦于以下问题:C++ SearchResult::GetLen方法的具体用法?C++ SearchResult::GetLen怎么用?C++ SearchResult::GetLen使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchResult
的用法示例。
在下文中一共展示了SearchResult::GetLen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoOpenSearchResult
void FindResultsTab::DoOpenSearchResult(const SearchResult& result, wxStyledTextCtrl* sci, int markerLine)
{
if(!result.GetFileName().IsEmpty()) {
LEditor* editor = clMainFrame::Get()->GetMainBook()->OpenFile(result.GetFileName());
if(editor && result.GetLen() >= 0) {
// Update the destination position if there have been subsequent changes in the editor
int position = result.GetPosition();
std::vector<int> changes;
editor->GetChanges(changes);
unsigned int changesTotal = changes.size();
int changePosition = 0;
int changeLength = 0;
int resultLength = result.GetLen();
bool removed = false;
for(unsigned int i = 0; i < changesTotal; i += 2) {
changePosition = changes.at(i);
changeLength = changes.at(i + 1);
if((changeLength < 0) && (changePosition - changeLength > position) &&
(changePosition < position + resultLength)) {
// It looks like the data corresponding to this search result has been deleted
// While it's possible that it's been cut, then (later in the changes) re-pasted
// so that the result still matches, it's more likely to have been replaced by different text
// We can't easily tell, so assume the worst and label the result invalid
removed = true;
// Explain the failure
clMainFrame::Get()->GetStatusBar()->SetMessage(_("Search result is no longer valid"));
break;
} else if(changePosition <= position) {
position += changeLength;
}
}
if(!removed) {
editor->SetEnsureCaretIsVisible(
position,
true,
true); // The 3rd parameter sets a small delay, otherwise it fails for long folded files
int lineNumber = editor->LineFromPos(position);
if(lineNumber) {
lineNumber--;
}
editor->SetLineVisible(lineNumber);
editor->SetSelection(position, position + resultLength);
#ifdef __WXGTK__
editor->ScrollToColumn(0);
#endif
if(sci) {
// remove the previous marker and add the new one
sci->MarkerDeleteAll(7);
sci->MarkerAdd(markerLine, 7);
sci->EnsureVisible(markerLine);
sci->GotoLine(markerLine);
}
}
}
}
}