edbee - Qt Editor Library
lineoffsetvector.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QVector>
9 
10 #include "gapvector.h"
11 
12 
13 namespace edbee {
14 
15 class TextBufferChange;
16 
17 
18 
27 {
28 public:
30 // struct LineChange {
31 // int line; ///< the first line that's going to be replaced
32 // int lineCount; ///< the number of lines that are replaced
33 // int newLineCount; ///< the number of lines added/removed
34 // int offsetDelta; ///< the change in offset
35 // QVector<int> newOffsets; ///< the new offsets
36 // };
37 
38 
40 
41  void applyChange( TextBufferChange change );
42 
43  int at( int idx ) const;
44  int length() const;
45 
46  int findLineFromOffset( int offset );
47 
48  int offsetDelta() { return offsetDelta_; }
49  int offsetDeltaIndex() { return offsetDeltaIndex_; }
50 
51  void appendOffset( int offset );
52 
54  GapVector<int> offsetList() { return offsetList_; }
55 
56 protected:
57  int searchOffsetIgnoringOffsetDelta(int offset, int org_start, int org_end );
58 
59  void moveDeltaToIndex( int index );
60  void changeOffsetDelta( int index, int delta );
61 
62 public:
63  QString toUnitTestString();
64  void initForUnitTesting( int offsetDelta, int offsetDeltaIndex, ... );
65 
66 
67 private:
68 
69  GapVector<int> offsetList_;
70  int offsetDelta_;
71  int offsetDeltaIndex_;
72 
73 
74 friend class LineOffsetVectorTest;
75 
76 
77 };
78 
79 } // edbee
int offsetDeltaIndex()
Definition: lineoffsetvector.h:49
This clas represents a text buffer change and is used to pass around between events This is a sharedd...
Definition: textbuffer.h:45
friend class LineOffsetVectorTest
Definition: lineoffsetvector.h:74
GapVector< int > offsetList()
Definition: lineoffsetvector.h:54
LineOffsetVector()
a structure to describe the line change that happend
Definition: lineoffsetvector.cpp:15
This class implements the vector for storing the line numbers at certain offsets/ The class allows th...
Definition: lineoffsetvector.h:26
int findLineFromOffset(int offset)
this method searches the line from the given offset
Definition: lineoffsetvector.cpp:101
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
int at(int idx) const
this method returns the line offset at the given line offset
Definition: lineoffsetvector.cpp:85
void changeOffsetDelta(int index, int delta)
This method moves the offset delta to the given location.
Definition: lineoffsetvector.cpp:257
int offsetDelta()
Definition: lineoffsetvector.h:48
int length() const
Definition: lineoffsetvector.cpp:94
void moveDeltaToIndex(int index)
This method moves the delta to the given index.
Definition: lineoffsetvector.cpp:220
int searchOffsetIgnoringOffsetDelta(int offset, int org_start, int org_end)
This method returns the line from the start position. This method uses a binary search. Warning this method uses RAW values from the offsetList it does NOT take in account the offsetDelta.
Definition: lineoffsetvector.cpp:174
void applyChange(TextBufferChange change)
Definition: lineoffsetvector.cpp:25
void appendOffset(int offset)
This method appends an offset to the end of the list It simply applies the current offsetDelta becaus...
Definition: lineoffsetvector.cpp:128
void initForUnitTesting(int offsetDelta, int offsetDeltaIndex,...)
initializes the construct for unit testing
Definition: lineoffsetvector.cpp:153
QString toUnitTestString()
This method returns the offset to string.
Definition: lineoffsetvector.cpp:134