本文整理汇总了C++中ktexteditor::View::cursorPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ View::cursorPosition方法的具体用法?C++ View::cursorPosition怎么用?C++ View::cursorPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::View
的用法示例。
在下文中一共展示了View::cursorPosition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cursorContextDeclaration
///The first definition that belongs to a context that surrounds the current cursor
Declaration* cursorContextDeclaration() {
KTextEditor::View* view = ICore::self()->documentController()->activeTextDocumentView();
if(!view)
return nullptr;
KDevelop::DUChainReadLocker lock( DUChain::lock() );
TopDUContext* ctx = DUChainUtils::standardContextForUrl(view->document()->url());
if(!ctx)
return nullptr;
KTextEditor::Cursor cursor(view->cursorPosition());
DUContext* subCtx = ctx->findContext(ctx->transformToLocalRevision(cursor));
while(subCtx && !subCtx->owner())
subCtx = subCtx->parentContext();
Declaration* definition = nullptr;
if(!subCtx || !subCtx->owner())
definition = DUChainUtils::declarationInLine(cursor, ctx);
else
definition = subCtx->owner();
if(!definition)
return nullptr;
return definition;
}
示例2: currentWord
QString KateCTagsView::currentWord( )
{
KTextEditor::View *kv = mainWindow()->activeView();
if (!kv) {
kDebug() << "no KTextEditor::View" << endl;
return QString();
}
if (kv->selection()) {
return kv->selectionText();
}
if (!kv->cursorPosition().isValid()) {
kDebug() << "cursor not valid!" << endl;
return QString();
}
int line = kv->cursorPosition().line();
int col = kv->cursorPosition().column();
bool includeColon = m_ctagsUi.cmdEdit->text().contains("--extra=+q");
QString linestr = kv->document()->line(line);
int startPos = qMax(qMin(col, linestr.length()-1), 0);
int endPos = startPos;
while (startPos >= 0 && (linestr[startPos].isLetterOrNumber() ||
(linestr[startPos] == ':' && includeColon) ||
linestr[startPos] == '_' ||
linestr[startPos] == '~'))
{
startPos--;
}
while (endPos < (int)linestr.length() && (linestr[endPos].isLetterOrNumber() ||
(linestr[endPos] == ':' && includeColon) ||
linestr[endPos] == '_')) {
endPos++;
}
if (startPos == endPos) {
kDebug() << "no word found!" << endl;
return QString();
}
//kDebug() << linestr.mid(startPos+1, endPos-startPos-1);
return linestr.mid(startPos+1, endPos-startPos-1);
}
示例3: getCursorPos
// /home/follinge/projects/kscope-kde4/src/editorpage4.h:61:7: error: candidate is: bool kscope4::EditorPage::getCursorPos(uint&, uint&)
bool EditorPage::getCursorPos(int& nLine, int& nCol)
{
KTextEditor::View* pCursorIf;
// Acquire the view cursor
pCursorIf = dynamic_cast<KTextEditor::View*>(m_pView);
if (pCursorIf == NULL)
return false;
// Get the cursor position (adjusted to 1-based counting)
//pCursorIf->cursorPosition(&nLine, &nCol);
pCursorIf->cursorPosition().position(nLine, nCol);
nLine++;
nCol++;
return true;
}
示例4: lock
void KDevelop::DocumentationController::doShowDocumentation()
{
IDocument* doc = ICore::self()->documentController()->activeDocument();
if(!doc)
return;
KTextEditor::Document* textDoc = doc->textDocument();
if(!textDoc)
return;
KTextEditor::View* view = textDoc->activeView();
if(!view)
return;
KDevelop::DUChainReadLocker lock( DUChain::lock() );
Declaration *dec = DUChainUtils::declarationForDefinition( DUChainUtils::itemUnderCursor( doc->url(), SimpleCursor(view->cursorPosition()) ) );
if(dec) {
KSharedPtr< IDocumentation > documentation = documentationForDeclaration(dec);
if(documentation) {
showDocumentation(documentation);
}
}
}
示例5: specialObjectNavigationWidget
QWidget* QuickOpenPlugin::specialObjectNavigationWidget() const
{
KTextEditor::View* view = ICore::self()->documentController()->activeTextDocumentView();
if( !view )
return nullptr;
QUrl url = ICore::self()->documentController()->activeDocument()->url();
const auto languages = ICore::self()->languageController()->languagesForUrl(url);
foreach (const auto language, languages) {
QWidget* w = language->specialLanguageObjectNavigationWidget(url, KTextEditor::Cursor(view->cursorPosition()) );
if(w)
return w;
}
示例6: cursorDeclaration
Declaration* cursorDeclaration() {
KTextEditor::View* view = ICore::self()->documentController()->activeTextDocumentView();
if(!view)
return nullptr;
KDevelop::DUChainReadLocker lock( DUChain::lock() );
return DUChainUtils::declarationForDefinition( DUChainUtils::itemUnderCursor( view->document()->url(), KTextEditor::Cursor(view->cursorPosition()) ).declaration );
}