diff.h 14.3 KB
Newer Older
Joachim Eibl's avatar
Joachim Eibl committed
1
/***************************************************************************
2 3
 *   Copyright (C) 2003-2007 by Joachim Eibl <joachim.eibl at gmx.de>      *
 *   Copyright (C) 2018 Michael Reeves reeves.87@gmail.com                 *
Joachim Eibl's avatar
Joachim Eibl committed
4 5 6 7 8 9 10 11 12 13 14 15 16
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef DIFF_H
#define DIFF_H

#include "common.h"
#include "fileaccess.h"
17
#include "options.h"
18
#include "gnudiff_diff.h"
19
#include "SourceData.h"
20 21 22
#include "Logging.h"

#include <QList>
Joachim Eibl's avatar
0.9.93  
Joachim Eibl committed
23

Michael Reeves's avatar
Michael Reeves committed
24 25 26 27 28 29 30 31 32 33 34 35
//enum must be sequential with no gaps to allow loop interiation of values
enum e_SrcSelector
{
   Min = -1,
   Invalid=-1,
   None=0,
   A = 1,
   B = 2,
   C = 3,
   Max=C
};

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
enum e_MergeDetails
{
   eDefault,
   eNoChange,
   eBChanged,
   eCChanged,
   eBCChanged,         // conflict
   eBCChangedAndEqual, // possible conflict
   eBDeleted,
   eCDeleted,
   eBCDeleted,         // possible conflict

   eBChanged_CDeleted, // conflict
   eCChanged_BDeleted, // conflict
   eBAdded,
   eCAdded,
   eBCAdded,           // conflict
   eBCAddedAndEqual    // possible conflict
};

Joachim Eibl's avatar
Joachim Eibl committed
56 57
// Each range with matching elements is followed by a range with differences on either side.
// Then again range of matching elements should follow.
Michael Reeves's avatar
Michael Reeves committed
58
class Diff
Joachim Eibl's avatar
Joachim Eibl committed
59
{
Michael Reeves's avatar
Michael Reeves committed
60
  public:
Michael Reeves's avatar
Cleanup  
Michael Reeves committed
61
    qint32 nofEquals;
Michael Reeves's avatar
Michael Reeves committed
62 63 64 65

    qint64 diff1;
    qint64 diff2;

Michael Reeves's avatar
Cleanup  
Michael Reeves committed
66
    Diff(qint32 eq, qint64 d1, qint64 d2)
Michael Reeves's avatar
Michael Reeves committed
67 68 69 70 71
    {
        nofEquals = eq;
        diff1 = d1;
        diff2 = d2;
    }
Joachim Eibl's avatar
Joachim Eibl committed
72 73 74 75
};

typedef std::list<Diff> DiffList;

Michael Reeves's avatar
Michael Reeves committed
76
class LineData
Joachim Eibl's avatar
Joachim Eibl committed
77
{
78
  private:
79 80 81
    QSharedPointer<QString> mBuffer;
    //QString pLine;
    QtNumberType mFirstNonWhiteChar = 0;
82
    qint64 mOffset = 0;
83
    QtNumberType mSize = 0;
Michael Reeves's avatar
Michael Reeves committed
84
    Q_DECL_DEPRECATED bool bContainsPureComment = false;
85 86

  public:
Michael Reeves's avatar
Michael Reeves committed
87
    explicit LineData() = default; // needed for Qt internal reasons should not be used.
88 89 90 91 92 93 94 95 96 97 98 99 100 101
    inline LineData(const QSharedPointer<QString> &buffer, const qint64 inOffset, QtNumberType inSize = 0)
    {
        mBuffer = buffer;
        mOffset = inOffset;
        mSize = inSize;
    }
    Q_REQUIRED_RESULT inline int size() const { return mSize; }
    inline void setFirstNonWhiteChar(const qint32 firstNonWhiteChar) { mFirstNonWhiteChar = firstNonWhiteChar;}
    Q_REQUIRED_RESULT inline qint32 getFirstNonWhiteChar() const { return mFirstNonWhiteChar; }

    /*
        QString::fromRawData allows us to create a light weight QString backed by the buffer memmory.
    */
    Q_REQUIRED_RESULT inline const QString getLine() const { return QString::fromRawData(mBuffer->data() + mOffset, mSize); }
Michael Reeves's avatar
cleanup  
Michael Reeves committed
102
    Q_REQUIRED_RESULT inline const QSharedPointer<QString>& getBuffer() const { return mBuffer; }
