青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
GMail/GTalk: yanglinbo#google.com;
MSN/Email: tx7do#yahoo.com.cn;
QQ: 3 0 3 3 9 6 9 2 0 .

一個有意思的給代碼染色的類:CSyntaxColorizer

可以給C++代碼染色,演示程序運行后如圖所示:



其主頁在:http://mypage.uniserve.com/~jeffsch/computing/visualC++/CSyntaxColorizer.html

Description

The CSyntaxColorizer class described here is a fast and versatile class for the syntax highlighting of code. The class is very simple to use, very fast, and highly flexible. The default highlighting mode is VC++, with comments in green, strings in dark blue, and keywords in light blue. The class exposes several methods that can be used for changing these defaults - and color is not the only option. Highlighted words can be made bold, italic, underlined, and more. The exposed methods take a CHARFORMAT structure as a parameter, so whatever text formatting changes can be made with a CHARFORMAT structure can also be made with the keyword, comment, and string formats in CSyntaxColorizer. As well, you are not limited to a predefined and fixed set of keyword groupings. The keywords can be grouped in any way you like, and then manipulated by group. For example, you could assign all compiler directives the group ID of 723 (or whatever) and then set all keywords with group ID 723 to the color red.

The default groupings for the CSyntaxColorizer class are as follows:

Group 0: VC++ keywords such as for, if, while, void, etc
Group 1: VC++ compiler directives such as #define, #include, etc
Group 2: VC++ compiler pragmas such as once, auto_inline, etc

CSyntaxColorizer maintains member variables, (m_cfDefault, m_cfComment and m_cfString), of type CHARFORMAT. These defaults are used when the class initializes its internal lists, and whenever the keyword, comment or string colors are changed using the methods that take a COLORREF parameter instead of a CHARFORMAT parameter. These default structures have a font of Courier New, 10pt size. Naturally, the class exposes methods for changing the defaults (see below).

Here are the declarations in CSyntaxColorizer.h for the exposed methods:

    void Colorize(long StartChar, long nEndChar, CRichEditCtrl *pCtrl);
void Colorize(CHARRANGE cr, CRichEditCtrl *pCtrl);
void GetCommentStyle(CHARFORMAT &cf) { cf = m_cfComment; };
void GetStringStyle(CHARFORMAT &cf) { cf = m_cfString; };
void GetGroupStyle(int grp, CHARFORMAT &cf);
void GetDefaultStyle(CHARFORMAT &cf) { cf = m_cfDefault; };
void SetCommentStyle(CHARFORMAT cf) { m_cfComment = cf; };
void SetCommentColor(COLORREF cr);
void SetStringStyle(CHARFORMAT cf) { m_cfString = cf; };
void SetStringColor(COLORREF cr);
void SetGroupStyle(int grp, CHARFORMAT cf);
void SetGroupColor(int grp, COLORREF cr);
void SetDefaultStyle(CHARFORMAT cf) { m_cfDefault = cf; };
void AddKeyword(LPCTSTR Keyword, CHARFORMAT cf, int grp = 0);
void AddKeyword(LPCTSTR Keyword, COLORREF cr, int grp = 0);
void ClearKeywordList();
CString GetKeywordList();
CString GetKeywordList(int grp);

[Back to Top]

Using CSyntaxColorizer

The simplest and quickest way to use this class is to first declare it, then call one of the overloaded Colorize member functions. For example, this code

    CSyntaxColorizer sc;
sc.Colorize(0, -1, &m_cRichEditCtrl);
first creates the object, then calls its Colorize method, which in this case colorizes all of the text in the specified rich edit box, using CSyntaxColorizer's default font, keyword groupings, and colors described above.

If you don't like the default colors, you can change them:

    sc.SetCommentColor(RGB(255,0,0));
sc.SetStringColor(RGB(0,255,0));
sc.SetGroupColor(nMyGroup,RGB(0,0,255));
The preceding methods change the color using the CHARFORMAT structures that would be returned by their respective "Get..." methods.

If it's more than just colors you don't like, then you can set the CHARFORMAT structures using

    sc.SetCommentStyle(cfMyStyle);
sc.SetStringStyle(cfMyStyle);
sc.SetGroupStyle(nMyGroup,cfMyStyle);
where cfMyStyle is a CHARFORMAT structure that you have created yourself from scratch, or have retrieved using one of the "Get..." methods and then modified to suit.

Adding keywords is easy too. The two AddKeyword methods each take an LPCTSTR as a parameter. The parameter is a NULL terminated list of words separated by commas. For example,

   sc.AddKeyword("for,if,while", RGB(255,0,0), 4);
