本文整理汇总了C++中ktexteditor::Document::removeText方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::removeText方法的具体用法?C++ Document::removeText怎么用?C++ Document::removeText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ktexteditor::Document
的用法示例。
在下文中一共展示了Document::removeText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: complete
// Do one completion, searching in the desired direction,
// if possible
void KateWordCompletionView::complete( bool fw )
{
KTextEditor::Range r = range();
int inc = fw ? 1 : -1;
KTextEditor::Document *doc = m_view->document();
if ( d->dcRange.isValid() )
{
//kDebug( 13040 )<<"CONTINUE "<<d->dcRange;
// this is a repeted activation
// if we are back to where we started, reset.
if ( ( fw && d->directionalPos == -1 ) ||
( !fw && d->directionalPos == 1 ) )
{
const int spansColumns = d->liRange->end().column() - d->liRange->start().column();
if ( spansColumns > 0 )
doc->removeText( *d->liRange );
d->liRange->setRange( KTextEditor::Range::invalid() );
d->dcCursor = r.end();
d->directionalPos = 0;
return;
}
if ( fw ) {
const int spansColumns = d->liRange->end().column() - d->liRange->start().column();
d->dcCursor.setColumn( d->dcCursor.column() + spansColumns );
}
d->directionalPos += inc;
}
else // new completion, reset all
{
//kDebug( 13040 )<<"RESET FOR NEW";
d->dcRange = r;
d->liRange->setRange( KTextEditor::Range::invalid() );
d->dcCursor = r.start();
d->directionalPos = inc;
d->liRange->setView( m_view );
connect( m_view, SIGNAL(cursorPositionChanged(KTextEditor::View*,KTextEditor::Cursor)), this, SLOT(slotCursorMoved()) );
}
d->re.setPattern( "\\b" + doc->text( d->dcRange ) + "(\\w+)" );
int pos ( 0 );
QString ln = doc->line( d->dcCursor.line() );
while ( true )
{
//kDebug( 13040 )<<"SEARCHING FOR "<<d->re.pattern()<<" "<<ln<<" at "<<d->dcCursor;
pos = fw ?
d->re.indexIn( ln, d->dcCursor.column() ) :
d->re.lastIndexIn( ln, d->dcCursor.column() );
if ( pos > -1 ) // we matched a word
{
//kDebug( 13040 )<<"USABLE MATCH";
QString m = d->re.cap( 1 );
if ( m != doc->text( *d->liRange ) && (d->dcCursor.line() != d->dcRange.start().line() || pos != d->dcRange.start().column() ) )
{
// we got good a match! replace text and return.
d->isCompleting = true;
KTextEditor::Range replaceRange(d->liRange->toRange());
if (!replaceRange.isValid()) {
replaceRange.setRange(r.end(), r.end());
}
doc->replaceText( replaceRange, m );
d->liRange->setRange( KTextEditor::Range( d->dcRange.end(), m.length() ) );
d->dcCursor.setColumn( pos ); // for next try
d->isCompleting = false;
return;
}
// equal to last one, continue
else
{
//kDebug( 13040 )<<"SKIPPING, EQUAL MATCH";
d->dcCursor.setColumn( pos ); // for next try
if ( fw )
d->dcCursor.setColumn( pos + m.length() );
else
{
if ( pos == 0 )
{
if ( d->dcCursor.line() > 0 )
{
int l = d->dcCursor.line() + inc;
ln = doc->line( l );
d->dcCursor.setPosition( l, ln.length() );
//.........这里部分代码省略.........