103 104 105

    Q_REQUIRED_RESULT inline qint64 getOffset() const { return mOffset; }
    Q_REQUIRED_RESULT int width(int tabSize) const; // Calcs width considering tabs.
Michael Reeves's avatar
Michael Reeves committed
106
    //int occurrences;
Michael Reeves's avatar
cleanup  
Michael Reeves committed
107
    inline bool whiteLine() const { return mFirstNonWhiteChar == mSize - 1; }
108

Michael Reeves's avatar
cleanup  
Michael Reeves committed
109 110
    inline bool isPureComment() const { return bContainsPureComment; }
    inline void setPureComment(const bool bPureComment) { bContainsPureComment = bPureComment; }
Michael Reeves's avatar
Cleanup  
Michael Reeves committed
111 112

    static bool equal(const LineData& l1, const LineData& l2, bool bStrict);
Joachim Eibl's avatar
Joachim Eibl committed
113 114 115 116 117
};

class Diff3LineList;
class Diff3LineVector;

Michael Reeves's avatar
Michael Reeves committed
118
class DiffBufferInfo
Joachim Eibl's avatar
Joachim Eibl committed
119
{
Michael Reeves's avatar
Michael Reeves committed
120
  public:
Michael Reeves's avatar
Michael Reeves committed
121 122 123
    const QVector<LineData>* m_pLineDataA;
    const QVector<LineData>* m_pLineDataB;
    const QVector<LineData>* m_pLineDataC;
124 125 126
    LineCount m_sizeA;
    LineCount m_sizeB;
    LineCount m_sizeC;
Michael Reeves's avatar
Michael Reeves committed
127 128 129
    const Diff3LineList* m_pDiff3LineList;
    const Diff3LineVector* m_pDiff3LineVector;
    void init(Diff3LineList* d3ll, const Diff3LineVector* d3lv,
Michael Reeves's avatar
Michael Reeves committed
130
              const QVector<LineData>* pldA, LineCount sizeA, const QVector<LineData>* pldB, LineCount sizeB, const QVector<LineData>* pldC, LineCount sizeC);
Joachim Eibl's avatar
Joachim Eibl committed
131 132
};

