aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/CellBuffer.h
diff options
context:
space:
mode:
authornyamatongwe <unknown>2007-01-01 23:34:58 +0000
committernyamatongwe <unknown>2007-01-01 23:34:58 +0000
commit9f6740c61ca15c172be2d5c04b672cd0eba7d0e4 (patch)
tree7ec27fd7c4ca3664e5ead3fb122a5aa87c713f41 /src/CellBuffer.h
parentc48897c8f67c8f4096fdb51269ec478b45694f7d (diff)
downloadscintilla-mirror-9f6740c61ca15c172be2d5c04b672cd0eba7d0e4.tar.gz
Major change to CellBuffer class with addition of Partitioning class and SplitVector
template. Inserting and deleting lines are made more efficient by lessening the amount of per line information copied. Marker data is only allocated for each line if markers are added.
Diffstat (limited to 'src/CellBuffer.h')
-rw-r--r--src/CellBuffer.h69
1 files changed, 28 insertions, 41 deletions
diff --git a/src/CellBuffer.h b/src/CellBuffer.h
index 92bbfa0da..7faeecd23 100644
--- a/src/CellBuffer.h
+++ b/src/CellBuffer.h
@@ -27,10 +27,10 @@ class MarkerHandleSet {
public:
MarkerHandleSet();
~MarkerHandleSet();
- int Length();
- int NumberFromHandle(int handle);
- int MarkValue(); ///< Bit set of marker numbers.
- bool Contains(int handle);
+ int Length() const;
+ int NumberFromHandle(int handle) const;
+ int MarkValue() const; ///< Bit set of marker numbers.
+ bool Contains(int handle) const;
bool InsertHandle(int handle, int markerNum);
void RemoveHandle(int handle);
bool RemoveNumber(int markerNum);
@@ -38,43 +38,40 @@ public:
};
/**
- * Each line stores the starting position of the first character of the line in the cell buffer
- * and potentially a marker handle set. Often a line will not have any attached markers.
- */
-struct LineData {
- int startPosition;
- MarkerHandleSet *handleSet;
- LineData() : startPosition(0), handleSet(0) {
- }
-};
-
-/**
* The line vector contains information about each of the lines in a cell buffer.
*/
class LineVector {
-public:
- int growSize;
- int lines;
- LineData *linesData;
- int size;
- int *levels;
- int sizeLevels;
+ Partitioning starts;
+ SplitVector<MarkerHandleSet *> markers;
+ SplitVector<int> levels;
/// Handles are allocated sequentially and should never have to be reused as 32 bit ints are very big.
int handleCurrent;
+public:
+
LineVector();
~LineVector();
void Init();
- void Expand(int sizeNew);
void ExpandLevels(int sizeNew=-1);
void ClearLevels();
- void InsertValue(int pos, int value);
- void SetValue(int pos, int value);
- void Remove(int pos);
+ int SetLevel(int line, int level);
+ int GetLevel(int line);
+
+ void InsertText(int line, int delta);
+ void InsertLine(int line, int position);
+ void SetLineStart(int line, int position);
+ void RemoveLine(int line);
+ int Lines() {
+ return starts.Partitions();
+ }
int LineFromPosition(int pos);
+ int LineStart(int line) {
+ return starts.PositionFromPartition(line);
+ }
+ int MarkValue(int line);
int AddMark(int line, int marker);
void MergeMarkers(int pos);
void DeleteMark(int line, int markerNum, bool all);
@@ -150,16 +147,8 @@ public:
*/
class CellBuffer {
private:
- char *body; ///< The cell buffer itself.
- int size; ///< Allocated size of the buffer.
- int length; ///< Total length of the data.
- int part1len; ///< Length of the first part.
- int gaplen; ///< Length of the gap between the two parts.
- char *part2body; ///< The second part of the cell buffer.
- ///< Doesn't point after the gap but set so that
- ///< part2body[position] is consistent with body[position].
+ SplitVector<char> body;
bool readOnly;
- int growSize;
bool collectingUndo;
UndoHistory uh;
@@ -168,15 +157,13 @@ private:
SVector lineStates;
- void GapTo(int position);
- void RoomFor(int insertionLength);
-
- inline char ByteAt(int position);
- void SetByteAt(int position, char ch);
+ char ByteAt(int position) {
+ return body.ValueAt(position);
+ }
public:
- CellBuffer(int initialLength = 4000);
+ CellBuffer();
~CellBuffer();
/// Retrieving positions outside the range of the buffer works and returns 0