2 * @file DiffTextBuffer.h
4 * @brief Declaration of CDiffTextBuffer class
8 #include "GhostTextBuffer.h"
9 #include "FileTextEncoding.h"
15 * @brief Specialized buffer to save file data
17 class CDiffTextBuffer : public CGhostTextBuffer
19 friend class CMergeDoc;
22 CMergeDoc * m_pOwnerDoc; /**< Merge document owning this buffer. */
23 int m_nThisPane; /**< Left/Right side */
24 String m_strTempPath; /**< Temporary files folder. */
25 String m_strTempFileName; /**< Temporary file name. */
26 std::vector<int> m_unpackerSubcodes; /**< Plugin information. */
27 bool m_bMixedEOL; /**< EOL style of this buffer is mixed? */
30 * @brief Unicode encoding from ucr::UNICODESET.
32 * @note m_unicoding and m_codepage are indications of how the buffer is
33 * supposed to be saved on disk. In memory, it is invariant, depending on
35 * - ANSI: in memory it is CP_ACP/CP_THREAD_ACP 8-bit characters
36 * - Unicode: in memory it is wchars
38 FileTextEncoding m_encoding;
40 bool FlagIsSet(int line, lineflags_t flag) const;
43 CDiffTextBuffer(CMergeDoc * pDoc, int pane);
45 void SetTempPath(const String &path);
46 String GetTempFileName() const { return m_strTempFileName; }
47 virtual void AddUndoRecord (bool bInsert, const CEPoint & ptStartPos,
48 const CEPoint & ptEndPos, const tchar_t* pszText, size_t cchText,
49 int nActionType = CE_ACTION_UNKNOWN,
50 std::vector<uint32_t> *paSavedRevisionNumbers = nullptr) override;
52 void ReplaceFullLines(CDiffTextBuffer& dbuf, CDiffTextBuffer& sbuf, CCrystalTextView * pSource, int nLineBegin, int nLineEnd, int nAction =CE_ACTION_UNKNOWN);
54 int LoadFromFile(const tchar_t* pszFileName, PackingInfo& infoUnpacker,
55 const tchar_t* filteredFilenames, bool & readOnly, CRLFSTYLE nCrlfStyle,
56 const FileTextEncoding & encoding, String &sError);
57 int SaveToFile (const String& pszFileName, bool bTempFile, String & sError,
58 PackingInfo& infoUnpacker, CRLFSTYLE nCrlfStyle = CRLFSTYLE::AUTOMATIC,
59 bool bClearModifiedFlag = true, int nStartLine = 0, int nLines = -1);
60 ucr::UNICODESET getUnicoding() const { return m_encoding.m_unicoding; }
61 void setUnicoding(ucr::UNICODESET value) { m_encoding.m_unicoding = value; }
62 int getCodepage() const { return m_encoding.m_codepage; }
63 void setCodepage(int value) { m_encoding.SetCodepage(value); }
64 bool getHasBom() const { return m_encoding.m_bom; }
65 void setHasBom(bool value) { m_encoding.m_bom = value; }
66 const FileTextEncoding & getEncoding() const { return m_encoding; }
67 void setEncoding(const FileTextEncoding &encoding) { m_encoding = encoding; }
68 bool IsMixedEOL() const { return m_bMixedEOL; }
69 void SetMixedEOL(bool bMixed) { m_bMixedEOL = bMixed; }
71 // If line has text (excluding eol), set strLine to text (excluding eol)
72 bool GetLine(int nLineIndex, String &strLine) const;
74 virtual void SetModified (bool bModified = true) override;
75 void prepareForRescan();
76 virtual void OnNotifyLineHasBeenEdited(int nLine) override;
77 bool IsInitialized() const;
78 virtual bool DeleteText2 (CCrystalTextView * pSource, int nStartLine,
79 int nStartPos, int nEndLine, int nEndPos,
80 int nAction = CE_ACTION_UNKNOWN, bool bHistory = true) override;
84 * @brief Set the folder for temp files.
85 * @param [in] path Temp files folder.
87 inline void CDiffTextBuffer::SetTempPath(const String &path)
93 * @brief Is the buffer initialized?
94 * @return true if the buffer is initialized, false otherwise.
96 inline bool CDiffTextBuffer::IsInitialized() const