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
    QString pLine;
Michael Reeves's avatar
Michael Reeves committed
80
    Q_DECL_DEPRECATED const QChar* pLine_old = nullptr;
81

Michael Reeves's avatar
Michael Reeves committed
82
    Q_DECL_DEPRECATED const QChar* pFirstNonWhiteChar = nullptr;
83
    int mSize = 0;
84 85

    qint64 mOffset = 0;
Michael Reeves's avatar
Michael Reeves committed
86
    Q_DECL_DEPRECATED bool bContainsPureComment = false;
87 88

  public:
89 90
    LineData() = default;
    inline LineData(const qint64 inOffset) { mOffset = inOffset; }
Michael Reeves's avatar
Michael Reeves committed
91 92
    Q_REQUIRED_RESULT inline int size() const { Q_ASSERT(pLine.length() == mSize); return pLine.length(); }
    Q_DECL_DEPRECATED inline void setSize(const int newSize) { mSize = newSize; }
93

Michael Reeves's avatar
Michael Reeves committed
94
    Q_DECL_DEPRECATED inline void setFirstNonWhiteChar(const QChar* firstNonWhiteChar) { pFirstNonWhiteChar = firstNonWhiteChar;}
95 96
    inline const QChar* getFirstNonWhiteChar() const { return pFirstNonWhiteChar; }

Michael Reeves's avatar
Michael Reeves committed
97 98 99
    Q_REQUIRED_RESULT inline const QString getLine() const { return pLine; }
    Q_DECL_DEPRECATED Q_REQUIRED_RESULT inline const QChar* getRawLine() const { return pLine_old; }
    Q_DECL_DEPRECATED inline void setLine(const QChar* line) { pLine_old = line;}
100
    inline void setLine(const QString& line) { pLine = line;}
101 102
    inline qint64 getOffset() { return mOffset; }
    inline void setOffset(qint64 inOffset) { mOffset = inOffset; }
Michael Reeves's avatar
Michael Reeves committed
103 104
    int width(int tabSize) const; // Calcs width considering tabs.
    //int occurrences;
105
    bool whiteLine() const { return pFirstNonWhiteChar - pLine_old == mSize; }
106 107 108

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

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

class Diff3LineList;
class Diff3LineVector;

Michael Reeves's avatar
Michael Reeves committed
116
class DiffBufferInfo
Joachim Eibl's avatar
Joachim Eibl committed
117
{
Michael Reeves's avatar
Michael Reeves committed
118
  public:
Michael Reeves's avatar
Michael Reeves committed
119 120 121
    const QVector<LineData>* m_pLineDataA;
    const QVector<LineData>* m_pLineDataB;
    const QVector<LineData>* m_pLineDataC;
122 123 124
    LineCount m_sizeA;
    LineCount m_sizeB;
    LineCount m_sizeC;
Michael Reeves's avatar
Michael Reeves committed
125 126 127
    const Diff3LineList* m_pDiff3LineList;
    const Diff3LineVector* m_pDiff3LineVector;
    void init(Diff3LineList* d3ll, const Diff3LineVector* d3lv,
Michael Reeves's avatar
Michael Reeves committed
128
              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
129 130
};

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

Michael Reeves's avatar
Michael Reeves committed
139 140 141
    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
142

Michael Reeves's avatar
Michael Reeves committed
143 144 145
    bool bWhiteLineA  = false;
    bool bWhiteLineB  = false;
    bool bWhiteLineC  = false;
Michael Reeves's avatar
Michael Reeves committed
146

Michael Reeves's avatar
Michael Reeves committed
147 148 149
    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
150

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

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

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

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

Michael Reeves's avatar
Michael Reeves committed
170 171 172 173 174 175 176
    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; }
177

Michael Reeves's avatar
Michael Reeves committed
178 179 180 181 182
    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
183
    const LineData* getLineData(e_SrcSelector src) const
