Open the explorer with the converted temp file selected on a Ctrl+trippleclick on...
[TortoiseGit.git] / src / TortoiseMerge / BaseView.h
blob4a784de3298b749c1f7ac9718e8a362273ed558d
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 SetTarget(bool bTarget = true) {m_bTarget = bTarget;}
80 bool IsReadonly() const {return m_bReadonly;}
81 bool IsWritable() const {return !m_bReadonly && m_pViewData;}
82 bool IsTarget() const {return m_bTarget;}
83 void SetCaretAndGoalPosition(const POINT& pt) {UpdateCaretPosition(pt); UpdateGoalPos(); }
84 void SetCaretAndGoalViewPosition(const POINT& pt) {UpdateCaretViewPosition(pt); UpdateGoalPos(); }
85 void SetCaretPosition(const POINT& pt) { SetCaretViewPosition(ConvertScreenPosToView(pt)); }
86 POINT GetCaretPosition() { return ConvertViewPosToScreen(GetCaretViewPosition()); }
87 void SetCaretViewPosition(const POINT & pt) { m_ptCaretViewPos = pt; }
88 POINT GetCaretViewPosition() { return m_ptCaretViewPos; }
89 void UpdateCaretPosition(const POINT& pt) { SetCaretPosition(pt); UpdateCaret(); }
90 void UpdateCaretViewPosition(const POINT& pt) { SetCaretViewPosition(pt); UpdateCaret(); EnsureCaretVisible(); }
91 void SetCaretToViewStart() { SetCaretToFirstViewLine(); SetCaretToViewLineStart(); }
92 void SetCaretToFirstViewLine() { m_ptCaretViewPos.y=0; }
93 void SetCaretToViewLineStart() { m_ptCaretViewPos.x=0; }
94 void SetCaretToLineStart() { SetCaretAndGoalPosition(SetupPoint(0, GetCaretPosition().y)); }
95 void EnsureCaretVisible();
96 void UpdateCaret();
98 bool ArePointsSame(const POINT &pt1, const POINT &pt2) {return (pt1.x == pt2.x) && (pt1.y == pt2.y); };
99 POINT SetupPoint(int x, int y) {POINT ptRet={x, y}; return ptRet; };
100 POINT ConvertScreenPosToView(const POINT& pt);
101 POINT ConvertViewPosToScreen(const POINT& pt);
103 void RefreshViews();
104 static void BuildAllScreen2ViewVector(); ///< schedule full screen2view rebuild
105 static void BuildAllScreen2ViewVector(int ViewLine); ///< schedule rebuild screen2view for single line
106 static void BuildAllScreen2ViewVector(int FirstViewLine, int LastViewLine); ///< schedule rebuild screen2view for line range (first and last inclusive)
107 void UpdateViewLineNumbers();
108 int CleanEmptyLines(); ///< remove line empty in all views
109 int GetLineCount() const;
110 static int GetViewLineForScreen(int screenLine) { return m_Screen2View.GetViewLineForScreen(screenLine); }
111 int FindScreenLineForViewLine(int viewLine);
112 // TODO: find better consistent names for Multiline(line with sublines) and Subline, Count.. or Get..Count ?
113 int CountMultiLines(int nViewLine);
114 int GetSubLineOffset(int index);
115 LineColors & GetLineColors(int nViewLine);
116 static void UpdateLocator() { if (m_pwndLocator) m_pwndLocator->DocumentUpdated(); }
117 void WrapChanged();
119 void HighlightLines(int start, int end = -1);
120 void HighlightViewLines(int start, int end = -1);
121 inline BOOL IsHidden() const {return m_bIsHidden;}
122 inline void SetHidden(BOOL bHidden) {m_bIsHidden = bHidden;}
123 inline bool IsModified() const {return m_bModified;}
124 void SetModified(bool bModified = true) {m_bModified = bModified; Invalidate();}
125 void SetInlineWordDiff(bool bWord) {m_bInlineWordDiff = bWord;}
126 void SetInlineDiff(bool bDiff) {m_bShowInlineDiff = bDiff;}
127 void SetMarkedWord(const CString& word) {m_sMarkedWord = word; BuildMarkedWordArray();}
128 LPCTSTR GetMarkedWord() {return (LPCTSTR)m_sMarkedWord;}
129 LPCTSTR GetFindString() {return (LPCTSTR)m_sFindText;}
131 // Selection methods; all public methods dealing with selection go here
132 static void ClearSelection();
133 BOOL GetViewSelection(int& start, int& end) const;
134 BOOL HasSelection() const { return (!((m_nSelViewBlockEnd < 0)||(m_nSelViewBlockStart < 0)||(m_nSelViewBlockStart > m_nSelViewBlockEnd))); }
135 BOOL HasTextSelection() const { return ((m_ptSelectionViewPosStart.x != m_ptSelectionViewPosEnd.x) || (m_ptSelectionViewPosStart.y != m_ptSelectionViewPosEnd.y)); }
136 static void SetupAllViewSelection(int start, int end);
137 static void SetupAllSelection(int start, int end);
138 void SetupSelection(int start, int end);
139 static void SetupViewSelection(CBaseView* view, int start, int end);
140 void SetupViewSelection(int start, int end);
141 CString GetSelectedText() const;
143 // state classifying methods; note: state may belong to more classes
144 static bool IsStateConflicted(DiffStates state);
145 static bool IsStateEmpty(DiffStates state);
146 static bool IsStateRemoved(DiffStates state);
147 static DiffStates ResolveState(DiffStates state);
149 bool IsLineEmpty(int nLineIndex);
150 bool IsViewLineEmpty(int nViewLine);
151 bool IsLineRemoved(int nLineIndex);
152 bool IsViewLineRemoved(int nViewLine);
153 bool IsBlockWhitespaceOnly(int nLineIndex, bool& bIdentical);
154 bool IsViewLineConflicted(int nLineIndex);
155 bool HasNextConflict();
156 bool HasPrevConflict();
157 bool HasNextDiff();
158 bool HasPrevDiff();
159 bool GetNextInlineDiff(int & nPos);
160 bool GetPrevInlineDiff(int & nPos);
161 bool HasNextInlineDiff();
162 bool HasPrevInlineDiff();
164 static const viewdata& GetEmptyLineData();
165 void InsertViewEmptyLines(int nFirstView, int nCount);
167 virtual void UseBothLeftFirst() {return UseBothBlocks(m_pwndLeft, m_pwndRight); }
168 virtual void UseBothRightFirst() {return UseBothBlocks(m_pwndRight, m_pwndLeft); }
169 void UseTheirAndYourBlock() {return UseBothLeftFirst(); } ///< ! for backward compatibility
170 void UseYourAndTheirBlock() {return UseBothRightFirst(); } ///< ! for backward compatibility
172 virtual void UseLeftBlock() {return UseViewBlock(m_pwndLeft); }
173 virtual void UseLeftFile() {return UseViewFile(m_pwndLeft); }
174 virtual void UseRightBlock() {return UseViewBlock(m_pwndRight); }
175 virtual void UseRightFile() {return UseViewFile(m_pwndRight); }
177 // ViewData methods
178 void InsertViewData(int index, const CString& sLine, DiffStates state, int linenumber, EOL ending, HIDESTATE hide, int movedline);
179 void InsertViewData(int index, const viewdata& data);
180 void RemoveViewData(int index);
182 const viewdata& GetViewData(int index) const {return m_pViewData->GetData(index); }
183 const CString& GetViewLine(int index) const {return m_pViewData->GetLine(index); }
184 DiffStates GetViewState(int index) const {return m_pViewData->GetState(index); }
185 HIDESTATE GetViewHideState(int index) {return m_pViewData->GetHideState(index); }
186 int GetViewLineNumber(int index) {return m_pViewData->GetLineNumber(index); }
187 int GetViewMovedIndex(int index) {return m_pViewData->GetMovedIndex(index); }
188 int FindViewLineNumber(int number) {return m_pViewData->FindLineNumber(number); }
189 EOL GetViewLineEnding(int index) const {return m_pViewData->GetLineEnding(index); }
191 int GetViewCount() const {return m_pViewData ? m_pViewData->GetCount() : -1; }
193 void SetViewData(int index, const viewdata& data);
194 void SetViewState(int index, DiffStates state);
195 void SetViewLine(int index, const CString& sLine);
196 void SetViewLineNumber(int index, int linenumber);
197 void SetViewLineEnding(int index, EOL ending);
199 static bool IsViewGood(const CBaseView* view ) { return (view != 0) && view->IsWindowVisible(); }
200 static CBaseView * GetFirstGoodView();
202 public: // variables
203 CViewData * m_pViewData;
204 CViewData * m_pOtherViewData;
205 CBaseView * m_pOtherView;
207 CString m_sWindowName; ///< The name of the view which is shown as a window title to the user
208 CString m_sFullFilePath; ///< The full path of the file shown
209 CString m_sConvertedFilePath; ///< the path to the converted file that's shown in the view
210 CFileTextLines::UnicodeType texttype; ///< the text encoding this view uses
211 EOL lineendings; ///< the line endings the view uses
213 BOOL m_bViewWhitespace; ///< If TRUE, then SPACE and TAB are shown as special characters
214 BOOL m_bShowInlineDiff; ///< If TRUE, diffs in lines are marked colored
215 bool m_bShowSelection; ///< If true, selection bars are shown and selected text darkened
216 bool m_bWhitespaceInlineDiffs; ///< if true, inline diffs are shown for identical lines only differing in whitespace
217 int m_nTopLine; ///< The topmost text line in the view
218 std::vector<int> m_arMarkedWordLines; ///< which lines contain a marked word
219 std::vector<int> m_arFindStringLines; ///< which lines contain a found string
221 static CLocatorBar * m_pwndLocator; ///< Pointer to the locator bar on the left
222 static CLineDiffBar * m_pwndLineDiffBar; ///< Pointer to the line diff bar at the bottom
223 static CMFCStatusBar * m_pwndStatusBar;///< Pointer to the status bar
224 static CMainFrame * m_pMainFrame; ///< Pointer to the mainframe
226 void GoToFirstDifference();
227 void GoToFirstConflict();
228 void AddEmptyViewLine(int nLineIndex);
230 protected: // methods
231 enum {
232 MOVERIGHT =0,
233 MOVELEFT = 1,
236 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
237 virtual void OnDraw(CDC * pDC);
238 virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
239 virtual BOOL PreTranslateMessage(MSG* pMsg);
240 BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR, LRESULT *pResult);
241 afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
242 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
243 afx_msg BOOL OnEraseBkgnd(CDC* pDC);
244 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
245 afx_msg void OnDestroy();
246 afx_msg void OnSize(UINT nType, int cx, int cy);
247 afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
248 afx_msg void OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
249 afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
250 afx_msg void OnKillFocus(CWnd* pNewWnd);
251 afx_msg void OnSetFocus(CWnd* pOldWnd);
252 afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
253 afx_msg void OnMergeNextdifference();
254 afx_msg void OnMergePreviousdifference();
255 afx_msg void OnMergePreviousconflict();
256 afx_msg void OnMergeNextconflict();
257 afx_msg void OnNavigateNextinlinediff();
258 afx_msg void OnNavigatePrevinlinediff();
259 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
260 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
261 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
262 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
263 virtual void OnLButtonTrippleClick(UINT nFlags, CPoint point) override;
264 afx_msg void OnEditCopy();
265 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
266 afx_msg void OnTimer(UINT_PTR nIDEvent);
267 afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
268 afx_msg void OnCaretDown();
269 afx_msg void OnCaretLeft();
270 afx_msg void OnCaretRight();
271 afx_msg void OnCaretUp();
272 afx_msg void OnCaretWordleft();
273 afx_msg void OnCaretWordright();
274 afx_msg void OnEditCut();
275 afx_msg void OnEditPaste();
276 afx_msg void OnEditSelectall();
277 afx_msg LRESULT OnFindDialogMessage(WPARAM wParam, LPARAM lParam);
278 afx_msg void OnEditFind();
279 afx_msg void OnEditFindnext();
280 afx_msg void OnEditFindprev();
281 afx_msg void OnEditFindnextStart();
282 afx_msg void OnEditFindprevStart();
283 afx_msg void OnEditGotoline();
285 DECLARE_MESSAGE_MAP()
287 void DrawHeader(CDC *pdc, const CRect &rect);
288 void DrawMargin(CDC *pdc, const CRect &rect, int nLineIndex);
289 void DrawSingleLine(CDC *pDC, const CRect &rc, int nLineIndex);
291 * Draws the horizontal lines around current diff block or selection block.
293 void DrawBlockLine(CDC *pDC, const CRect &rc, int nLineIndex);
295 * Draws the line ending 'char'.
297 void DrawLineEnding(CDC *pDC, const CRect &rc, int nLineIndex, const CPoint& origin);
298 void ExpandChars(const CString &sLine, int nOffset, int nCount, CString &line);
299 CString ExpandChars(const CString &sLine, int nOffset = 0);
300 int CountExpandedChars(const CString &sLine, int nLength);
302 void RecalcVertScrollBar(BOOL bPositionOnly = FALSE);
303 void RecalcHorzScrollBar(BOOL bPositionOnly = FALSE);
305 void OnDoMouseWheel(UINT nFlags, short zDelta, CPoint pt);
306 void OnDoMouseHWheel(UINT nFlags, short zDelta, CPoint pt);
307 void OnDoHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar, CBaseView * master);
308 void OnDoVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar, CBaseView * master);
310 void ShowDiffLines(int nLine);
312 int GetTabSize() const {return m_nTabSize;}
313 void DeleteFonts();
315 void CalcLineCharDim();
316 int GetLineHeight();
317 int GetCharWidth();
318 int GetMaxLineLength();
319 int GetLineLength(int index);
320 int GetViewLineLength(int index) const;
321 int GetScreenChars();
322 int GetAllMinScreenChars() const;
323 int GetAllMaxLineLength() const;
324 int GetAllLineCount() const;
325 int GetAllMinScreenLines() const;
326 CString GetViewLineChars(int index) const;
327 CString GetLineChars(int index);
328 int GetLineNumber(int index) const;
329 CFont * GetFont(BOOL bItalic = FALSE, BOOL bBold = FALSE);
330 int GetLineFromPoint(CPoint point);
331 int GetMarginWidth();
332 COLORREF InlineDiffColor(int nLineIndex);
333 COLORREF InlineViewLineDiffColor(int nLineIndex);
334 bool GetInlineDiffPositions(int lineIndex, std::vector<inlineDiffPos>& positions);
335 void CheckOtherView();
336 static void GetWhitespaceBlock(CViewData *viewData, int nLineIndex, int & nStartBlock, int & nEndBlock);
337 static CString GetWhitespaceString(CViewData *viewData, int nStartBlock, int nEndBlock);
338 bool IsViewLineHidden(int nViewLine);
339 static bool IsViewLineHidden(CViewData * pViewData, int nViewLine);
341 void OnContextMenu(CPoint point, DiffStates state);
343 * Updates the status bar pane. Call this if the document changed.
345 void UpdateStatusBar();
347 static bool IsLeftViewGood() {return IsViewGood(m_pwndLeft);}
348 static bool IsRightViewGood() {return IsViewGood(m_pwndRight);}
349 static bool IsBottomViewGood() {return IsViewGood(m_pwndBottom);}
351 int CalculateActualOffset(const POINT& point);
352 int CalculateCharIndex(int nLineIndex, int nActualOffset);
353 POINT TextToClient(const POINT& point);
354 void DrawTextLine(CDC * pDC, const CRect &rc, int nLineIndex, POINT& coords);
355 void ClearCurrentSelection();
356 void AdjustSelection(bool bMoveLeft);
357 bool SelectNextBlock(int nDirection, bool bConflict, bool bSkipEndOfCurrentBlock = true, bool dryrun = false);
359 enum SearchDirection{SearchNext=0, SearchPrevious=1};
360 bool StringFound(const CString& str, SearchDirection srchDir, int& start, int& end) const;
361 void Search(SearchDirection srchDir);
362 void BuildFindStringArray();
364 void RemoveLine(int nLineIndex);
365 void RemoveSelectedText();
366 void PasteText();
367 void AddUndoViewLine(int nViewLine, bool bAddEmptyLine = false);
369 bool MoveCaretLeft();
370 bool MoveCaretRight();
371 void MoveCaretWordLeft();
372 void MoveCaretWordRight();
373 void OnCaretMove(bool bMoveLeft);
374 void OnCaretMove(bool bMoveLeft, bool isShiftPressed);
375 void UpdateGoalPos();
377 bool IsWordSeparator(const wchar_t ch) const;
378 bool IsCaretAtWordBoundary();
379 void UpdateViewsCaretPosition();
380 void BuildMarkedWordArray();
382 virtual void UseBothBlocks(CBaseView * /*pwndFirst*/, CBaseView * /*pwndLast*/) {};
383 virtual void UseViewBlock(CBaseView * /*pwndView*/) {}
384 virtual void UseViewFile(CBaseView * /*pwndView*/) {}
386 virtual void AddContextItems(CIconMenu& popup, DiffStates state);
387 void AddCutCopyAndPaste(CIconMenu& popup);
388 void CompensateForKeyboard(CPoint& point);
389 static HICON LoadIcon(WORD iconId);
390 void ReleaseBitmap();
391 static bool LinesInOneChange( int direction, DiffStates firstLineState, DiffStates currentLineState );
392 static void FilterWhitespaces(CString& first, CString& second);
393 static void FilterWhitespaces(CString& line);
394 int GetButtonEventLineIndex(const POINT& point);
396 static void ResetUndoStep();
397 void SaveUndoStep();
398 protected: // variables
399 COLORREF m_InlineRemovedBk;
400 COLORREF m_InlineAddedBk;
401 COLORREF m_ModifiedBk;
402 COLORREF m_WhiteSpaceFg;
403 UINT m_nStatusBarID; ///< The ID of the status bar pane used by this view. Must be set by the parent class.
405 SVNLineDiff m_svnlinediff;
406 DWORD m_nInlineDiffMaxLineLength;
407 BOOL m_bOtherDiffChecked;
408 bool m_bModified;
409 BOOL m_bFocused;
410 BOOL m_bViewLinenumbers;
411 BOOL m_bIsHidden;
412 BOOL m_bIconLFs;
413 int m_nLineHeight;
414 int m_nCharWidth;
415 int m_nMaxLineLength;
416 int m_nScreenLines;
417 int m_nScreenChars;
418 int m_nLastScreenChars;
419 int m_nOffsetChar;
420 int m_nTabSize;
421 int m_nDigits;
422 bool m_bInlineWordDiff;
424 // Block selection attributes
425 int m_nSelViewBlockStart;
426 int m_nSelViewBlockEnd;
428 int m_nMouseLine;
429 bool m_mouseInMargin;
430 HCURSOR m_margincursor;
432 // caret
433 bool m_bReadonly;
434 bool m_bTarget; ///< view intended as result
435 POINT m_ptCaretViewPos;
436 int m_nCaretGoalPos;
438 // Text selection attributes
439 POINT m_ptSelectionViewPosStart;
440 POINT m_ptSelectionViewPosEnd;
441 POINT m_ptSelectionViewPosOrigin;
443 static const UINT m_FindDialogMessage;
444 CFindDlg * m_pFindDialog;
445 CString m_sFindText;
446 BOOL m_bMatchCase;
447 bool m_bLimitToDiff;
448 bool m_bWholeWord;
451 HICON m_hAddedIcon;
452 HICON m_hRemovedIcon;
453 HICON m_hConflictedIcon;
454 HICON m_hConflictedIgnoredIcon;
455 HICON m_hWhitespaceBlockIcon;
456 HICON m_hEqualIcon;
457 HICON m_hEditedIcon;
459 HICON m_hLineEndingCR;
460 HICON m_hLineEndingCRLF;
461 HICON m_hLineEndingLF;
463 HICON m_hMovedIcon;
465 LOGFONT m_lfBaseFont;
466 static const int fontsCount = 4;
467 CFont * m_apFonts[fontsCount];
468 CString m_sConflictedText;
469 CString m_sNoLineNr;
470 CString m_sMarkedWord;
471 CString m_sPreviousMarkedWord;
473 CBitmap * m_pCacheBitmap;
474 CDC * m_pDC;
475 CScrollTool m_ScrollTool;
476 CString m_sWordSeparators;
478 char m_szTip[MAX_PATH*2+1];
479 wchar_t m_wszTip[MAX_PATH*2+1];
480 // These three pointers lead to the three parent
481 // classes CLeftView, CRightView and CBottomView
482 // and are used for the communication between
483 // the views (e.g. synchronized scrolling, ...)
484 // To find out which parent class this object
485 // is made of just compare e.g. (m_pwndLeft==this).
486 static CBaseView * m_pwndLeft; ///< Pointer to the left view. Must be set by the CLeftView parent class.
487 static CBaseView * m_pwndRight; ///< Pointer to the right view. Must be set by the CRightView parent class.
488 static CBaseView * m_pwndBottom; ///< Pointer to the bottom view. Must be set by the CBottomView parent class.
490 struct TScreenLineInfo
492 int nViewLine;
493 int nViewSubLine;
495 class TScreenedViewLine
497 public:
498 TScreenedViewLine()
500 Clear();
503 void Clear()
505 bSublinesSet = false;
506 eIcon = ICN_UNKNOWN;
507 bLineColorsSet = false;
508 bLineColorsSetWhiteSpace = false;
511 bool bSublinesSet;
512 std::vector<CString> SubLines;
514 enum EIcon
516 ICN_UNKNOWN,
517 ICN_NONE,
518 ICN_EDIT,
519 ICN_SAME,
520 ICN_WHITESPACEDIFF,
521 ICN_ADD,
522 ICN_REMOVED,
523 ICN_MOVED,
524 ICN_CONFLICT,
525 ICN_CONFLICTIGNORED,
526 } eIcon;
528 bool bLineColorsSetWhiteSpace;
529 LineColors lineColorsWhiteSpace;
530 bool bLineColorsSet;
531 LineColors lineColors;
533 std::vector<TScreenedViewLine> m_ScreenedViewLine; ///< cached data for screening
535 static allviewstate m_AllState;
536 viewstate * m_pState;
538 enum PopupCommands
540 // 2-pane view commands
541 POPUPCOMMAND_USELEFTBLOCK = 1, // 0 means the context menu was dismissed
542 POPUPCOMMAND_USELEFTFILE,
543 POPUPCOMMAND_USEBOTHLEFTFIRST,
544 POPUPCOMMAND_USEBOTHRIGHTFIRST,
545 // 3-pane view commands
546 POPUPCOMMAND_USEYOURANDTHEIRBLOCK,
547 POPUPCOMMAND_USETHEIRANDYOURBLOCK,
548 POPUPCOMMAND_USEYOURBLOCK,
549 POPUPCOMMAND_USEYOURFILE,
550 POPUPCOMMAND_USETHEIRBLOCK,
551 POPUPCOMMAND_USETHEIRFILE,
554 class Screen2View
556 public:
557 Screen2View()
558 : m_pViewData(NULL)
559 {m_bFull=false; }
561 int GetViewLineForScreen(int screenLine);
562 int GetSubLineOffset(int screenLine);
563 TScreenLineInfo GetScreenLineInfo(int screenLine);
564 int FindScreenLineForViewLine(int viewLine);
565 void ScheduleFullRebuild(CViewData * ViewData);
566 void ScheduleRangeRebuild(CViewData * ViewData, int FirstViewLine, int LastViewLine);
567 int size();
569 private:
570 struct TRebuildRange
572 int FirstViewLine;
573 int LastViewLine;
576 bool FixScreenedCacheSize(CBaseView* View);
577 void RebuildIfNecessary();
578 bool ResetScreenedViewLineCache(CBaseView* View);
579 bool ResetScreenedViewLineCache(CBaseView* View, const TRebuildRange& Range);
581 CViewData * m_pViewData;
582 bool m_bFull;
583 std::vector<TScreenLineInfo> m_Screen2View;
584 std::vector<TRebuildRange> m_RebuildRanges;
587 static Screen2View m_Screen2View;