-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathCRorTextView.h
311 lines (248 loc) · 8.55 KB
/
CRorTextView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
#if !defined(AFX_CRorTEXTVIEW__H)
#define AFX_CRorTEXTVIEW__H
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "../exe2c/src/cxmllist.h"
////////////////////////////////////////////////////////////////////////////
// Forward class declarations
class CRorTextBuffer;
class CUpdateContext;
////////////////////////////////////////////////////////////////////////////
// CRorTextView class declaration
// CRorTextView::UpdateView() flags
enum
{
UPDATE_HORZRANGE = 0x0001, // update horz scrollbar
UPDATE_VERTRANGE = 0x0002, // update vert scrollbar
UPDATE_SINGLELINE = 0x0100, // single line has changed
UPDATE_FLAGSONLY = 0x0200, // only line-flags were changed
UPDATE_RESET = 0x1000 // document was reloaded, update all!
};
// Syntax coloring overrides
struct TEXTBLOCK
{
int m_nCharPos;
int m_nColorIndex; //COLORINDEX_COMMENT µÈ
void* handle;
};
class CRorTextView : public CScrollView, public I_COLOROUT
{
DECLARE_DYNCREATE(CRorTextView)
private:
// Painting caching bitmap
CBitmap *m_pCacheBitmap;
// Line/character dimensions
int m_nLineHeight, m_nCharWidth;
void CalcLineCharDim();
// Amount of lines/characters that completely fits the client area
int m_nScreenLines, m_nScreenChars;
int m_nMaxLineLength;
BOOL m_bFocused;
CPoint m_ptAnchor;
CFont *m_apFont;
// Parsing stuff
int m_nParseArraySize;
void GetParseCookie(int nLineIndex);
CPoint WordToRight(CPoint pt);
CPoint WordToLeft(CPoint pt);
CPoint m_ptDrawSelStart, m_ptDrawSelEnd;
CPoint m_ptCursorPos;
CPoint m_ptSelStart, m_ptSelEnd;
void PrepareSelBounds();
int ApproxActualOffset(int nLineIndex, int nOffset);
void AdjustTextPoint(CPoint &point);
void DrawLineHelperImpl(CDC *pdc, CPoint &ptOrigin,
LPCTSTR pszChars, int nCount);
void DrawLineHelperImpl_1(CDC *pdc, CPoint &ptOrigin,
LPCTSTR pszChars, int nCount);
BOOL IsInsideSelBlock(CPoint ptTextPos);
protected:
CImageList *m_pIcons;
CRorTextBuffer *m_pTextBuffer;
HACCEL m_hAccel;
virtual void ResetView();
void UpdateCaret();
CPoint ClientToText(const CPoint &point);
CPoint TextToClient(const CPoint &point);
void InvalidateLines(int nLine1, int nLine2, BOOL bInvalidateMargin = FALSE);
// Keyboard handlers
void MoveLeft(BOOL bSelect);
void MoveRight(BOOL bSelect);
void MoveWordLeft(BOOL bSelect);
void MoveWordRight(BOOL bSelect);
void MoveUp(BOOL bSelect);
void MoveDown(BOOL bSelect);
void MoveHome(BOOL bSelect);
void MoveEnd(BOOL bSelect);
void MovePgUp(BOOL bSelect);
void MovePgDn(BOOL bSelect);
void MoveCtrlHome(BOOL bSelect);
void MoveCtrlEnd(BOOL bSelect);
void SelectAll();
void Copy();
BOOL IsSelection();
BOOL IsInsideSelection(const CPoint &ptTextPos);
void GetSelection(CPoint &ptStart, CPoint &ptEnd);
void SetSelection(const CPoint &ptStart, const CPoint &ptEnd);
int m_nTopLine, m_nOffsetChar;
void PointTrans_ImageToChar(IN CPoint& pt1, OUT CPoint& pt2);
void PointTrans_CharToImage(IN CPoint& pt1, OUT CPoint& pt2);
int GetLineHeight();
int GetCharWidth();
int GetMaxLineLength();
int GetScreenLines();
int GetScreenChars();
CFont *GetFont_1();
void RecalcVertScrollBar(BOOL bPositionOnly = FALSE);
void RecalcHorzScrollBar(BOOL bPositionOnly = FALSE);
// Scrolling helpers
void ScrollToChar(int nNewOffsetChar);
void ScrollToLine(int nNewTopLine, BOOL bNoSmoothScroll = FALSE, BOOL bTrackScrollBar = TRUE);
// Splitter support
virtual void UpdateSiblingScrollPos(BOOL bHorz);
virtual void OnUpdateSibling(CRorTextView *pUpdateSource, BOOL bHorz);
CRorTextView *GetSiblingView(int nRow, int nCol);
virtual int GetLineCount();
virtual int GetLineLength(int nLineIndex);
virtual LPCTSTR GetLineChars(int nLineIndex);
CString GetText(const CPoint &ptStart, const CPoint &ptEnd);
// Clipboard overridable
virtual BOOL PutToClipboard(LPCTSTR pszText);
virtual COLORREF GetColor(int nColorIndex);
void DrawLineHelper(CDC *pdc, CPoint &ptOrigin,
LPCTSTR pszChars, int nCount, CPoint ptTextPos);
virtual void DrawSingleLine(CDC *pdc, int nLineIndex);
void func1(CDC *pdc, TEXTBLOCK *pBuf, int I, int nLength, CPoint& origin,
LPCTSTR pszChars, int nLineIndex);
virtual HINSTANCE GetResourceHandle();
// Attributes
public:
void SetFont();
class CTempDraw* m_pdraw; //ÁÙʱÁ¿
virtual void __stdcall SetBKColor(COLORREF textcolor);
virtual void __stdcall ColorOut(PCSTR str, long len, COLORREF textcolor);
// Default handle to resources
static HINSTANCE s_hResourceInst;
enum
{
// Base colors
COLORINDEX_0 = 0,
COLORINDEX_func,
COLOR_Var,
COLOR_VarH,
COLOR_Immed,
COLOR_ea,
COLOR_type,
COLOR_label,
COLORINDEX_WHITESPACE,
COLORINDEX_BKGND,
COLORINDEX_NORMALTEXT,
COLORINDEX_SELMARGIN,
COLORINDEX_SELBKGND,
COLORINDEX_SELTEXT,
// Syntax colors
COLORINDEX_KEYWORD,
COLORINDEX_COMMENT,
COLORINDEX_NUMBER,
COLORINDEX_OPERATOR, // [JRT]:
COLORINDEX_STRING,
COLORINDEX_PREPROCESSOR,
// Compiler/debugger colors
COLORINDEX_ERRORBKGND,
COLORINDEX_ERRORTEXT,
COLORINDEX_EXECUTIONBKGND,
COLORINDEX_EXECUTIONTEXT,
COLORINDEX_BREAKPOINTBKGND,
COLORINDEX_BREAKPOINTTEXT
// ...
// Expandable: custom elements are allowed.
};
// Operations
public:
void AttachToBuffer(CRorTextBuffer *pBuf = NULL);
void DetachFromBuffer();
// Buffer-view interaction, multiple views
virtual CRorTextBuffer *LocateTextBuffer();
virtual void UpdateView(); //CRorTextView *pSource, CUpdateContext *pContext, DWORD dwFlags, int nLineIndex = -1);
// Operations
void EnsureVisible(CPoint pt);
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRorTextView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL PreTranslateMessage(MSG* pMsg);
virtual void OnPrepareDC(CDC* pDC, CPrintInfo* pInfo = NULL);
protected:
virtual void OnInitialUpdate(); // called first time after construct
//}}AFX_VIRTUAL
// Implementation
public:
CRorTextView();
~CRorTextView();
protected:
// Generated message map functions
protected:
#ifdef _DEBUG
void AssertValidTextPos(const CPoint &pt);
#endif
//{{AFX_MSG(CRorTextView)
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnDestroy();
afx_msg void OnSize(UINT nType, int cx, int cy);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
//afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnEditCopy();
afx_msg void OnEditSelectAll();
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
afx_msg void OnCharLeft();
afx_msg void OnExtCharLeft();
afx_msg void OnCharRight();
afx_msg void OnExtCharRight();
afx_msg void OnWordLeft();
afx_msg void OnExtWordLeft();
afx_msg void OnWordRight();
afx_msg void OnExtWordRight();
afx_msg void OnLineUp();
afx_msg void OnExtLineUp();
afx_msg void OnLineDown();
afx_msg void OnExtLineDown();
afx_msg void OnPageUp();
afx_msg void OnExtPageUp();
afx_msg void OnPageDown();
afx_msg void OnExtPageDown();
afx_msg void OnLineEnd();
afx_msg void OnExtLineEnd();
afx_msg void OnHome();
afx_msg void OnExtHome();
afx_msg void OnTextBegin();
afx_msg void OnExtTextBegin();
afx_msg void OnTextEnd();
afx_msg void OnExtTextEnd();
afx_msg void ScrollUp();
afx_msg void ScrollDown();
afx_msg void ScrollLeft();
afx_msg void ScrollRight();
DECLARE_MESSAGE_MAP()
};
#ifdef _DEBUG
#define ASSERT_VALIDTEXTPOS(pt) AssertValidTextPos(pt);
#else
#define ASSERT_VALIDTEXTPOS(pt)
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_CRorTEXTVIEW__H)