⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ccrystaltextview.h

📁 一个完整的编辑器的代码(很值得参考
💻 H
📖 第 1 页 / 共 3 页
字号:

	@return Character position that matches the end of the given subline, relative
		to the given line.
	*/
	int SubLineEndToCharPos( int nLineIndex, int nSubLineOffset );

	/**
	Returns the character position relative to the given line, that matches
	the start of the given sub line.

	@param nLineIndex Zero based index of the line to work on.
	@param nSubLineOffset Zero based index of the subline inside the given line.

	@return Character position that matches the start of the given subline, relative
		to the given line.
	*/
	int SubLineHomeToCharPos( int nLineIndex, int nSubLineOffset );
	//END SW
    int GetCharWidth ();
    int GetMaxLineLength ();
    int GetScreenLines ();
    int GetScreenChars ();
    CFont *GetFont (BOOL bItalic = FALSE, BOOL bBold = FALSE);

    void RecalcVertScrollBar (BOOL bPositionOnly = FALSE);
    void RecalcHorzScrollBar (BOOL bPositionOnly = FALSE);

    //  Scrolling helpers
    void ScrollToChar (int nNewOffsetChar, BOOL bNoSmoothScroll = FALSE, BOOL bTrackScrollBar = TRUE);
    void ScrollToLine (int nNewTopLine, BOOL bNoSmoothScroll = FALSE, BOOL bTrackScrollBar = TRUE);

	//BEGIN SW
	/**
	Scrolls to the given sub line, so that the sub line is the first visible
	line on the screen.

	@param nNewTopSubLine Index of the sub line to scroll to.
	@param bNoSmoothScroll TRUE to disable smooth scrolling, else FALSE.
	@param bTrackScrollBar TRUE to recalculate the scroll bar after scrolling,
		else FALSE.
	*/
	void ScrollToSubLine( int nNewTopSubLine, BOOL bNoSmoothScroll = FALSE, BOOL bTrackScrollBar = TRUE );
	//END SW

    //  Splitter support
    virtual void UpdateSiblingScrollPos (BOOL bHorz);
    virtual void OnUpdateSibling (CCrystalTextView * pUpdateSource, BOOL bHorz);
    CCrystalTextView *GetSiblingView (int nRow, int nCol);

	//BEGIN SW
	/**
	Returns the number of sublines in the whole text buffer.

	The number of sublines is the sum of all sublines of all lines.

	@return Number of sublines in the whole text buffer.
	*/
	virtual int GetSubLineCount();

	/**
	Returns the zero-based subline index of the given line.

	@param nLineIndex Index of the line to calculate the subline index of

	@return The zero-based subline index of the given line.
	*/
	virtual int GetSubLineIndex( int nLineIndex );

	/**
	Splits the given subline index into line and sub line of this line.

	@param nSubLineIndex The zero based index of the subline to get info about
	@param nLine Gets the line number the give subline is included in
	@param nSubLine Get the subline of the given subline relative to nLine
	*/
	virtual void GetLineBySubLine( int nSubLineIndex, int &nLine, int &nSubLine );
	//END SW

    virtual int GetLineLength (int nLineIndex);
    virtual int GetLineActualLength (int nLineIndex);
    virtual LPCTSTR GetLineChars (int nLineIndex);
    virtual DWORD GetLineFlags (int nLineIndex);
    virtual void GetText (const CPoint & ptStart, const CPoint & ptEnd, CString & text);

    //  Clipboard overridable
    virtual BOOL TextInClipboard ();
    virtual BOOL PutToClipboard (LPCTSTR pszText);
    virtual BOOL GetFromClipboard (CString & text);

    //  Drag-n-drop overrideable
    virtual HGLOBAL PrepareDragData ();
    virtual DROPEFFECT GetDropEffect ();
    virtual void OnDropSource (DROPEFFECT de);
    BOOL IsDraggingText () const;

    virtual COLORREF GetColor (int nColorIndex);
    virtual void GetLineColors (int nLineIndex, COLORREF & crBkgnd,
                                COLORREF & crText, BOOL & bDrawWhitespace);
    virtual BOOL GetItalic (int nColorIndex);
    virtual BOOL GetBold (int nColorIndex);

    void DrawLineHelper (CDC * pdc, CPoint & ptOrigin, const CRect & rcClip, int nColorIndex,
                         LPCTSTR pszChars, int nOffset, int nCount, CPoint ptTextPos);
    virtual void DrawSingleLine (CDC * pdc, const CRect & rect, int nLineIndex);
    virtual void DrawMargin (CDC * pdc, const CRect & rect, int nLineIndex);

	//BEGIN SW
	// word wrapping

	/**
	Called to wrap the line with the given index into sublines.

	The standard implementation wraps the line at the first non-whitespace after
	an whitespace that exceeds the visible line width (nMaxLineWidth). Override
	this function to provide your own word wrapping.

	<b>Attention:</b> Never call this function directly,
	call WrapLineCached() instead, which calls this method.

	@param nLineIndex The index of the line to wrap

	@param nMaxLineWidth The number of characters a subline of this line should
	not exceed (except whitespaces)

	@param anBreaks An array of integers. Put the positions where to wrap the line
	in that array (its allready allocated). If this pointer is NULL, the function
	has only to compute the number of breaks (the parameter nBreaks).

	@param nBreaks The number of breaks this line has (number of sublines - 1). When
	the function is called, this variable is 0. If the line is not wrapped, this value
	should be 0 after the call.

	@see WrapLineCached()
	*/
	virtual void WrapLine( int nLineIndex, int nMaxLineWidth, int *anBreaks, int &nBreaks );

	/**
	Called to wrap the line with the given index into sublines.

	Call this method instead of WrapLine() (which is called internal by this
	method). This function uses an internal cache which contains the number
	of sublines for each line, so it has only to call WrapLine(), if the
	cache for the given line is invalid or if the caller wants to get the
	wrap postions (anBreaks != NULL).

	This functions also tests m_bWordWrap -- you can call it even if
	word wrapping is disabled and you will retrieve a valid value.

	@param nLineIndex The index of the line to wrap

	@param nMaxLineWidth The number of characters a subline of this line should
	not exceed (except whitespaces)

	@param anBreaks An array of integers. Put the positions where to wrap the line
	in that array (its allready allocated). If this pointer is NULL, the function
	has only to compute the number of breaks (the parameter nBreaks).

	@param nBreaks The number of breaks this line has (number of sublines - 1). When
	the function is called, this variable is 0. If the line is not wrapped, this value
	should be 0 after the call.

	@see WrapLine()
	@see m_anSubLines
	*/
	void WrapLineCached( int nLineIndex, int nMaxLineWidth, int *anBreaks, int &nBreaks );

	/**
	Invalidates the cached data for the given lines.

	<b>Remarks:</b> Override this method, if your derived class caches other
	view specific line info, which becomes invalid, when this line changes.
	Call this standard implementation in your overriding.

	@param nLineIndex1 The index of the first line to invalidate.

	@param nLineIndex2 The index of the last line to invalidate. If this value is
	-1 (default) all lines from nLineIndex1 to the end are invalidated.
	*/
	virtual void InvalidateLineCache( int nLineIndex1, int nLineIndex2 );
	//END SW

    //  Syntax coloring overrides
    struct TEXTBLOCK
      {
        int m_nCharPos;
        int m_nColorIndex;
      };

    virtual HINSTANCE GetResourceHandle ();

	//BEGIN SW
	// function to draw a single screen line
	// (a wrapped line can consist of many screen lines
	virtual void DrawScreenLine( CDC *pdc, CPoint &ptOrigin, const CRect &rcClip,
		TEXTBLOCK *pBuf, int nBlocks, int &nActualItem,
		COLORREF crText, COLORREF crBkgnd, BOOL bDrawWhitespace,
		LPCTSTR pszChars,
		int nOffset, int nCount, CPoint ptTextPos );
	//END SW


	//BEGIN SW
	// helpers for incremental search

	/**
	Called each time the position-information in the status bar
	is updated. Use this to change the text of the message field
	in the status bar.

	@param pStatusBar
		Pointer to the status bar
	*/
	void OnUpdateStatusMessage( CStatusBar *pStatusBar );

	/**
	Called by OnFindIncrementalForward() and OnFindIncrementalBackward().

	@param bFindNextOccurence
		TRUE, if the method should look for the next occurence of the
		search string in search direction.

	@see #OnFindIncrementalForward
	@see #OnFindIncrementalBackward
	*/
	void OnEditFindIncremental( BOOL bFindNextOccurence = FALSE );

	/** TRUE if incremental forward search is active, FALSE otherwise */
	BOOL m_bIncrementalSearchForward;

	/** TRUE if incremental backward search is active, FALSE otherwise */
	BOOL m_bIncrementalSearchBackward;

private:
	/** TRUE if we found the string to search for */
	BOOL m_bIncrementalFound;

	/** String we are looking for.*/
	CString *m_pstrIncrementalSearchString;

	/** String we looked for last time.*/
	CString *m_pstrIncrementalSearchStringOld;

	/** Start of selection at the time the incremental search started */
	CPoint m_selStartBeforeIncrementalSearch;

	/** Start of selection at the time the incremental search started */
	CPoint m_selEndBeforeIncrementalSearch;

	/** Cursor position at the time the incremental search started */
	CPoint m_cursorPosBeforeIncrementalSearch;

	/** position to start the incremental search at */
	CPoint m_incrementalSearchStartPos;

	//END SW

public :
    void GoToLine (int nLine, bool bRelative);
    DWORD ParseLine (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLinePlain (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineAsp (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineBasic (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineBatch (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineC (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineDcl (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineFortran (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineHtml (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineIS (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineJava (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineLisp (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLinePascal (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLinePerl (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLinePhp (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLinePython (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineRexx (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineRsrc (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineSgml (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineSh (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineSiod (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineSql (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineTcl (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);
    DWORD ParseLineTex (DWORD dwCookie, int nLineIndex, TEXTBLOCK * pBuf, int &nActualItems);

    // Attributes
public :
    int GetCRLFMode ();
    void SetCRLFMode (int nCRLFMode);
    BOOL GetViewTabs ();
    void SetViewTabs (BOOL bViewTabs);
    int GetTabSize ();
    void SetTabSize (int nTabSize);
    BOOL GetSelectionMargin ();
    void SetSelectionMargin (BOOL bSelMargin);
    void GetFont (LOGFONT & lf);
    void SetFont (const LOGFONT & lf);
    DWORD GetFlags ();
    void SetFlags (DWORD dwFlags);
    BOOL GetSmoothScroll () const;
    void SetSmoothScroll (BOOL bSmoothScroll);
    //  [JRT]:
    BOOL GetDisableDragAndDrop () const;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -