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

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
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 楊粼波 閱讀(523) 評論(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  回復  更多評論   

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            亚洲伦理在线免费看| 久久精品一区二区国产| 欧美激情精品久久久| 欧美大片国产精品| 9色精品在线| 99视频超级精品| 国产精品亚洲一区| 久久女同互慰一区二区三区| 亚洲国产成人av好男人在线观看| 亚洲天堂网在线观看| 亚洲毛片在线观看.| 国产精品每日更新| 久久夜色精品国产| 欧美精品久久一区二区| 午夜精品久久一牛影视| 久久久久国产精品一区三寸 | 欧美在线免费| 亚洲精品免费在线观看| 亚洲制服av| 最新日韩欧美| 亚洲女同在线| 日韩视频久久| 欧美伊人久久久久久久久影院| 亚洲破处大片| 欧美一级大片在线免费观看| 亚洲精品韩国| 久久国产免费| 宅男噜噜噜66一区二区66| 欧美亚洲一区在线| 亚洲视频欧美在线| 久久综合电影| 久久成人资源| 欧美三级午夜理伦三级中文幕| 久久精品国语| 国产精品成人在线观看| 欧美国产精品劲爆| 国产亚洲精品久久久久婷婷瑜伽 | 久久久久国产精品午夜一区| 欧美精品激情在线| 免费久久99精品国产自| 国产无一区二区| 99re在线精品| 99re视频这里只有精品| 老司机精品视频网站| 久久精品亚洲国产奇米99| 欧美视频一区二区| 亚洲精品影院| 日韩一二在线观看| 欧美大片在线观看一区| 美女亚洲精品| 在线观看亚洲| 久久精品一区二区三区不卡| 欧美在线免费观看视频| 国产精品国产三级国产普通话99| 亚洲国产影院| 亚洲激情影视| 麻豆精品91| 欧美成人乱码一区二区三区| 影音欧美亚洲| 久久综合一区| 欧美电影免费观看网站| 亚洲第一天堂无码专区| 久久频这里精品99香蕉| 欧美成人一区二区| 悠悠资源网亚洲青| 美女在线一区二区| 欧美激情一区二区三区成人| 91久久在线观看| 欧美激情在线有限公司| 亚洲精品色婷婷福利天堂| 亚洲深夜影院| 国产麻豆精品视频| 亚洲一区不卡| 欧美成人乱码一区二区三区| 亚洲二区视频| 亚洲视频 欧洲视频| 国产精品女人毛片| 欧美一区二区三区久久精品| 久久色在线观看| 亚洲国产精品综合| 欧美日韩视频专区在线播放 | 欧美日本视频在线| 亚洲先锋成人| 久久久久久网站| 亚洲日本中文字幕免费在线不卡| 欧美日韩福利在线观看| 亚洲一区二区三区视频| 老司机亚洲精品| 妖精成人www高清在线观看| 国产精品hd| 久久久久国产精品麻豆ai换脸| 亚洲二区在线观看| 亚洲欧美国产视频| 在线精品视频免费观看| 欧美日韩一区在线观看视频| 欧美在线视频导航| 亚洲精品视频免费在线观看| 久久都是精品| 日韩午夜三级在线| 国产真实乱子伦精品视频| 欧美国产91| 欧美在线视频网站| 99国产欧美久久久精品| 久久综合色影院| 一区二区三区日韩精品| 影音先锋成人资源站| 国产精品v片在线观看不卡| 久久婷婷久久| 亚洲欧美制服另类日韩| 亚洲美女视频在线免费观看| 久久一日本道色综合久久| 亚洲一区二区三区中文字幕| 在线日韩av| 国产精品影片在线观看| 欧美日本不卡高清| 免费av成人在线| 欧美中文字幕在线视频| 一区二区三区四区国产精品| 亚洲国产经典视频| 久久一本综合频道| 欧美一区二区三区四区在线观看| 亚洲美女中出| 亚洲欧洲精品一区二区三区不卡| 国产中文一区二区| 国产精品一区在线观看| 国产精品xvideos88| 欧美日韩精品中文字幕| 欧美精品黄色| 欧美激情第六页| 欧美sm极限捆绑bd| 免费观看一级特黄欧美大片| 午夜久久美女| 亚洲自拍高清| 亚洲一区图片| 亚洲欧美久久| 亚洲欧美中文另类| 亚洲欧美成人网| 亚洲欧美成人在线| 亚洲欧美另类在线| 亚洲欧美日韩精品综合在线观看 | 久久久www成人免费无遮挡大片| 亚洲一区欧美一区| 欧美午夜精品久久久久免费视 | 美日韩精品视频免费看| 久久综合九色欧美综合狠狠| 久久久久久一区二区三区| 久久久久国产一区二区| 久久综合九色综合欧美就去吻| 久久欧美中文字幕| 欧美 日韩 国产一区二区在线视频 | 在线日韩av| 亚洲精品一区二区三区在线观看| 亚洲国产毛片完整版 | 国产在线不卡| 亚洲高清影视| 一区二区欧美国产| 午夜精品久久久久影视| 久久久综合精品| 欧美国产日韩在线| 亚洲精品久久久久中文字幕欢迎你 | 亚洲日本激情| 宅男噜噜噜66一区二区66| 午夜亚洲精品| 美女久久网站| 亚洲人体偷拍| 午夜精品理论片| 久久综合九色综合欧美狠狠| 欧美精品97| 国产亚洲女人久久久久毛片| 亚洲二区视频| 亚洲香蕉在线观看| 裸体女人亚洲精品一区| 亚洲另类在线一区| 欧美在线视频不卡| 欧美日韩国产高清视频| 国产视频一区在线观看| 亚洲精品欧美激情| 午夜精品福利视频| 欧美国产日本韩| 亚洲一区二区三区精品在线观看| 久久久久久久网| 欧美午夜电影在线| 亚洲国产导航| 欧美一区二视频| 91久久在线播放| 欧美自拍丝袜亚洲| 欧美午夜精品久久久久久超碰| 国内精品**久久毛片app| 亚洲视频一区在线| 欧美国产日韩精品| 久久都是精品| 国产精品日本精品| 一卡二卡3卡四卡高清精品视频| 久久青草久久| 一区二区三区三区在线| 欧美精品久久久久久久免费观看 | 亚洲国产一区二区精品专区| 欧美一级淫片aaaaaaa视频| 欧美日韩午夜剧场| 亚洲精品自在在线观看|