[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdevelop/parts/abbrev
From: Roberto Raggi <raggi () cli ! di ! unipi ! it>
Date: 2003-02-27 12:44:00
[Download RAW message or body]
CVS commit by raggi:
improved automatic completion.. now it is less annoying ;)
M +33 -7 abbrevpart.cpp 1.22
M +4 -1 abbrevpart.h 1.7
--- kdevelop/parts/abbrev/abbrevpart.cpp #1.21:1.22
@@ -84,4 +84,8 @@ AbbrevPart::AbbrevPart(QObject *parent,
viewCursorIface = 0;
completionIface = 0;
+
+ m_prevLine = -1;
+ m_prevColumn = -1;
+ m_sequenceLength = 0;
}
@@ -418,4 +422,8 @@ void AbbrevPart::slotActivePartChanged(
connect( doc, SIGNAL(textChanged()), this, SLOT(slotTextChanged()) );
}
+
+ m_prevLine = -1;
+ m_prevColumn = -1;
+ m_sequenceLength = 0;
}
@@ -424,8 +432,26 @@ void AbbrevPart::slotTextChanged()
unsigned int line, col;
viewCursorIface->cursorPositionReal( &line, &col );
- QChar ch = editIface->textLine( line )[ col ];
- if( !ch.isLetterOrNumber() && !m_inCompletion && currentWord().length() >= 3 )
+
+ if( m_prevLine != int(line) || m_prevColumn+1 != int(col) || col == 0 ){
+ m_prevLine = line;
+ m_prevColumn = col;
+ m_sequenceLength = 1;
+ return;
+ }
+
+ QChar ch = editIface->textLine( line )[ col-1 ];
+
+ if( m_inCompletion || !(ch.isLetterOrNumber() || ch == QChar('_')) ){
+ // reset
+ m_prevLine = -1;
+ return;
+ }
+
+ if( m_sequenceLength >= 3 )
slotExpandText();
+ ++m_sequenceLength;
+ m_prevLine = line;
+ m_prevColumn = col;
}
--- kdevelop/parts/abbrev/abbrevpart.h #1.6:1.7
@@ -71,4 +71,7 @@ private:
QAsciiDict<CodeTemplate> m_templates;
bool m_inCompletion;
+ int m_prevLine;
+ int m_prevColumn;
+ int m_sequenceLength;
KTextEditor::Document* docIface;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic