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 int m_unpackerSubcode; /**< Plugin information. */
26 bool m_bMixedEOL; /**< EOL style of this buffer is mixed? */
29 * @brief Unicode encoding from ucr::UNICODESET.
31 * @note m_unicoding and m_codepage are indications of how the buffer is
32 * supposed to be saved on disk. In memory, it is invariant, depending on
34 * - ANSI: in memory it is CP_ACP/CP_THREAD_ACP 8-bit characters
35 * - Unicode: in memory it is wchars
37 FileTextEncoding m_encoding;
39 bool FlagIsSet(UINT line, DWORD flag) const;
42 CDiffTextBuffer(CMergeDoc * pDoc, int pane);
44 void SetTempPath(const String &path);
45 virtual void AddUndoRecord (bool bInsert, const CPoint & ptStartPos,
46 const CPoint & ptEndPos, LPCTSTR pszText, size_t cchText,
47 int nActionType = CE_ACTION_UNKNOWN,
48 CDWordArray *paSavedRevisionNumbers = NULL) override;
50 void ReplaceFullLines(CDiffTextBuffer& dbuf, CDiffTextBuffer& sbuf, CCrystalTextView * pSource, int nLineBegin, int nLineEnd, int nAction =CE_ACTION_UNKNOWN);
52 int LoadFromFile(LPCTSTR pszFileName, PackingInfo * infoUnpacker,
53 LPCTSTR filteredFilenames, bool & readOnly, CRLFSTYLE nCrlfStyle,
54 const FileTextEncoding & encoding, CString &sError);
55 int SaveToFile (const String& pszFileName, bool bTempFile, String & sError,
56 PackingInfo * infoUnpacker = nullptr, CRLFSTYLE nCrlfStyle = CRLF_STYLE_AUTOMATIC,
57 bool bClearModifiedFlag = true, int nStartLine = 0, int nLines = -1);
58 ucr::UNICODESET getUnicoding() const { return m_encoding.m_unicoding; }
59 void setUnicoding(ucr::UNICODESET value) { m_encoding.m_unicoding = value; }
60 int getCodepage() const { return m_encoding.m_codepage; }
61 void setCodepage(int value) { m_encoding.SetCodepage(value); }
62 bool getHasBom() const { return m_encoding.m_bom; }
63 void setHasBom(bool value) { m_encoding.m_bom = value; }
64 const FileTextEncoding & getEncoding() const { return m_encoding; }
65 void setEncoding(const FileTextEncoding &encoding) { m_encoding = encoding; }
66 bool IsMixedEOL() const { return m_bMixedEOL; }
67 void SetMixedEOL(bool bMixed) { m_bMixedEOL = bMixed; }
69 // If line has text (excluding eol), set strLine to text (excluding eol)
70 bool GetLine(int nLineIndex, CString &strLine) const;
72 // if line has any text (including eol), set strLine to text (including eol)
73 bool GetFullLine(int nLineIndex, CString &strLine) const;
75 virtual void SetModified (bool bModified = true) override;
76 void prepareForRescan();
77 virtual void OnNotifyLineHasBeenEdited(int nLine) override;
78 bool IsInitialized() const;
79 virtual bool DeleteText2 (CCrystalTextView * pSource, int nStartLine,
80 int nStartPos, int nEndLine, int nEndPos,
81 int nAction = CE_ACTION_UNKNOWN, bool bHistory = true) override;