Michael Reeves's avatar
Michael Reeves committed
133
class Diff3Line
Joachim Eibl's avatar
Joachim Eibl committed
134
{
135
  private:
Michael Reeves's avatar
Michael Reeves committed
136 137 138
    LineRef lineA;
    LineRef lineB;
    LineRef lineC;
139
  public:
Michael Reeves's avatar
Michael Reeves committed
140

Michael Reeves's avatar
Michael Reeves committed
141 142 143
    bool bAEqC = false; // These are true if equal or only white-space changes exist.
    bool bBEqC = false;
    bool bAEqB = false;
Michael Reeves's avatar
Michael Reeves committed
144

Michael Reeves's avatar
Michael Reeves committed
145 146 147
    bool bWhiteLineA  = false;
    bool bWhiteLineB  = false;
    bool bWhiteLineC  = false;
Michael Reeves's avatar
Michael Reeves committed
148

Michael Reeves's avatar
Michael Reeves committed
149 150 151
    DiffList* pFineAB = nullptr; // These are 0 only if completely equal or if either source doesn't exist.
    DiffList* pFineBC = nullptr;
    DiffList* pFineCA = nullptr;
Michael Reeves's avatar
Michael Reeves committed
152

Michael Reeves's avatar
Michael Reeves committed
153 154
    int linesNeededForDisplay = 1;    // Due to wordwrap
    int sumLinesNeededForDisplay = 0; // For fast conversion to m_diff3WrapLineVector
Michael Reeves's avatar
Michael Reeves committed
155

Michael Reeves's avatar
Michael Reeves committed
156
    DiffBufferInfo* m_pDiffBufferInfo = nullptr; // For convenience
Michael Reeves's avatar
Michael Reeves committed
157 158 159 160 161 162 163 164 165 166 167

    ~Diff3Line()
    {
        if(pFineAB != nullptr) delete pFineAB;
        if(pFineBC != nullptr) delete pFineBC;
        if(pFineCA != nullptr) delete pFineCA;
        pFineAB = nullptr;
        pFineBC = nullptr;
        pFineCA = nullptr;
    }

168 169 170 171
    LineRef getLineA() const { return lineA; }
    LineRef getLineB() const { return lineB; }
    LineRef getLineC() const { return lineC; }

Michael Reeves's avatar
Michael Reeves committed
172 173 174 175 176 177 178
    inline void setLineA(const LineRef& line) { lineA = line; }
    inline void setLineB(const LineRef& line) { lineB = line; }
    inline void setLineC(const LineRef& line) { lineC = line; }

    inline bool isEqualAB() const { return bAEqB; }
    inline bool isEqualAC() const { return bAEqC; }
    inline bool isEqualBC() const { return bBEqC; }
179

Michael Reeves's avatar
Michael Reeves committed
180 181 182 183 184
    bool operator==(const Diff3Line& d3l) const
    {
        return lineA == d3l.lineA && lineB == d3l.lineB && lineC == d3l.lineC && bAEqB == d3l.bAEqB && bAEqC == d3l.bAEqC && bBEqC == d3l.bBEqC;
    }

Michael Reeves's avatar
Michael Reeves committed
185
    const LineData* getLineData(e_SrcSelector src) const
Michael Reeves's avatar
Michael Reeves committed
186 187
    {
        Q_ASSERT(m_pDiffBufferInfo != nullptr);
Michael Reeves's avatar
Michael Reeves committed
188 189 190
        if(src == A && lineA >= 0) return &(*m_pDiffBufferInfo->m_pLineDataA)[lineA];
        if(src == B && lineB >= 0) return &(*m_pDiffBufferInfo->m_pLineDataB)[lineB];
        if(src == C && lineC >= 0) return &(*m_pDiffBufferInfo->m_pLineDataC)[lineC];
Michael Reeves's avatar
Michael Reeves committed
191 192
        return nullptr;
    }
193
    const QString getString(const e_SrcSelector src) const
Michael Reeves's avatar
Michael Reeves committed
194 195 196
    {
        const LineData* pld = getLineData(src);
        if(pld)
197
            return pld->getLine();
Michael Reeves's avatar
Michael Reeves committed
198 199 200
        else
            return QString();
    }
Michael Reeves's avatar
Michael Reeves committed
201
    LineRef getLineInFile(e_SrcSelector src) const
Michael Reeves's avatar
Michael Reeves committed
202
    {
Michael Reeves's avatar
Michael Reeves committed
203 204 205
        if(src == A) return lineA;
        if(src == B) return lineB;
        if(src == C) return lineC;
Michael Reeves's avatar
Michael Reeves committed
206 207
        return -1;
    }
208

Michael Reeves's avatar
Michael Reeves committed
209
    bool fineDiff(bool bTextsTotalEqual, const e_SrcSelector selector, const QVector<LineData>* v1, const QVector<LineData>* v2);
Michael Reeves's avatar
Michael Reeves committed
210
    void mergeOneLine(e_MergeDetails& mergeDetails, bool& bConflict, bool& bLineRemoved, e_SrcSelector& src, bool bTwoInputs) const;
211

Michael Reeves's avatar
Michael Reeves committed
212
    void getLineInfo(const e_SrcSelector winIdx, const bool isTriple, int& lineIdx,
Michael Reeves's avatar
Michael Reeves committed
213 214 215
        DiffList*& pFineDiff1, DiffList*& pFineDiff2, // return values
        int& changed, int& changed2) const;

216
  private:
Michael Reeves's avatar
Michael Reeves committed
217
    void setFineDiff(const e_SrcSelector selector, DiffList* pDiffList)
218
    {
Michael Reeves's avatar
Michael Reeves committed
219 220
        Q_ASSERT(selector == A || selector == B || selector == C);
        if(selector == A)
221 222 223 224 225
        {
            if(pFineAB != nullptr)
                delete pFineAB;
            pFineAB = pDiffList;
        }
Michael Reeves's avatar
Michael Reeves committed
226
        else if(selector == B)
227 228 229 230 231
        {
            if(pFineBC != nullptr)
                delete pFineBC;
            pFineBC = pDiffList;
        }
Michael Reeves's avatar
Michael Reeves committed
232
        else if(selector == C)
233 234 235 236 237 238
        {
            if(pFineCA)
                delete pFineCA;
            pFineCA = pDiffList;
        }
    }
Joachim Eibl's avatar
Joachim Eibl committed
239 240
};

