本文整理汇总了C++中ktexteditor::Range::columnWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ Range::columnWidth方法的具体用法?C++ Range::columnWidth怎么用?C++ Range::columnWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::Range
的用法示例。
在下文中一共展示了Range::columnWidth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shellComplete
// Contributed by <[email protected]>
void KateWordCompletionView::shellComplete()
{
KTextEditor::Range r = range();
QStringList matches = m_dWCompletionModel->allMatches( m_view, r );
if (matches.size() == 0)
return;
QString partial = findLongestUnique( matches, r.columnWidth() );
if ( ! partial.length() )
popupCompletionList();
else
{
m_view->document()->insertText( r.end(), partial.mid( r.columnWidth() ) );
d->liRange->setView(m_view);
d->liRange->setRange( KTextEditor::Range( r.end(), partial.length() - r.columnWidth() ) );
connect( m_view, SIGNAL(cursorPositionChanged(KTextEditor::View*,KTextEditor::Cursor)), this, SLOT(slotCursorMoved()) );
}
}
示例2: rangeText
QString CodeRepresentation::rangeText(const KTextEditor::Range& range) const
{
Q_ASSERT(range.end().line() < lines());
//Easier for single line ranges which should happen most of the time
if(range.onSingleLine())
return QString( line( range.start().line() ).mid( range.start().column(), range.columnWidth() ) );
//Add up al the requested lines
QString rangedText = line(range.start().line()).mid(range.start().column());
for(int i = range.start().line() + 1; i <= range.end().line(); ++i)
rangedText += '\n' + ((i == range.end().line()) ? line(i).left(range.end().column()) : line(i));
return rangedText;
}
示例3: completionInvoked
void KateNewCompletionModel::completionInvoked(KTextEditor::View* view, const KTextEditor::Range& range, InvocationType it)
{
/**
* auto invoke...
*/
m_automatic=false;
if (it==AutomaticInvocation) {
m_automatic=true;
KateView *v = qobject_cast<KateView*> (view);
if (range.columnWidth() >= 3)
saveMatches( view, range );
else
m_matches.clear();
// done here...
return;
}
// normal case ;)
saveMatches( view, range );
}
示例4: exportDocument
QString HighlighterByKate::exportDocument(KTextEditor::Document* note)
{
QString ret("");
KTextEditor::Range range;
range = note->documentRange();
KTextEditor::HighlightInterface* hiface = qobject_cast<KTextEditor::HighlightInterface*>(note);
const KTextEditor::Attribute::Ptr noAttrib(0);
for (int i = 0; i < note->lines(); ++i)
{
QString content("");
const QString &line = note->line(i);
QList<KTextEditor::HighlightInterface::AttributeBlock> attribs;
if ( hiface ) {
attribs = hiface->lineAttributes(i);
}
int lineStart = 0;
int remainingChars = line.length();
if ( range.onSingleLine() ) {
lineStart = range.start().column();
remainingChars = range.columnWidth();
} else if ( i == range.start().line() ) {
lineStart = range.start().column();
} else if ( i == range.end().line() ) {
remainingChars = range.end().column();
}
int handledUntil = lineStart;
foreach ( const KTextEditor::HighlightInterface::AttributeBlock& block, attribs ) {
// honor (block-) selections
if ( block.start + block.length <= lineStart ) {
continue;
} else if ( block.start >= lineStart + remainingChars ) {
break;
}
int start = qMax(block.start, lineStart);
if ( start > handledUntil ) {
exportText(content, line.mid( handledUntil, start - handledUntil ), noAttrib );
}
int length = qMin(block.length, remainingChars);
exportText(content, line.mid( start, length ), block.attribute);
handledUntil = start + length;
}
if ( handledUntil < lineStart + remainingChars ) {
exportText(content, line.mid( handledUntil, remainingChars ), noAttrib );
}
if (i != range.end().line()) {
ret.append(content.isEmpty() ? "\n" : content);
ret.append("\n");
}
}
return ret;
}
示例5: exportData
void ExporterPluginView::exportData(const bool useSelection, QTextStream &output)
{
const KTextEditor::Range range = useSelection ? m_view->selectionRange() : m_view->document()->documentRange();
const bool blockwise = useSelection ? m_view->blockSelection() : false;
if ( (blockwise || range.onSingleLine()) && (range.start().column() > range.end().column() ) ) {
return;
}
//outputStream.setEncoding(QTextStream::UnicodeUTF8);
output.setCodec(QTextCodec::codecForName("UTF-8"));
///TODO: add more exporters
AbstractExporter* exporter;
exporter = new HTMLExporter(m_view, output, !useSelection);
KTextEditor::HighlightInterface* hiface = qobject_cast<KTextEditor::HighlightInterface*>(m_view->document());
const KTextEditor::Attribute::Ptr noAttrib(0);
for (int i = range.start().line(); (i <= range.end().line()) && (i < m_view->document()->lines()); ++i)
{
const QString &line = m_view->document()->line(i);
QList<KTextEditor::HighlightInterface::AttributeBlock> attribs;
if ( hiface ) {
attribs = hiface->lineAttributes(i);
}
int lineStart = 0;
int remainingChars = line.length();
if ( blockwise || range.onSingleLine() ) {
lineStart = range.start().column();
remainingChars = range.columnWidth();
} else if ( i == range.start().line() ) {
lineStart = range.start().column();
} else if ( i == range.end().line() ) {
remainingChars = range.end().column();
}
int handledUntil = lineStart;
foreach ( const KTextEditor::HighlightInterface::AttributeBlock& block, attribs ) {
// honor (block-) selections
if ( block.start + block.length <= lineStart ) {
continue;
} else if ( block.start >= lineStart + remainingChars ) {
break;
}
int start = qMax(block.start, lineStart);
if ( start > handledUntil ) {
exporter->exportText( line.mid( handledUntil, start - handledUntil ), noAttrib );
}
int length = qMin(block.length, remainingChars);
exporter->exportText( line.mid( start, length ), block.attribute);
handledUntil = start + length;
}
if ( handledUntil < lineStart + remainingChars ) {
exporter->exportText( line.mid( handledUntil, remainingChars ), noAttrib );
}
exporter->closeLine(i == range.end().line());
}
delete exporter;
output.flush();
}