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 int m_unpackerSubcode; /**< 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(UINT line, DWORD 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 CPoint & ptStartPos,
48 const CPoint & ptEndPos, LPCTSTR pszText, size_t cchText,
49 int nActionType = CE_ACTION_UNKNOWN,
50 CDWordArray *paSavedRevisionNumbers = nullptr) override;
52 void ReplaceFullLines(CDiffTextBuffer& dbuf, CDiffTextBuffer& sbuf, CCrystalTextView * pSource, int nLineBegin, int nLineEnd, int nAction =CE_ACTION_UNKNOWN);
54 int LoadFromFile(LPCTSTR pszFileName, PackingInfo * infoUnpacker,
55 LPCTSTR filteredFilenames, bool & readOnly, CRLFSTYLE nCrlfStyle,
56 const FileTextEncoding & encoding, CString &sError);
57 int SaveToFile (const String& pszFileName, bool bTempFile, String & sError,
58 PackingInfo * infoUnpacker = nullptr, 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, CString &strLine) const;
74 // if line has any text (including eol), set strLine to text (including eol)
75 bool GetFullLine(int nLineIndex, CString &strLine) const;
77 virtual void SetModified (bool bModified = true) override;
78 void prepareForRescan();
79 virtual void OnNotifyLineHasBeenEdited(int nLine) override;
80 bool IsInitialized() const;
81 virtual bool DeleteText2 (CCrystalTextView * pSource, int nStartLine,
82 int nStartPos, int nEndLine, int nEndPos,
83 int nAction = CE_ACTION_UNKNOWN, bool bHistory = true) override;
87 * @brief Set the folder for temp files.
88 * @param [in] path Temp files folder.
90 inline void CDiffTextBuffer::SetTempPath(const String &path)
96 * @brief Is the buffer initialized?
97 * @return true if the buffer is initialized, false otherwise.
99 inline bool CDiffTextBuffer::IsInitialized() const