Michael Reeves's avatar
Michael Reeves committed
241
class Diff3LineList : public std::list<Diff3Line>
Joachim Eibl's avatar
Joachim Eibl committed
242
{
243
  public:
Michael Reeves's avatar
Michael Reeves committed
244
    bool fineDiff(const e_SrcSelector selector, const QVector<LineData>* v1, const QVector<LineData>* v2);
245
    void calcDiff3LineVector(Diff3LineVector& d3lv);
Michael Reeves's avatar
Michael Reeves committed
246
    void calcWhiteDiff3Lines(const QVector<LineData>* pldA, const QVector<LineData>* pldB, const QVector<LineData>* pldC);
Michael Reeves's avatar
Michael Reeves committed
247
    //TODO: Add safety guards to prevent list from getting too large. Same problem as with QLinkedList.
248 249
    int size() const
    {
250 251
        if(std::list<Diff3Line>::size() > std::numeric_limits<int>::max())
        {
252
            qCDebug(kdiffMain) << "Diff3Line: List too large. size=" << std::list<Diff3Line>::size();
253
            Q_ASSERT(false); //Unsupported size
254 255 256
            return 0;
        }
        return (int)std::list<Diff3Line>::size();
257 258 259
    } //safe for small files same limit as exited with QLinkedList. This should ultimatly be removed.

    void debugLineCheck(const LineCount size, const e_SrcSelector srcSelector) const;
Joachim Eibl's avatar
Joachim Eibl committed
260
};
261

262
class Diff3LineVector : public QVector<Diff3Line*>
Joachim Eibl's avatar
Joachim Eibl committed
263 264
{
};
Joachim Eibl's avatar
0.9.86  
Joachim Eibl committed
265 266 267

class Diff3WrapLine
{
Michael Reeves's avatar
Michael Reeves committed
268 269 270 271 272
  public:
    Diff3Line* pD3L;
    int diff3LineIndex;
    int wrapLineOffset;
    int wrapLineLength;
Joachim Eibl's avatar
0.9.86  
Joachim Eibl committed
273 274
};

275
typedef QVector<Diff3WrapLine> Diff3WrapLineVector;
Joachim Eibl's avatar
0.9.86  
Joachim Eibl committed
276

Joachim Eibl's avatar
Joachim Eibl committed
277 278
class TotalDiffStatus
{
Michael Reeves's avatar
Michael Reeves committed
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
  public:
    inline void reset()
    {
        bBinaryAEqC = false;
        bBinaryBEqC = false;
        bBinaryAEqB = false;
        bTextAEqC = false;
        bTextBEqC = false;
        bTextAEqB = false;
        nofUnsolvedConflicts = 0;
        nofSolvedConflicts = 0;
        nofWhitespaceConflicts = 0;
    }

    inline int getUnsolvedConflicts() const { return nofUnsolvedConflicts; }
    inline void setUnsolvedConflicts(const int unsolved) { nofUnsolvedConflicts = unsolved; }

    inline int getSolvedConflicts() const { return nofSolvedConflicts; }
    inline void setSolvedConflicts(const int solved) { nofSolvedConflicts = solved; }

    inline int getWhitespaceConflicts() const { return nofWhitespaceConflicts; }
    inline void setWhitespaceConflicts(const int wintespace) { nofWhitespaceConflicts = wintespace; }

    inline int getNonWhitespaceConflicts() { return getUnsolvedConflicts() + getSolvedConflicts() - getWhitespaceConflicts(); }

    bool isBinaryEqualAC() const { return bBinaryAEqC; }
    bool isBinaryEqualBC() const { return bBinaryBEqC; }
    bool isBinaryEqualAB() const { return bBinaryAEqB; }

    bool bBinaryAEqC = false;
    bool bBinaryBEqC = false;
    bool bBinaryAEqB = false;

    bool bTextAEqC = false;
    bool bTextBEqC = false;
    bool bTextAEqB = false;

  private:
Michael Reeves's avatar
Michael Reeves committed
317 318 319
    int nofUnsolvedConflicts = 0;
    int nofSolvedConflicts = 0;
    int nofWhitespaceConflicts = 0;
Joachim Eibl's avatar
Joachim Eibl committed
320 321
};