will add the three keywords to the sc object's list, give them the color red and place them in group 4, using the CHARFORMAT structure currently in m_cfDefault. You can also send a single word as the LPCTSTR parameter. If the keyword already exists in the list, its color and group attributes are overwritten by those passed in the AddKeyword method. The AddKeyword method that takes a CHARFORMAT as a parameter instead of a COLORREF works in a similar fashion.

A word about comments...

By default, CSyntaxColorizer deals with C++ and Java multiline comments starting with /* and single line comments starting with //. If you want single line comments as in VB, (starting with ' or REM), simply add "REM" as one of the keywords. For example:

    sc.AddKeyword("REM",cfMyStyle,nMyGroup);
CSyntaxColorizer will ignore any style or color settings you specify for the REM keyword, and instead will set them to whatever attributes you have set for the comments. CSyntaxColorizer will automatically treat the ' as the start of a single line comment once "REM" is added to the keyword list. Note: if you add only "REM", then "rem", "Rem", etc will not be recognized - you will have to add these as well.

Where a comment starts with // and ends with '\' + '\n' (the line continuation character immediately followed by a newline character) CSyntaxColorizer will recognize it, and treat the next line as a comment line.

[Back to Top]

Speed

CSyntaxColorizer is pretty fast. Small files under 20K or so are colorized practically instantaneously on my 466MHz machine. Larger files, over 100K, take four or five seconds. CSyntaxColorizer can locate and identify words to be colorized fairly quickly, but the big time hog is not in the algorithm itself - it's in the text formatting functions of CRichEditCtrl. If you comment out the two lines (line #494 & 495)

    pCtrl->SetSel(iStart,iOffset + x);
pCtrl->SetSelectionCharFormat(pskTemp->cf);
then a 100K file takes less than a second, but only comments and strings are colorized.

About the Demo

The demo project is a quick and dirty dialog box with a rich edit control. It has a rather crude editing capablity, the minimum required to show off some of CSyntaxColorizer's abilities. In particular, if you type in \* to start off a multiline comment, only the one line with the cursor on it will be reformatted. In this case, press the "Format" button. As well, you can load files, but you can't save them.

For those of you who don't have Visual C++ or just don't feel like compiling the thing, an executable is also available for download.

Downloads

ColorizerDemo.zip - 32 Kb VC++ project (includes all source code)
ColorizerDemo.exe - 32 Kb Windows executable file only

posted on 2008-04-30 21:48 楊粼波 閱讀(528) 評論(1)  編輯 收藏 引用

評論

# re: 一個有意思的給代碼染色的類:CSyntaxColorizer 2010-08-05 14:13 cosplay

I love your blog so much, and there are just some differences with others'. Hope there will be more wonderful things in your blog. .Happy every day!GFH  回復  更多評論   


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            美日韩精品视频| 亚洲少妇最新在线视频| 一区二区三区高清不卡| 永久555www成人免费| 亚洲影院色无极综合| 亚洲美女在线国产| 久久嫩草精品久久久久| 午夜在线不卡| 欧美日韩国产成人| 亚洲激情图片小说视频| 亚洲大胆人体视频| 欧美一区三区三区高中清蜜桃| 亚洲一区二区精品在线| 欧美风情在线观看| 欧美高清免费| 亚洲电影下载| 久久亚洲欧美| 久久伊人免费视频| 国产综合激情| 久久精品国产2020观看福利| 久久av资源网| 国产欧美精品| 性欧美激情精品| 久久av资源网| 国产亚洲一区二区三区在线观看| 一本一本久久a久久精品综合麻豆 一本一本久久a久久精品牛牛影视 | 日韩午夜在线视频| 亚洲精品中文字幕女同| 欧美www视频| 亚洲激情电影中文字幕| 亚洲精品国产精品乱码不99按摩| 欧美一级日韩一级| 久久精品99国产精品日本| 国产女精品视频网站免费| 亚洲免费中文字幕| 久久精品国产第一区二区三区最新章节 | 亚洲精品专区| 亚洲精品一区二区三区蜜桃久| 久久久精品一品道一区| 免费观看成人网| 亚洲国产精品尤物yw在线观看| 欧美成人久久| 国产精品99久久99久久久二8| 午夜精彩视频在线观看不卡| 国产欧美激情| 蜜桃av一区二区| 亚洲精品影视| 欧美一区高清| 亚洲第一级黄色片| 欧美久久久久久久久| 亚洲欧美一级二级三级| 蜜桃视频一区| 亚洲一区二区三区激情| 国产一区二区无遮挡| 免费欧美视频| 亚洲无限乱码一二三四麻| 久久综合五月| 这里只有精品电影| 国产一区二区三区日韩| 欧美精品一区二区在线观看| 亚洲欧美日韩在线观看a三区| 免费成人在线观看视频| 亚洲视屏在线播放| 在线成人激情视频| 国产精品v亚洲精品v日韩精品 | 亚洲午夜在线视频| 久久手机精品视频| 中文亚洲视频在线| 樱花yy私人影院亚洲| 欧美视频精品在线| 麻豆精品传媒视频| 亚洲男人的天堂在线aⅴ视频| 欧美成人在线免费观看| 欧美一区午夜精品| 一区二区三区四区五区精品| 国产一区二区你懂的| 欧美日韩免费| 美女视频黄免费的久久| 午夜精品免费在线| 日韩视频在线永久播放| 欧美不卡福利| 久久精品国产一区二区三| 国产精品99久久久久久久女警| 国内精品视频在线播放| 国产精品久久久久av| 欧美成人午夜视频| 久久久久99精品国产片| 香港成人在线视频| 亚洲一区二区三区激情| 亚洲美女电影在线| 欧美激情一二三区| 免费久久久一本精品久久区| 欧美中文字幕在线播放| 亚洲欧美精品在线观看| 国产精品99久久久久久久女警| 亚洲人成在线播放| 亚洲国产色一区| 影音先锋日韩资源| 国产综合自拍| 国产一区二区三区免费不卡| 国产午夜精品在线观看| 国产欧美日韩精品一区| 国产日韩精品久久久| 国产精品自在线| 国产午夜精品理论片a级大结局| 国产精品一卡二卡| 国产拍揄自揄精品视频麻豆| 国产精品影院在线观看| 国产精品自拍小视频| 国产日韩欧美麻豆| 国产婷婷色一区二区三区在线| 国产日韩欧美在线播放| 国产亚洲精品久久飘花| 国产三级欧美三级日产三级99| 国产精自产拍久久久久久| 国产欧美午夜| 狠狠久久综合婷婷不卡| 精品电影在线观看| 亚洲韩国一区二区三区| 日韩一区二区高清| 亚洲午夜精品久久| 欧美一区二区三区免费视频| 久久久www成人免费无遮挡大片| 久久精品国产免费观看| 麻豆视频一区二区| 亚洲国产精品黑人久久久| 日韩午夜av| 亚洲女性喷水在线观看一区| 久久国产乱子精品免费女 | 国内综合精品午夜久久资源| 一区二区三区自拍| 亚洲精品国偷自产在线99热| 一本到高清视频免费精品| 午夜免费在线观看精品视频| 久久精品1区| 欧美电影在线播放| 亚洲精品一二区| 性欧美1819性猛交| 免费成人高清在线视频| 国产精品成人v| 狠狠88综合久久久久综合网| 亚洲人精品午夜在线观看| 午夜精品福利在线| 女人色偷偷aa久久天堂| av不卡免费看| 久久人人97超碰人人澡爱香蕉| 欧美巨乳波霸| 激情久久综合| 在线视频欧美日韩| 久久综合亚州| 夜夜嗨av一区二区三区网页| 久久久国产精彩视频美女艺术照福利| 欧美精品www| 狠狠入ady亚洲精品| 亚洲视频在线一区观看| 久久综合色天天久久综合图片| 亚洲最新在线视频| 久久久久欧美| 欧美四级电影网站| 亚洲区在线播放| 久久九九免费视频| 亚洲视频在线看| 欧美黑人多人双交| 伊人精品在线| 欧美一区=区| 99精品欧美一区二区三区综合在线| 久久久久一区二区| 国产九区一区在线| 亚洲手机成人高清视频| 欧美国产一区在线| 久久精品国产99国产精品| 国产精品久久久久久户外露出 | 欧美精品一区二区三区高清aⅴ| 国产亚洲精品bt天堂精选| 亚洲一区二区三区四区五区午夜 | 亚洲国产精品一区制服丝袜 | 亚洲最新在线视频| 美女黄网久久| 久久精品亚洲一区二区| 国产精品爽爽爽| 亚洲一区国产精品| 99精品热视频| 欧美日韩成人网| 亚洲人成77777在线观看网| 免费看成人av| 久久全国免费视频| 在线观看亚洲专区| 久久久美女艺术照精彩视频福利播放 | 免费av成人在线| 先锋影音网一区二区| 国产精品一区二区视频| 亚洲欧美日韩一区| 亚洲制服丝袜在线| 国产精品亚发布| 亚洲一区二区视频在线观看| 日韩视频一区二区三区在线播放 | 黄色亚洲免费| 久久久久久亚洲精品杨幂换脸 | 久久久久亚洲综合| 久久国产夜色精品鲁鲁99|