OSDN Git Service

Merge pull request #93 from GreyMerlin/master
[winmerge-jp/winmerge-jp.git] / Src / DiffTextBuffer.h
1 /** 
2  * @file  DiffTextBuffer.h
3  *
4  * @brief Declaration of CDiffTextBuffer class
5  */
6 #pragma once
7
8 #include "GhostTextBuffer.h"
9 #include "FileTextEncoding.h"
10
11 class CMergeDoc;
12 class PackingInfo;
13
14 /**
15  * @brief Specialized buffer to save file data
16  */
17 class CDiffTextBuffer : public CGhostTextBuffer
18 {
19         friend class CMergeDoc;
20
21 private :
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? */
27
28         /** 
29          * @brief Unicode encoding from ucr::UNICODESET.
30          *
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
33          * build:
34          * - ANSI: in memory it is CP_ACP/CP_THREAD_ACP 8-bit characters
35          * - Unicode: in memory it is wchars
36          */
37         FileTextEncoding m_encoding;
38
39         bool FlagIsSet(UINT line, DWORD flag) const;
40
41 public :
42         CDiffTextBuffer(CMergeDoc * pDoc, int pane);
43
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;
49         bool curUndoGroup();
50         void ReplaceFullLines(CDiffTextBuffer& dbuf, CDiffTextBuffer& sbuf, CCrystalTextView * pSource, int nLineBegin, int nLineEnd, int nAction =CE_ACTION_UNKNOWN);
51
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 = NULL, 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; }
68
69         // If line has text (excluding eol), set strLine to text (excluding eol)
70         bool GetLine(int nLineIndex, CString &strLine) const;
71
72         // if line has any text (including eol), set strLine to text (including eol)
73         bool GetFullLine(int nLineIndex, CString &strLine) const;
74
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;
82 };