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

83
    Q_DECL_DEPRECATED const QChar* pFirstNonWhiteChar_old = nullptr;
84
    int mSize = 0;
85 86

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

  public:
90 91
    LineData() = default;
    inline LineData(const qint64 inOffset) { mOffset = inOffset; }
Michael Reeves's avatar
Michael Reeves committed
92 93
    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; }
94

95 96
    Q_DECL_DEPRECATED inline void setFirstNonWhiteChar(const QChar* firstNonWhiteChar) { pFirstNonWhiteChar_old = firstNonWhiteChar;}
    Q_DECL_DEPRECATED inline const QChar* getFirstNonWhiteChar() const { return pFirstNonWhiteChar_old; }
97

Michael Reeves's avatar
Michael Reeves committed
98 99 100
    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;}
101
    inline void setLine(const QString& line) { pLine = line;}
102 103
    inline qint64 getOffset() { return mOffset; }
    inline void setOffset(qint64 inOffset) { mOffset = inOffset; }
Michael Reeves's avatar
Michael Reeves committed
104 105
    int width(int tabSize) const; // Calcs width considering tabs.
    //int occurrences;
106
    bool whiteLine() const { return pFirstNonWhiteChar_old - pLine_old == mSize; }
107 108 109

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

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

class Diff3LineList;
class Diff3LineVector;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    int calcManualDiffFirstDiff3LineIdx(const Diff3LineVector& d3lv);
353

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

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

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

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

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

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

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

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

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

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

Joachim Eibl's avatar
Joachim Eibl committed
404

Joachim Eibl's avatar
0.9.80  
Joachim Eibl committed
405

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

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

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

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

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
435 436
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
437

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

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

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