OSDN Git Service

Use enum UNICODESET instead of int as a unicoding variable.
[winmerge-jp/winmerge-jp.git] / Src / DiffTextBuffer.h
1 /** 
2  * @file  DiffTextBuffer.h
3  *
4  * @brief Declaration of CDiffTextBuffer class
5  */
6 // ID line follows -- this is updated by SVN
7 // $Id$
8
9 #ifndef _DIFFTEXT_BUFFER_H_
10 #define _DIFFTEXT_BUFFER_H_
11
12 #include "GhostTextBuffer.h"
13 #include "FileTextEncoding.h"
14
15 class CMergedoc;
16 class PackingInfo;
17
18 /**
19  * @brief Specialized buffer to save file data
20  */
21 class CDiffTextBuffer : public CGhostTextBuffer
22 {
23         friend class CMergeDoc;
24
25 private :
26         CMergeDoc * m_pOwnerDoc; /**< Merge document owning this buffer. */
27         int m_nThisPane; /**< Left/Right side */
28         BOOL FlagIsSet(UINT line, DWORD flag);
29         String m_strTempPath; /**< Temporary files folder. */
30         int unpackerSubcode;
31         /* 
32                 * @brief Unicode encoding from ucr::UNICODESET 
33                 *
34                 * @note m_unicoding and m_codepage are indications of how the buffer is supposed to be saved on disk
35                 * In memory, it is invariant, depending on build:
36                 * ANSI:
37                 *   in memory it is CP_ACP/CP_THREAD_ACP 8-bit characters
38                 * Unicode:
39                 *   in memory it is wchars
40                 */
41         FileTextEncoding m_encoding; /**< File's encoding information. */
42
43         int NoteCRLFStyleFromBuffer(TCHAR *lpLineBegin, DWORD dwLineLen = 0);
44         void ReadLineFromBuffer(TCHAR *lpLineBegin, DWORD dwLineNum, DWORD dwLineLen = 0);
45 public :
46         void SetTempPath(String path);
47         virtual void AddUndoRecord (BOOL bInsert, const CPoint & ptStartPos, const CPoint & ptEndPos,
48                 LPCTSTR pszText, int cchText, int nLinesToValidate, int nActionType = CE_ACTION_UNKNOWN, CDWordArray *paSavedRevisonNumbers = NULL);
49         bool curUndoGroup();
50         void ReplaceLine(CCrystalTextView * pSource, int nLine, LPCTSTR pchText, int cchText, int nAction =CE_ACTION_UNKNOWN);
51         void ReplaceFullLine(CCrystalTextView * pSource, int nLine, const CString& strText, int nAction =CE_ACTION_UNKNOWN);
52
53         int LoadFromFile(LPCTSTR pszFileName, PackingInfo * infoUnpacker,
54                 LPCTSTR filteredFilenames, BOOL & readOnly, CRLFSTYLE nCrlfStyle,
55                 const FileTextEncoding & encoding, CString &sError);
56         int SaveToFile (LPCTSTR pszFileName, BOOL bTempFile, CString & sError,
57                 PackingInfo * infoUnpacker = NULL, CRLFSTYLE nCrlfStyle = CRLF_STYLE_AUTOMATIC,
58                 BOOL bClearModifiedFlag = TRUE );
59         ucr::UNICODESET getUnicoding() const { return m_encoding.m_unicoding; }
60         void setUnicoding(ucr::UNICODESET value) { m_encoding.m_unicoding = value; }
61         int getCodepage() const { return m_encoding.m_codepage; }
62         void setCodepage(int value) { m_encoding.m_codepage = value; }
63         const FileTextEncoding & getEncoding() const { return m_encoding; }
64
65         CDiffTextBuffer(CMergeDoc * pDoc, int pane);
66
67         // If line has text (excluding eol), set strLine to text (excluding eol)
68         BOOL GetLine(int nLineIndex, CString &strLine);
69
70         // if line has any text (including eol), set strLine to text (including eol)
71         BOOL GetFullLine(int nLineIndex, CString &strLine);
72
73         virtual void SetModified (BOOL bModified = TRUE);
74
75         void prepareForRescan();
76
77         /** 
78         After editing a line, we don't know if there is a diff or not.
79         So we clear the LF_DIFF flag (and it is more easy to read during edition).
80         Rescan will set the proper color
81         */
82         virtual void OnNotifyLineHasBeenEdited(int nLine);
83
84         bool IsInitialized() const;
85 };
86
87 #endif // _DIFFTEXT_BUFFER_H_