322
class ManualDiffHelpList; // A list of corresponding ranges
Joachim Eibl's avatar
Joachim Eibl committed
323 324 325
// Three corresponding ranges. (Minimum size of a valid range is one line.)
class ManualDiffHelpEntry
{
326
  private:
Michael Reeves's avatar
Michael Reeves committed
327 328 329 330 331 332 333
    LineRef lineA1;
    LineRef lineA2;
    LineRef lineB1;
    LineRef lineB2;
    LineRef lineC1;
    LineRef lineC2;

Michael Reeves's avatar
Michael Reeves committed
334
  public:
Michael Reeves's avatar
Michael Reeves committed
335
    LineRef& firstLine(e_SrcSelector winIdx)
Michael Reeves's avatar
Michael Reeves committed
336
    {
Michael Reeves's avatar
Michael Reeves committed
337
        return winIdx == A ? lineA1 : (winIdx == B ? lineB1 : lineC1);
Michael Reeves's avatar
Michael Reeves committed
338
    }
Michael Reeves's avatar
Michael Reeves committed
339
    LineRef& lastLine(e_SrcSelector winIdx)
Michael Reeves's avatar
Michael Reeves committed
340
    {
Michael Reeves's avatar
Michael Reeves committed
341
        return winIdx == A ? lineA2 : (winIdx == B ? lineB2 : lineC2);
Michael Reeves's avatar
Michael Reeves committed
342
    }
Michael Reeves's avatar
Michael Reeves committed
343
    bool isLineInRange(LineRef line, e_SrcSelector winIdx)
Michael Reeves's avatar
Michael Reeves committed
344 345 346 347 348 349 350 351
    {
        return line >= 0 && line >= firstLine(winIdx) && line <= lastLine(winIdx);
    }
    bool operator==(const ManualDiffHelpEntry& r) const
    {
        return lineA1 == r.lineA1 && lineB1 == r.lineB1 && lineC1 == r.lineC1 &&
               lineA2 == r.lineA2 && lineB2 == r.lineB2 && lineC2 == r.lineC2;
    }
352 353

    int calcManualDiffFirstDiff3LineIdx(const Diff3LineVector& d3lv);
354

Michael Reeves's avatar
Michael Reeves committed
355 356
    void getRangeForUI(const e_SrcSelector winIdx, int *rangeLine1, int *rangeLine2) const {
        if(winIdx == A) {
357 358 359
            *rangeLine1 = lineA1;
            *rangeLine2 = lineA2;
        }
Michael Reeves's avatar
Michael Reeves committed
360
        if(winIdx == B) {
361 362 363
            *rangeLine1 = lineB1;
            *rangeLine2 = lineB2;
        }
Michael Reeves's avatar
Michael Reeves committed
364
        if(winIdx == C) {
365 366 367 368 369
            *rangeLine1 = lineC1;
            *rangeLine2 = lineC2;
        }
    }

Michael Reeves's avatar
Michael Reeves committed
370 371 372
    inline int getLine1(const e_SrcSelector winIdx) const { return winIdx == A ? lineA1 : winIdx == B ? lineB1 : lineC1;}
    inline int getLine2(const e_SrcSelector winIdx) const { return winIdx == A ? lineA2 : winIdx == B ? lineB2 : lineC2;}
    bool isValidMove(int line1, int line2, e_SrcSelector winIdx1, e_SrcSelector winIdx2) const;
Joachim Eibl's avatar
Joachim Eibl committed
373 374 375
};

// A list of corresponding ranges
376 377 378
class ManualDiffHelpList: public std::list<ManualDiffHelpEntry>
{
    public:
Michael Reeves's avatar
Michael Reeves committed
379 380
        bool isValidMove(int line1, int line2, e_SrcSelector winIdx1, e_SrcSelector winIdx2) const;
        void insertEntry(e_SrcSelector winIdx, LineRef firstLine, LineRef lastLine);
Michael Reeves's avatar
Michael Reeves committed
381

Michael Reeves's avatar
Michael Reeves committed
382
        bool runDiff(const QVector<LineData>* p1, LineRef size1, const QVector<LineData>* p2, LineRef size2, DiffList& diffList,
Michael Reeves's avatar
Michael Reeves committed
383
                     e_SrcSelector winIdx1, e_SrcSelector winIdx2,
Michael Reeves's avatar
Michael Reeves committed
384
                     Options* pOptions);
385
};
386

Michael Reeves's avatar
Michael Reeves committed
387 388
void calcDiff(const QString &line1, const QString &line2, DiffList& diffList, int match, int maxSearchRange);

