Multi-view edit III
[TortoiseGit.git] / src / TortoiseMerge / BaseView.h
blobdd5c1e63305fbd6c62644fa9b0801f23f5049028
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2003-2013 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #pragma once
20 #include "DiffData.h"
21 #include "SVNLineDiff.h"
22 #include "ScrollTool.h"
23 #include "Undo.h"
24 #include "LocatorBar.h"
25 #include "LineColors.h"
26 #include "TripleClick.h"
27 #include "IconMenu.h"
28 #include "FindDlg.h"
30 typedef struct inlineDiffPos
32 apr_off_t start;
33 apr_off_t end;
34 } inlineDiffPos;
37 /**
38 * \ingroup TortoiseMerge
40 * View class providing the basic functionality for
41 * showing diffs. Has three parent classes which inherit
42 * from this base class: CLeftView, CRightView and CBottomView.
44 class CBaseView : public CView, public CTripleClick
46 DECLARE_DYNCREATE(CBaseView)
47 friend class CLineDiffBar;
48 public:
49 CBaseView();
50 virtual ~CBaseView();
52 public: // methods
53 /**
54 * Indicates that the underlying document has been updated. Reloads all
55 * data and redraws the view.
57 virtual void DocumentUpdated();
58 /**
59 * Returns the number of lines visible on the view.
61 int GetScreenLines();
62 /**
63 * Scrolls the view to the given line.
64 * \param nNewTopLine The new top line to scroll the view to
65 * \param bTrackScrollBar If TRUE, then the scrollbars are affected too.
67 void ScrollToLine(int nNewTopLine, BOOL bTrackScrollBar = TRUE);
68 void ScrollAllToLine(int nNewTopLine, BOOL bTrackScrollBar = TRUE);
69 void ScrollSide(int delta);
70 void ScrollAllSide(int delta);
71 void ScrollVertical(short delta);
72 static void RecalcAllVertScrollBars(BOOL bPositionOnly = FALSE);
73 static void RecalcAllHorzScrollBars(BOOL bPositionOnly = FALSE);
74 void GoToLine(int nNewLine, BOOL bAll = TRUE);
75 void ScrollToChar(int nNewOffsetChar, BOOL bTrackScrollBar = TRUE);
76 void ScrollAllToChar(int nNewOffsetChar, BOOL bTrackScrollBar = TRUE);
77 void SetReadonly(bool bReadonly = true) {m_bReadonly = bReadonly;}
78 void SetWritable(bool bWritable = true) {m_bReadonly = !bWritable;}
79 void SetWritableIsChangable(bool bWritableIsChangable = true) {m_bReadonlyIsChangable = bWritableIsChangable;}
80 void SetTarget(bool bTarget = true) {m_bTarget = bTarget;}
81 bool IsReadonly() const {return m_bReadonly;}
82 bool IsWritable() const {return !m_bReadonly && m_pViewData;}
83 bool IsReadonlyChangable() const {return m_bReadonlyIsChangable && !IsModified();}
84 bool IsTarget() const {return m_bTarget;}
85 void SetCaretAndGoalPosition(const POINT& pt) {UpdateCaretPosition(pt); UpdateGoalPos(); }
86 void SetCaretAndGoalViewPosition(const POINT& pt) {UpdateCaretViewPosition(pt); UpdateGoalPos(); }
87 void SetCaretPosition(const POINT& pt) { SetCaretViewPosition(ConvertScreenPosToView(pt)); }
88 POINT GetCaretPosition() { return ConvertViewPosToScreen(GetCaretViewPosition()); }
89 void SetCaretViewPosition(const POINT & pt) { m_ptCaretViewPos = pt; }
90 POINT GetCaretViewPosition() { return m_ptCaretViewPos; }
91 void UpdateCaretPosition(const POINT& pt) { SetCaretPosition(pt); UpdateCaret(); }
92 void UpdateCaretViewPosition(const POINT& pt) { SetCaretViewPosition(pt); UpdateCaret(); EnsureCaretVisible(); }
93 void SetCaretToViewStart() { SetCaretToFirstViewLine(); SetCaretToViewLineStart(); }
94 void SetCaretToFirstViewLine() { m_ptCaretViewPos.y=0; }
95 void SetCaretToViewLineStart() { m_ptCaretViewPos.x=0; }
96 void SetCaretToLineStart() { SetCaretAndGoalPosition(SetupPoint(0, GetCaretPosition().y)); }
97 void EnsureCaretVisible();
98 void UpdateCaret();
100 bool ArePointsSame(const POINT &pt1, const POINT &pt2) {return (pt1.x == pt2.x) && (pt1.y == pt2.y); };
101 POINT SetupPoint(int x, int y) {POINT ptRet={x, y}; return ptRet; };
102 POINT ConvertScreenPosToView(const POINT& pt);
103 POINT ConvertViewPosToScreen(const POINT& pt);
105 void RefreshViews();
106 static void BuildAllScreen2ViewVector(); ///< schedule full screen2view rebuild
107 static void BuildAllScreen2ViewVector(int ViewLine); ///< schedule rebuild screen2view for single line
108 static void BuildAllScreen2ViewVector(int FirstViewLine, int LastViewLine); ///< schedule rebuild screen2view for line range (first and last inclusive)
109 void UpdateViewLineNumbers();
110 int CleanEmptyLines(); ///< remove line empty in all views
111 int GetLineCount() const;
112 static int GetViewLineForScreen(int screenLine) { return m_Screen2View.GetViewLineForScreen(screenLine); }
113 int FindScreenLineForViewLine(int viewLine);
114 // TODO: find better consistent names for Multiline(line with sublines) and Subline, Count.. or Get..Count ?
115 int CountMultiLines(int nViewLine);
116 int GetSubLineOffset(int index);
117 LineColors & GetLineColors(int nViewLine);
118 static void UpdateLocator() { if (m_pwndLocator) m_pwndLocator->DocumentUpdated(); }
119 void WrapChanged();
121 void HighlightLines(int start, int end = -1);
122 void HighlightViewLines(int start, int end = -1);
123 inline BOOL IsHidden() const {return m_bIsHidden;}
124 inline void SetHidden(BOOL bHidden) {m_bIsHidden = bHidden;}
125 inline bool IsModified() const {return m_bModified;}
126 void SetModified(bool bModified = true) {m_bModified = bModified; Invalidate();}
127 void SetInlineWordDiff(bool bWord) {m_bInlineWordDiff = bWord;}
128 void SetInlineDiff(bool bDiff) {m_bShowInlineDiff = bDiff;}
129 void SetMarkedWord(const CString& word) {m_sMarkedWord = word; BuildMarkedWordArray();}
130 LPCTSTR GetMarkedWord() {return (LPCTSTR)m_sMarkedWord;}
131 LPCTSTR GetFindString() {return (LPCTSTR)m_sFindText;}
133 // Selection methods; all public methods dealing with selection go here
134 static void ClearSelection();
135 BOOL GetViewSelection(int& start, int& end) const;
136 BOOL HasSelection() const { return (!((m_nSelViewBlockEnd < 0)||(m_nSelViewBlockStart < 0)||(m_nSelViewBlockStart > m_nSelViewBlockEnd))); }
137 BOOL HasTextSelection() const { return ((m_ptSelectionViewPosStart.x != m_ptSelectionViewPosEnd.x) || (m_ptSelectionViewPosStart.y != m_ptSelectionViewPosEnd.y)); }
138 static void SetupAllViewSelection(int start, int end);
139 static void SetupAllSelection(int start, int end);
140 void SetupSelection(int start, int end);
141 static void SetupViewSelection(CBaseView* view, int start, int end);
142 void SetupViewSelection(int start, int end);
143 CString GetSelectedText() const;
145 // state classifying methods; note: state may belong to more classes
146 static bool IsStateConflicted(DiffStates state);
147 static bool IsStateEmpty(DiffStates state);
148 static bool IsStateRemoved(DiffStates state);
149 static DiffStates ResolveState(DiffStates state);
151 bool IsLineEmpty(int nLineIndex);
152 bool IsViewLineEmpty(int nViewLine);
153 bool IsLineRemoved(int nLineIndex);
154 bool IsViewLineRemoved(int nViewLine);
155 bool IsBlockWhitespaceOnly(int nLineIndex, bool& bIdentical);
156 bool IsViewLineConflicted(int nLineIndex);
157 bool HasNextConflict();
158 bool HasPrevConflict();
159 bool HasNextDiff();
160 bool HasPrevDiff();
161 bool GetNextInlineDiff(int & nPos);
162 bool GetPrevInlineDiff(int & nPos);
163 bool HasNextInlineDiff();
164 bool HasPrevInlineDiff();
166 static const viewdata& GetEmptyLineData();
167 void InsertViewEmptyLines(int nFirstView, int nCount);
169 virtual void UseBothLeftFirst() {return UseBothBlocks(m_pwndLeft, m_pwndRight); }
170 virtual void UseBothRightFirst() {return UseBothBlocks(m_pwndRight, m_pwndLeft); }
171 void UseTheirAndYourBlock() {return UseBothLeftFirst(); } ///< ! for backward compatibility
172 void UseYourAndTheirBlock() {return UseBothRightFirst(); } ///< ! for backward compatibility
174 virtual void UseLeftBlock() {return UseViewBlock(m_pwndLeft); }
175 virtual void UseLeftFile() {return UseViewFile(m_pwndLeft); }
176 virtual void UseRightBlock() {return UseViewBlock(m_pwndRight); }
177 virtual void UseRightFile() {return UseViewFile(m_pwndRight); }
179 // ViewData methods
180 void InsertViewData(int index, const CString& sLine, DiffStates state, int linenumber, EOL ending, HIDESTATE hide, int movedline);
181 void InsertViewData(int index, const viewdata& data);
182 void RemoveViewData(int index);
184 const viewdata& GetViewData(int index) const {return m_pViewData->GetData(index); }
185 const CString& GetViewLine(int index) const {return m_pViewData->GetLine(index); }
186 DiffStates GetViewState(int index) const {return m_pViewData->GetState(index); }
187 HIDESTATE GetViewHideState(int index) {return m_pViewData->GetHideState(index); }
188 int GetViewLineNumber(int index) {return m_pViewData->GetLineNumber(index); }
189 int GetViewMovedIndex(int index) {return m_pViewData->GetMovedIndex(index); }
190 int FindViewLineNumber(int number) {return m_pViewData->FindLineNumber(number); }
191 EOL GetViewLineEnding(int index) const {return m_pViewData->GetLineEnding(index); }
193 int GetViewCount() const {return m_pViewData ? m_pViewData->GetCount() : -1; }
195 void SetViewData(int index, const viewdata& data);
196 void SetViewState(int index, DiffStates state);
197 void SetViewLine(int index, const CString& sLine);
198 void SetViewLineNumber(int index, int linenumber);
199 void SetViewLineEnding(int index, EOL ending);
201 static bool IsViewGood(const CBaseView* view ) { return (view != 0) && view->IsWindowVisible(); }
202 static CBaseView * GetFirstGoodView();
204 public: // variables
205 CViewData * m_pViewData;
206 CViewData * m_pOtherViewData;
207 CBaseView * m_pOtherView;
209 CString m_sWindowName; ///< The name of the view which is shown as a window title to the user
210 CString m_sFullFilePath; ///< The full path of the file shown
211 CString m_sConvertedFilePath; ///< the path to the converted file that's shown in the view
212 CFileTextLines::UnicodeType texttype; ///< the text encoding this view uses
213 EOL lineendings; ///< the line endings the view uses
215 BOOL m_bViewWhitespace; ///< If TRUE, then SPACE and TAB are shown as special characters
216 BOOL m_bShowInlineDiff; ///< If TRUE, diffs in lines are marked colored
217 bool m_bShowSelection; ///< If true, selection bars are shown and selected text darkened
218 bool m_bWhitespaceInlineDiffs; ///< if true, inline diffs are shown for identical lines only differing in whitespace
219 int m_nTopLine; ///< The topmost text line in the view
220 std::vector<int> m_arMarkedWordLines; ///< which lines contain a marked word
221 std::vector<int> m_arFindStringLines; ///< which lines contain a found string
223 static CLocatorBar * m_pwndLocator; ///< Pointer to the locator bar on the left
224 static CLineDiffBar * m_pwndLineDiffBar; ///< Pointer to the line diff bar at the bottom
225 static CMFCStatusBar * m_pwndStatusBar;///< Pointer to the status bar
226 static CMainFrame * m_pMainFrame; ///< Pointer to the mainframe
228 void GoToFirstDifference();
229 void GoToFirstConflict();
230 void AddEmptyViewLine(int nLineIndex);
231 #define SAVE_REMOVED 1
232 int SaveFile(int Flags = 0);
233 int SaveFileTo(CString FileName);
235 CWorkingFile * m_pWorkingFile; ///< pointer to source/destination file parametrers
237 protected: // methods
238 enum {
239 MOVERIGHT =0,
240 MOVELEFT = 1,
243 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
244 virtual void OnDraw(CDC * pDC);
245 virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
246 virtual BOOL PreTranslateMessage(MSG* pMsg);
247 BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult);
248 afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
249 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
250 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
251 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
252 afx_msg void OnDestroy();
253 afx_msg void OnSize(UINT nType, int cx, int cy);
254 afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
255 afx_msg void OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
256 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
257 afx_msg void OnKillFocus(CWnd* pNewWnd);
258 afx_msg void OnSetFocus(CWnd* pOldWnd);
259 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
260 afx_msg void OnMergeNextdifference();
261 afx_msg void OnMergePreviousdifference();
262 afx_msg void OnMergePreviousconflict();
263 afx_msg void OnMergeNextconflict();
264 afx_msg void OnNavigateNextinlinediff();
265 afx_msg void OnNavigatePrevinlinediff();
266 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
267 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
268 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
269 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
270 virtual void OnLButtonTrippleClick(UINT nFlags, CPoint point) override;
271 afx_msg void OnEditCopy();
272 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
273 afx_msg void OnTimer(UINT_PTR nIDEvent);
274 afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
275 afx_msg void OnCaretDown();
276 afx_msg void OnCaretLeft();
277 afx_msg void OnCaretRight();
278 afx_msg void OnCaretUp();
279 afx_msg void OnCaretWordleft();
280 afx_msg void OnCaretWordright();
281 afx_msg void OnEditCut();
282 afx_msg void OnEditPaste();
283 afx_msg void OnEditSelectall();
284 afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
285 afx_msg void OnEditFind();
286 afx_msg void OnEditFindnext();
287 afx_msg void OnEditFindprev();
288 afx_msg void OnEditFindnextStart();
289 afx_msg void OnEditFindprevStart();
290 afx_msg void OnEditGotoline();
291 afx_msg void OnToggleReadonly();
293 DECLARE_MESSAGE_MAP()
295 void DrawHeader(CDC *pdc, const CRect &rect);
296 void DrawMargin(CDC *pdc, const CRect &rect, int nLineIndex);
297 void DrawSingleLine(CDC *pDC, const CRect &rc, int nLineIndex);
299 * Draws the horizontal lines around current diff block or selection block.
301 void DrawBlockLine(CDC *pDC, const CRect &rc, int nLineIndex);
303 * Draws the line ending 'char'.
305 void DrawLineEnding(CDC *pDC, const CRect &rc, int nLineIndex, const CPoint& origin);
306 void ExpandChars(const CString &sLine, int nOffset, int nCount, CString &line);
307 CString ExpandChars(const CString &sLine, int nOffset = 0);
308 int CountExpandedChars(const CString &sLine, int nLength);
310 void RecalcVertScrollBar(BOOL bPositionOnly = FALSE);
311 void RecalcHorzScrollBar(BOOL bPositionOnly = FALSE);
313 void OnDoMouseWheel(UINT nFlags, short zDelta, CPoint pt);
314 void OnDoMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
315 void OnDoHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar, CBaseView * master);
316 void OnDoVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar, CBaseView * master);
318 void ShowDiffLines(int nLine);
320 int GetTabSize() const {return m_nTabSize;}
321 void DeleteFonts();
323 void CalcLineCharDim();
324 int GetLineHeight();
325 int GetCharWidth();
326 int GetMaxLineLength();
327 int GetLineLength(int index);
328 int GetViewLineLength(int index) const;
329 int GetScreenChars();
330 int GetAllMinScreenChars() const;
331 int GetAllMaxLineLength() const;
332 int GetAllLineCount() const;
333 int GetAllMinScreenLines() const;
334 CString GetViewLineChars(int index) const;
335 CString GetLineChars(int index);
336 int GetLineNumber(int index) const;
337 CFont * GetFont(BOOL bItalic = FALSE, BOOL bBold = FALSE);
338 int GetLineFromPoint(CPoint point);
339 int GetMarginWidth();
340 COLORREF InlineDiffColor(int nLineIndex);
341 COLORREF InlineViewLineDiffColor(int nLineIndex);
342 bool GetInlineDiffPositions(int lineIndex, std::vector<inlineDiffPos>& positions);
343 void CheckOtherView();
344 static void GetWhitespaceBlock(CViewData *viewData, int nLineIndex, int & nStartBlock, int & nEndBlock);
345 static CString GetWhitespaceString(CViewData *viewData, int nStartBlock, int nEndBlock);
346 bool IsViewLineHidden(int nViewLine);
347 static bool IsViewLineHidden(CViewData * pViewData, int nViewLine);
349 void OnContextMenu(CPoint point, DiffStates state);
351 * Updates the status bar pane. Call this if the document changed.
353 void UpdateStatusBar();
355 static bool IsLeftViewGood() {return IsViewGood(m_pwndLeft);}
356 static bool IsRightViewGood() {return IsViewGood(m_pwndRight);}
357 static bool IsBottomViewGood() {return IsViewGood(m_pwndBottom);}
359 int CalculateActualOffset(const POINT& point);
360 int CalculateCharIndex(int nLineIndex, int nActualOffset);
361 POINT TextToClient(const POINT& point);
362 void DrawTextLine(CDC * pDC, const CRect &rc, int nLineIndex, POINT& coords);
363 void ClearCurrentSelection();
364 void AdjustSelection(bool bMoveLeft);
365 bool SelectNextBlock(int nDirection, bool bConflict, bool bSkipEndOfCurrentBlock = true, bool dryrun = false);
367 enum SearchDirection{SearchNext=0, SearchPrevious=1};
368 bool StringFound(const CString& str, SearchDirection srchDir, int& start, int& end) const;
369 void Search(SearchDirection srchDir);
370 void BuildFindStringArray();
372 void RemoveLine(int nLineIndex);
373 void RemoveSelectedText();
374 void PasteText();
375 void AddUndoViewLine(int nViewLine, bool bAddEmptyLine = false);
377 bool MoveCaretLeft();
378 bool MoveCaretRight();
379 void MoveCaretWordLeft();
380 void MoveCaretWordRight();
381 void OnCaretMove(bool bMoveLeft);
382 void OnCaretMove(bool bMoveLeft, bool isShiftPressed);
383 void UpdateGoalPos();
385 bool IsWordSeparator(const wchar_t ch) const;
386 bool IsCaretAtWordBoundary();
387 void UpdateViewsCaretPosition();
388 void BuildMarkedWordArray();
390 virtual void UseBothBlocks(CBaseView * /*pwndFirst*/, CBaseView * /*pwndLast*/) {};
391 virtual void UseViewBlock(CBaseView * /*pwndView*/) {}
392 virtual void UseViewFile(CBaseView * /*pwndView*/) {}
394 virtual void AddContextItems(CIconMenu& popup, DiffStates state);
395 void AddCutCopyAndPaste(CIconMenu& popup);
396 void CompensateForKeyboard(CPoint& point);
397 static HICON LoadIcon(WORD iconId);
398 void ReleaseBitmap();
399 static bool LinesInOneChange( int direction, DiffStates firstLineState, DiffStates currentLineState );
400 static void FilterWhitespaces(CString& first, CString& second);
401 static void FilterWhitespaces(CString& line);
402 int GetButtonEventLineIndex(const POINT& point);
404 static void ResetUndoStep();
405 void SaveUndoStep();
406 protected: // variables
407 COLORREF m_InlineRemovedBk;
408 COLORREF m_InlineAddedBk;
409 COLORREF m_ModifiedBk;
410 COLORREF m_WhiteSpaceFg;
411 UINT m_nStatusBarID; ///< The ID of the status bar pane used by this view. Must be set by the parent class.
413 SVNLineDiff m_svnlinediff;
414 DWORD m_nInlineDiffMaxLineLength;
415 BOOL m_bOtherDiffChecked;
416 bool m_bModified;
417 BOOL m_bFocused;
418 BOOL m_bViewLinenumbers;
419 BOOL m_bIsHidden;
420 BOOL m_bIconLFs;
421 int m_nLineHeight;
422 int m_nCharWidth;
423 int m_nMaxLineLength;
424 int m_nScreenLines;
425 int m_nScreenChars;
426 int m_nLastScreenChars;
427 int m_nOffsetChar;
428 int m_nTabSize;
429 int m_nDigits;
430 bool m_bInlineWordDiff;
432 // Block selection attributes
433 int m_nSelViewBlockStart;
434 int m_nSelViewBlockEnd;
436 int m_nMouseLine;
437 bool m_mouseInMargin;
438 HCURSOR m_margincursor;
440 // caret
441 bool m_bReadonly;
442 bool m_bReadonlyIsChangable;
443 bool m_bTarget; ///< view intended as result
444 POINT m_ptCaretViewPos;
445 int m_nCaretGoalPos;
447 // Text selection attributes
448 POINT m_ptSelectionViewPosStart;
449 POINT m_ptSelectionViewPosEnd;
450 POINT m_ptSelectionViewPosOrigin;
452 static const UINT m_FindDialogMessage;
453 CFindDlg * m_pFindDialog;
454 CString m_sFindText;
455 BOOL m_bMatchCase;
456 bool m_bLimitToDiff;
457 bool m_bWholeWord;
460 HICON m_hAddedIcon;
461 HICON m_hRemovedIcon;
462 HICON m_hConflictedIcon;
463 HICON m_hConflictedIgnoredIcon;
464 HICON m_hWhitespaceBlockIcon;
465 HICON m_hEqualIcon;
466 HICON m_hEditedIcon;
468 HICON m_hLineEndingCR;
469 HICON m_hLineEndingCRLF;
470 HICON m_hLineEndingLF;
472 HICON m_hMovedIcon;
474 LOGFONT m_lfBaseFont;
475 static const int fontsCount = 4;
476 CFont * m_apFonts[fontsCount];
477 CString m_sConflictedText;
478 CString m_sNoLineNr;
479 CString m_sMarkedWord;
480 CString m_sPreviousMarkedWord;
482 CBitmap * m_pCacheBitmap;
483 CDC * m_pDC;
484 CScrollTool m_ScrollTool;
485 CString m_sWordSeparators;
487 char m_szTip[MAX_PATH*2+1];
488 wchar_t m_wszTip[MAX_PATH*2+1];
489 // These three pointers lead to the three parent
490 // classes CLeftView, CRightView and CBottomView
491 // and are used for the communication between
492 // the views (e.g. synchronized scrolling, ...)
493 // To find out which parent class this object
494 // is made of just compare e.g. (m_pwndLeft==this).
495 static CBaseView * m_pwndLeft; ///< Pointer to the left view. Must be set by the CLeftView parent class.
496 static CBaseView * m_pwndRight; ///< Pointer to the right view. Must be set by the CRightView parent class.
497 static CBaseView * m_pwndBottom; ///< Pointer to the bottom view. Must be set by the CBottomView parent class.
499 struct TScreenLineInfo
501 int nViewLine;
502 int nViewSubLine;
504 class TScreenedViewLine
506 public:
507 TScreenedViewLine()
509 Clear();
512 void Clear()
514 bSublinesSet = false;
515 eIcon = ICN_UNKNOWN;
516 bLineColorsSet = false;
517 bLineColorsSetWhiteSpace = false;
520 bool bSublinesSet;
521 std::vector<CString> SubLines;
523 enum EIcon
525 ICN_UNKNOWN,
526 ICN_NONE,
527 ICN_EDIT,
528 ICN_SAME,
529 ICN_WHITESPACEDIFF,
530 ICN_ADD,
531 ICN_REMOVED,
532 ICN_MOVED,
533 ICN_CONFLICT,
534 ICN_CONFLICTIGNORED,
535 } eIcon;
537 bool bLineColorsSetWhiteSpace;
538 LineColors lineColorsWhiteSpace;
539 bool bLineColorsSet;
540 LineColors lineColors;
542 std::vector<TScreenedViewLine> m_ScreenedViewLine; ///< cached data for screening
544 static allviewstate m_AllState;
545 viewstate * m_pState;
547 enum PopupCommands
549 // 2-pane view commands
550 POPUPCOMMAND_USELEFTBLOCK = 1, // 0 means the context menu was dismissed
551 POPUPCOMMAND_USELEFTFILE,
552 POPUPCOMMAND_USEBOTHLEFTFIRST,
553 POPUPCOMMAND_USEBOTHRIGHTFIRST,
554 // 3-pane view commands
555 POPUPCOMMAND_USEYOURANDTHEIRBLOCK,
556 POPUPCOMMAND_USETHEIRANDYOURBLOCK,
557 POPUPCOMMAND_USEYOURBLOCK,
558 POPUPCOMMAND_USEYOURFILE,
559 POPUPCOMMAND_USETHEIRBLOCK,
560 POPUPCOMMAND_USETHEIRFILE,
563 class Screen2View
565 public:
566 Screen2View()
567 : m_pViewData(NULL)
568 {m_bFull=false; }
570 int GetViewLineForScreen(int screenLine);
571 int GetSubLineOffset(int screenLine);
572 TScreenLineInfo GetScreenLineInfo(int screenLine);
573 int FindScreenLineForViewLine(int viewLine);
574 void ScheduleFullRebuild(CViewData * ViewData);
575 void ScheduleRangeRebuild(CViewData * ViewData, int FirstViewLine, int LastViewLine);
576 int size();
578 private:
579 struct TRebuildRange
581 int FirstViewLine;
582 int LastViewLine;
585 bool FixScreenedCacheSize(CBaseView* View);
586 void RebuildIfNecessary();
587 bool ResetScreenedViewLineCache(CBaseView* View);
588 bool ResetScreenedViewLineCache(CBaseView* View, const TRebuildRange& Range);
590 CViewData * m_pViewData;
591 bool m_bFull;
592 std::vector<TScreenLineInfo> m_Screen2View;
593 std::vector<TRebuildRange> m_RebuildRanges;
596 static Screen2View m_Screen2View;
597 CFileTextLines::SaveParams m_SaveParams; ///< encoding and new line style for saving