Michael Reeves's avatar
Michael Reeves committed
184 185
    {
        Q_ASSERT(m_pDiffBufferInfo != nullptr);
Michael Reeves's avatar
Michael Reeves committed
186 187 188
        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
189 190
        return nullptr;
    }
Michael Reeves's avatar
Michael Reeves committed
191
    QString getString(const e_SrcSelector src) const
Michael Reeves's avatar
Michael Reeves committed
192 193 194
    {
        const LineData* pld = getLineData(src);
        if(pld)
195
            return pld->getLine();
Michael Reeves's avatar
Michael Reeves committed
196 197 198
        else
            return QString();
    }
Michael Reeves's avatar
Michael Reeves committed
199
    LineRef getLineInFile(e_SrcSelector src) const
Michael Reeves's avatar
Michael Reeves committed
200
    {
Michael Reeves's avatar
Michael Reeves committed
201 202 203
        if(src == A) return lineA;
        if(src == B) return lineB;
        if(src == C) return lineC;
Michael Reeves's avatar
Michael Reeves committed
204 205
        return -1;
    }
206

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

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

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

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

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

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

273
typedef QVector<Diff3WrapLine> Diff3WrapLineVector;
Joachim Eibl's avatar
0.9.86  
Joachim Eibl committed
274

Joachim Eibl's avatar
Joachim Eibl committed
275 276
class TotalDiffStatus
{
Michael Reeves's avatar
Michael Reeves committed
277 278 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
  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
315 316 317
    int nofUnsolvedConflicts = 0;
    int nofSolvedConflicts = 0;
    int nofWhitespaceConflicts = 0;
Joachim Eibl's avatar
Joachim Eibl committed
318 319
};

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

Michael Reeves's avatar
Michael Reeves committed
332
  public:
Michael Reeves's avatar
Michael Reeves committed
333
    LineRef& firstLine(e_SrcSelector winIdx)
Michael Reeves's avatar
Michael Reeves committed
334
    {
Michael Reeves's avatar
Michael Reeves committed
335
        return winIdx == A ? lineA1 : (winIdx == B ? lineB1 : lineC1);
Michael Reeves's avatar
Michael Reeves committed
336
    }
Michael Reeves's avatar
Michael Reeves committed
337
    LineRef& lastLine(e_SrcSelector winIdx)
Michael Reeves's avatar
Michael Reeves committed
338
    {
Michael Reeves's avatar
Michael Reeves committed
339
        return winIdx == A ? lineA2 : (winIdx == B ? lineB2 : lineC2);
Michael Reeves's avatar
Michael Reeves committed
340
    }
Michael Reeves's avatar
Michael Reeves committed
341
    bool isLineInRange(LineRef line, e_SrcSelector winIdx)
Michael Reeves's avatar
Michael Reeves committed
342 343 344 345 346 347 348 349
    {
        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;
    }
350 351

    int calcManualDiffFirstDiff3LineIdx(const Diff3LineVector& d3lv);
352

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

Michael Reeves's avatar
Michael Reeves committed
368 369 370
    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
371 372 373
};

// A list of corresponding ranges
374 375 376
class ManualDiffHelpList: public std::list<ManualDiffHelpEntry>
{
    public:
Michael Reeves's avatar
Michael Reeves committed
377 378
        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
379

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

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

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

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

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

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

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

Joachim Eibl's avatar
Joachim Eibl committed
403

Joachim Eibl's avatar
0.9.80  
Joachim Eibl committed
404

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

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

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

/** 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
427
int getBestFirstLine(int line, int nofLines, int firstLine, int visibleLines);
Joachim Eibl's avatar
Joachim Eibl committed
428 429 430 431 432 433

extern bool g_bIgnoreWhiteSpace;
extern bool g_bIgnoreTrivialMatches;
extern int g_bAutoSolve;

// Cursor conversions that consider g_tabSize.
Michael Reeves's avatar
Michael Reeves committed
434 435
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
436

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

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

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