本文整理汇总了C++中ktexteditor::View::selection方法的典型用法代码示例。如果您正苦于以下问题:C++ View::selection方法的具体用法?C++ View::selection怎么用?C++ View::selection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::View
的用法示例。
在下文中一共展示了View::selection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: slipInFilter
static void slipInFilter(KProcess & proc, KTextEditor::View & view, QString command)
{
QString inputText;
if (view.selection()) {
inputText = view.selectionText();
}
proc.clearProgram ();
proc.setShellCommand(command);
proc.start();
QByteArray encoded = inputText.toLocal8Bit();
proc.write(encoded);
proc.closeWriteChannel();
// TODO: Put up a modal dialog to defend the text from further
// keystrokes while the command is out. With a cancel button...
}