Joachim Eibl's avatar
0.9.80  
Joachim Eibl committed
389
void calcDiff3LineListUsingAB(
Michael Reeves's avatar
Michael Reeves committed
390 391
    const DiffList* pDiffListAB,
    Diff3LineList& d3ll);
Joachim Eibl's avatar
Joachim Eibl committed
392 393

void calcDiff3LineListUsingAC(
Michael Reeves's avatar
Michael Reeves committed
394 395
    const DiffList* pDiffListAC,
    Diff3LineList& d3ll);
Joachim Eibl's avatar
Joachim Eibl committed
396

Joachim Eibl's avatar
Joachim Eibl committed
397
void calcDiff3LineListUsingBC(
Michael Reeves's avatar
Michael Reeves committed
398 399
    const DiffList* pDiffListBC,
    Diff3LineList& d3ll);
Joachim Eibl's avatar
Joachim Eibl committed
400

Michael Reeves's avatar
Michael Reeves committed
401
void correctManualDiffAlignment(Diff3LineList& d3ll, ManualDiffHelpList* pManualDiffHelpList);
Joachim Eibl's avatar
Joachim Eibl committed
402

Michael Reeves's avatar
Michael Reeves committed
403
void calcDiff3LineListTrim(Diff3LineList& d3ll, const QVector<LineData>* pldA, const QVector<LineData>* pldB, const QVector<LineData>* pldC, ManualDiffHelpList* pManualDiffHelpList);
404

Joachim Eibl's avatar
Joachim Eibl committed
405

Joachim Eibl's avatar
0.9.80  
Joachim Eibl committed
406

407
bool fineDiff(
Michael Reeves's avatar
Michael Reeves committed
408 409
    Diff3LineList& diff3LineList,
    int selector,
Michael Reeves's avatar
Michael Reeves committed
410 411
    const QVector<LineData>* v1,
    const QVector<LineData>* v2);
Joachim Eibl's avatar
Joachim Eibl committed
412

Michael Reeves's avatar
Michael Reeves committed
413
inline bool isWhite(QChar c)
Joachim Eibl's avatar
Joachim Eibl committed
414
{
Michael Reeves's avatar
Michael Reeves committed
415
    return c == ' ' || c == '\t' || c == '\r';
Joachim Eibl's avatar
Joachim Eibl committed
416 417 418 419
}

/** Returns the number of equivalent spaces at position outPos.
*/
Michael Reeves's avatar
Michael Reeves committed
420
inline int tabber(int outPos, int tabSize)
Joachim Eibl's avatar
Joachim Eibl committed
421
{
Michael Reeves's avatar
Michael Reeves committed
422
    return tabSize - (outPos % tabSize);
Joachim Eibl's avatar
Joachim Eibl committed
423 424 425 426 427 428
}

/** Returns a line number where the linerange [line, line+nofLines] can
    be displayed best. If it fits into the currently visible range then
    the returned value is the current firstLine.
*/
Michael Reeves's avatar
Michael Reeves committed
429
int getBestFirstLine(int line, int nofLines, int firstLine, int visibleLines);
Joachim Eibl's avatar
Joachim Eibl committed
430 431 432

extern bool g_bIgnoreWhiteSpace;
extern bool g_bIgnoreTrivialMatches;
433
extern bool g_bAutoSolve;
Joachim Eibl's avatar
Joachim Eibl committed
434 435

// Cursor conversions that consider g_tabSize.
Michael Reeves's avatar
Michael Reeves committed
436 437
int convertToPosInText(const QString& s, int posOnScreen, int tabSize);
int convertToPosOnScreen(const QString& s, int posInText, int tabSize);
Joachim Eibl's avatar
Joachim Eibl committed
438

Michael Reeves's avatar
Michael Reeves committed
439 440 441 442 443 444
enum e_CoordType
{
    eFileCoords,
    eD3LLineCoords,
    eWrapCoords
};
Joachim Eibl's avatar
Joachim Eibl committed
445

Michael Reeves's avatar
Michael Reeves committed
446
void calcTokenPos(const QString&, int posOnScreen, int& pos1, int& pos2, int tabSize);
Joachim Eibl's avatar
Joachim Eibl committed
447

Michael Reeves's avatar
Michael Reeves committed
448 449
QString calcHistorySortKey(const QString& keyOrder, QRegExp& matchedRegExpr, const QStringList& parenthesesGroupList);
bool findParenthesesGroups(const QString& s, QStringList& sl);
Joachim Eibl's avatar
Joachim Eibl committed
450
#endif