summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katetextline.h24
1 files changed, 12 insertions, 12 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katetextline.h b/noncore/apps/tinykate/libkate/document/katetextline.h
index c2968cc..3518900 100644
--- a/noncore/apps/tinykate/libkate/document/katetextline.h
+++ b/noncore/apps/tinykate/libkate/document/katetextline.h
@@ -12,180 +12,180 @@
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef _KWTEXTLINE_H_
#define _KWTEXTLINE_H_
#include <stdlib.h>
#include <qstring.h>
#include <qarray.h>
#include <qvaluelist.h>
#include <ksharedptr.h>
/**
FastValueList: QValueList, but with a faster at() like QList
FVPrivate is needed so that "const" functions can change the
current position
*/
template<class T>
class FVPrivate
{
public:
int curpos;
typedef QValueListConstIterator<T> Iterator;
Iterator curit;
FVPrivate() { curpos=-1; };
};
template<class T>
class FastValueList : public QValueList<T>
{
public:
typedef QValueListIterator<T> Iterator;
typedef QValueListConstIterator<T> ConstIterator;
protected:
FVPrivate<T> *fvp;
Iterator fastat( uint i ) {
- uint num=count();
- if (i>=num) {return end();}
- if (fvp->curpos<0) { fvp->curpos=0; fvp->curit=begin(); }
+ uint num=this->count();
+ if (i>=num) {return this->end();}
+ if (fvp->curpos<0) { fvp->curpos=0; fvp->curit=this->begin(); }
uint curpos=(uint) fvp->curpos;
Iterator curit(fvp->curit.node);
if (curpos==i) return curit;
int diff=i-curpos;
bool forward;
if (diff<0) diff=-diff;
if (((uint)diff < i) && ((uint)diff < num-i)) { // start from current node
forward=i > (uint)curpos;
} else if (i < num - i) { // start from first node
- curit=begin(); diff=i; forward=TRUE;
+ curit=this->begin(); diff=i; forward=TRUE;
} else { // start from last node
- curit=fromLast(); diff=num - i - 1;
+ curit=this->fromLast(); diff=num - i - 1;
if (diff<0) diff=0;
forward=FALSE;
}
if (forward) {
while(diff--) curit++;
} else {
while(diff--) curit--;
}
fvp->curpos=i; fvp->curit=curit;
return curit;
}
ConstIterator fastat( uint i ) const {
- uint num=count();
- if (i>=num) {return end();}
- if (fvp->curpos<0) { fvp->curpos=0; fvp->curit=begin(); }
+ uint num=this->count();
+ if (i>=num) {return this->end();}
+ if (fvp->curpos<0) { fvp->curpos=0; fvp->curit=this->begin(); }
uint curpos=(uint) fvp->curpos;
ConstIterator curit=fvp->curit;
if (curpos==i) return curit;
int diff=i-curpos;
bool forward;
if (diff<0) diff=-diff;
if (((uint)diff < i) && ((uint)diff < num-i)) { // start from current node
forward=i > (uint)curpos;
} else if (i < num - i) { // start from first node
- curit=begin(); diff=i; forward=TRUE;
+ curit=this->begin(); diff=i; forward=TRUE;
} else { // start from last node
- curit=fromLast(); diff=num - i - 1;
+ curit=this->fromLast(); diff=num - i - 1;
if (diff<0) diff=0;
forward=FALSE;
}
if (forward) {
while(diff--) curit++;
} else {
while(diff--) curit--;
}
fvp->curpos=i; fvp->curit=curit;
return curit;
}
public:
FastValueList() : QValueList<T>()
{ fvp=new FVPrivate<T>(); }
FastValueList(const FastValueList<T>& l) : QValueList<T>(l)
{ fvp=new FVPrivate<T>(); }
~FastValueList() { delete fvp; }
Iterator insert( Iterator it, const T& x ) {
fvp->curpos=-1; return QValueList<T>::insert(it, x);
}
Iterator append( const T& x ) {
fvp->curpos=-1; return QValueList<T>::append( x );
}
Iterator prepend( const T& x ) {
fvp->curpos=-1; return QValueList<T>::prepend( x );
}
Iterator remove( Iterator it ) {
fvp->curpos=-1; return QValueList<T>::remove( it );
}
void remove( const T& x ) {
fvp->curpos=-1; QValueList<T>::remove( x );
}
- T& operator[] ( uint i ) { detach(); return fastat(i); }
+ T& operator[] ( uint i ) { this->detach(); return fastat(i); }
const T& operator[] ( uint i ) const { return *fastat(i); }
- Iterator at( uint i ) { detach(); return fastat(i); }
+ Iterator at( uint i ) { this->detach(); return fastat(i); }
ConstIterator at( uint i ) const { return ConstIterator( fastat(i) ); }
};
/**
The TextLine represents a line of text. A text line that contains the
text, an attribute for each character, an attribute for the free space
behind the last character and a context number for the syntax highlight.
The attribute stores the index to a table that contains fonts and colors
and also if a character is selected.
*/
class TextLine : public KShared
{
friend class KWBuffer;
friend class KWBufBlock;
public:
typedef KSharedPtr<TextLine> Ptr;
typedef FastValueList<Ptr> List;
public:
/**
Creates an empty text line with given attribute and syntax highlight
context
*/
TextLine(uchar attribute = 0, int context = 0);
~TextLine();
/**
Returns the length
*/
uint length() const {return text.length();}
/**
Universal text manipulation method. It can be used to insert, delete
or replace text.
*/
void replace(uint pos, uint delLen, const QChar *insText, uint insLen, uchar *insAttribs = 0L);
/**
Appends a string of length l to the textline
*/
void append(const QChar *s, uint l) {replace(text.length(), 0, s, l);}
/**
Wraps the text from the given position to the end to the next line
*/
void wrap(TextLine::Ptr nextLine, uint pos);
/**
Wraps the text of given length from the beginning of the next line to