本文整理汇总了C++中LEditor::EnsureCaretVisible方法的典型用法代码示例。如果您正苦于以下问题:C++ LEditor::EnsureCaretVisible方法的具体用法?C++ LEditor::EnsureCaretVisible怎么用?C++ LEditor::EnsureCaretVisible使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LEditor
的用法示例。
在下文中一共展示了LEditor::EnsureCaretVisible方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoSelectAndOpen
bool NewBuildTab::DoSelectAndOpen(const wxDataViewItem& item)
{
if( item.IsOk() == false )
return false;
m_listctrl->UnselectAll(); // Clear any selection
m_listctrl->EnsureVisible(item);
m_listctrl->Select(item);
BuildLineInfo* bli = (BuildLineInfo*)m_listctrl->GetItemData(item);
if( bli ) {
wxFileName fn(bli->GetFilename());
if ( !fn.IsAbsolute() ) {
std::vector<wxFileName> files;
std::vector<wxFileName> candidates;
ManagerST::Get()->GetWorkspaceFiles(files, true);
for(size_t i=0; i<files.size(); ++i) {
if( files.at(i).GetFullName() == fn.GetFullName() ) {
candidates.push_back( files.at(i) );
}
}
if ( candidates.empty() )
return false;
if ( candidates.size() == 1 )
fn = candidates.at(0);
else {
// prompt the user
wxArrayString fileArr;
for(size_t i=0; i<candidates.size(); ++i) {
fileArr.Add( candidates.at(i).GetFullPath() );
}
wxString selection = wxGetSingleChoice(_("Select a file to open:"), _("Choose a file"), fileArr);
if(selection.IsEmpty())
return false;
fn = wxFileName(selection);
// if we resolved it now, open the file there is no point in searching this file
// in m_buildInfoPerFile since the key on this map is kept as full name
LEditor* editor = clMainFrame::Get()->GetMainBook()->FindEditor(fn.GetFullPath());
if ( !editor ) {
editor = clMainFrame::Get()->GetMainBook()->OpenFile(fn.GetFullPath(), wxT(""), bli->GetLineNumber(), wxNOT_FOUND, OF_AddJump);
}
if ( editor ) {
// We already got compiler markers set here, just goto the line
clMainFrame::Get()->GetMainBook()->SelectPage( editor );
editor->GotoLine(bli->GetLineNumber());
SetActive(editor);
return true;
}
}
}
if ( fn.IsAbsolute() ) {
// try to locate the editor first
LEditor* editor = clMainFrame::Get()->GetMainBook()->FindEditor(fn.GetFullPath());
if ( !editor ) {
// Open it
editor = clMainFrame::Get()->GetMainBook()->OpenFile(bli->GetFilename(), wxT(""), bli->GetLineNumber(), wxNOT_FOUND, OF_AddJump);
}
if ( editor ) {
if ( !editor->HasCompilerMarkers())
MarkEditor( editor );
int lineNumber = bli->GetLineNumber();
if ( lineNumber > 0 ) {
lineNumber --;
}
// We already got compiler markers set here, just goto the line
clMainFrame::Get()->GetMainBook()->SelectPage( editor );
editor->GotoLine( bli->GetLineNumber() );
editor->ScrollToLine( bli->GetLineNumber() );
editor->EnsureVisible( lineNumber );
editor->EnsureCaretVisible();
SetActive(editor);
return true;
}
}
}
return false;
}
示例2: DoMarkAll
void QuickFindBar::DoMarkAll(bool useIndicators)
{
if(!m_sci)
return;
LEditor* editor = dynamic_cast<LEditor*>(m_sci);
if(!editor)
return;
wxString findWhat = m_findWhat->GetValue();
if(findWhat.IsEmpty()) {
return;
}
// Save the caret position
long savedPos = m_sci->GetCurrentPos();
size_t flags = DoGetSearchFlags();
int pos(0);
int match_len(0);
// remove reverse search
flags &= ~wxSD_SEARCH_BACKWARD;
int offset(0);
wchar_t* pinput = DoGetSearchStringPtr();
if(!pinput)
return;
int fixed_offset(0);
// Clear markers
editor->DelAllMarkers(smt_find_bookmark);
// set the active indicator to be 1
editor->SetIndicatorCurrent(1);
size_t count(0);
int firstMatchPos(wxNOT_FOUND);
while(StringFindReplacer::Search(pinput, offset, findWhat.wc_str(), flags, pos, match_len)) {
int matchStart = fixed_offset + pos;
int matchEnd = matchStart + match_len;
if(useIndicators) {
editor->MarkerAdd(editor->LineFromPosition(fixed_offset + pos), smt_find_bookmark);
// add indicator as well
editor->IndicatorFillRange(fixed_offset + pos, match_len);
} else {
// Use multiple selections
if(count) {
// we already have the main selection, add secondary selections
editor->AddSelection(matchStart, matchEnd);
} else {
// clear and set the first selection
editor->ClearSelections();
editor->SetSelection(matchStart, matchEnd);
firstMatchPos = matchStart;
}
}
++count;
offset = pos + match_len;
}
// Restore the caret
if(useIndicators) {
editor->SetCurrentPos(savedPos);
editor->EnsureCaretVisible();
}
if(firstMatchPos != wxNOT_FOUND) {
editor->SetMainSelection(0);
editor->SetLineVisible(editor->LineFromPos(firstMatchPos));
}
if(!useIndicators) {
// Hide the bar
Show(false);
}
}