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

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
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>
            男人天堂欧美日韩| 国产欧美欧洲在线观看| 亚洲手机视频| 一区二区三区高清视频在线观看| 亚洲黄一区二区三区| 亚洲欧洲一区二区在线播放| 亚洲国产高清在线| 亚洲美女色禁图| 亚洲在线观看免费| 欧美一区二粉嫩精品国产一线天| 欧美在线看片| 欧美大片专区| 国产精品尤物福利片在线观看| 国产亚洲欧美日韩一区二区| 亚洲国产日韩欧美在线99| 夜夜夜久久久| 欧美一区二区三区四区在线观看| 久久久久国产成人精品亚洲午夜| 欧美成人一区二区三区片免费| 亚洲国产老妈| 欧美一区二区三区免费在线看| 美女福利精品视频| 国产精品午夜电影| 亚洲理论在线观看| 久久夜色精品国产| 中文在线资源观看视频网站免费不卡| 久久久999精品| 国产精品盗摄久久久| 亚洲国产日韩欧美| 欧美一区午夜精品| 亚洲精品免费一二三区| 久久狠狠一本精品综合网| 欧美日韩在线视频首页| 亚洲电影中文字幕| 久久久久久有精品国产| 亚洲精品视频免费在线观看| 久久精品国产2020观看福利| 国产精品视频成人| 亚洲一级免费视频| 亚洲国产一区二区在线| 久久国产手机看片| 国产日韩欧美不卡在线| 亚洲一区二区三区在线视频| 欧美激情中文字幕一区二区| 久久成人18免费网站| 国产精品午夜电影| 午夜电影亚洲| 亚洲亚洲精品三区日韩精品在线视频| 欧美高清视频一区| 亚洲人久久久| 久久久综合网| 亚洲综合丁香| 9l国产精品久久久久麻豆| 欧美α欧美αv大片| 影音先锋亚洲电影| 久久人人看视频| 欧美在线视频全部完| 国产精品私房写真福利视频| 亚洲综合色激情五月| 亚洲天堂激情| 国产欧美一区二区三区国产幕精品 | 在线日韩中文字幕| 久久色在线观看| 久久精品国产69国产精品亚洲 | 欧美成人免费网站| 久久精选视频| 激情欧美一区二区| 欧美粗暴jizz性欧美20| 你懂的国产精品| 日韩视频在线一区二区三区| 亚洲美女av黄| 国产精品日韩欧美一区二区三区| 午夜精品亚洲| 久久九九99视频| 亚洲精品视频免费在线观看| 亚洲精品少妇30p| 国产精品久久久久久五月尺| 亚洲欧美日韩国产综合| 亚洲欧美日韩区| 在线成人激情视频| 亚洲国产精品久久人人爱蜜臀| 欧美精品久久天天躁 | 欧美韩国在线| 欧美久久一级| 久久成人免费网| 久久免费高清| 亚洲伊人一本大道中文字幕| 香蕉久久夜色精品国产使用方法| 黄色亚洲大片免费在线观看| 亚洲黄色成人网| 国产精品色网| 亚洲高清网站| 国产乱肥老妇国产一区二| 久久综合导航| 欧美性一区二区| 欧美成人综合在线| 国产欧美日本一区二区三区| 亚洲国产精品精华液网站| 国产日韩高清一区二区三区在线| 亚洲电影观看| 国产曰批免费观看久久久| 亚洲欧洲精品天堂一级| 国产一区二区在线观看免费| 国产精品一区免费视频| 91久久在线视频| 久久久久.com| 欧美日韩精品伦理作品在线免费观看| 久久成人av少妇免费| 欧美精品一区视频| 久久尤物视频| 国产美女扒开尿口久久久| 亚洲欧洲在线看| 亚洲高清久久| 欧美在线中文字幕| 亚洲欧美激情视频| 欧美美女bbbb| 亚洲国产成人精品久久| 激情一区二区三区| 亚洲欧美日韩综合| 亚洲欧美另类在线| 欧美视频二区| 最近看过的日韩成人| 亚洲国产女人aaa毛片在线| 欧美伊人久久久久久午夜久久久久| 一区二区免费看| 欧美精品一二三| 亚洲国产精品久久久久婷婷884 | 亚洲精品中文字幕女同| 久久久国产一区二区| 久久丁香综合五月国产三级网站| 欧美日韩国内自拍| 亚洲美女av在线播放| 亚洲精品社区| 欧美精品一区二区视频| 亚洲日本欧美在线| 在线视频欧美日韩| 欧美天堂亚洲电影院在线观看| 亚洲精品你懂的| 亚洲人午夜精品免费| 欧美大色视频| 夜夜嗨av一区二区三区中文字幕| 在线一区亚洲| 国产精品区二区三区日本| 亚洲午夜久久久| 久久精品九九| 亚洲第一福利视频| 欧美国产视频日韩| 99成人精品| 欧美一二三视频| 红桃av永久久久| 免费在线成人av| 亚洲精品永久免费精品| 亚洲视频一二区| 国产精品中文字幕在线观看| 亚洲综合三区| 免费成人av| 夜夜爽www精品| 国产人成一区二区三区影院| 欧美综合国产| 最新国产乱人伦偷精品免费网站| 一区二区激情| 国产一区91| 欧美理论视频| 欧美一区二区三区久久精品| 欧美成人午夜激情| 亚洲欧美日韩国产| 亚洲国产精品一区二区久| 欧美欧美全黄| 欧美一区二区三区免费观看视频 | 一级成人国产| 一区二区欧美在线观看| 欧美在线观看网址综合| 伊人久久男人天堂| 欧美日韩一区二| 久久黄色影院| 99在线热播精品免费| 久久久久国产一区二区三区四区| 亚洲日本中文| 国产一区二区三区在线观看视频| 欧美大片在线看免费观看| 午夜亚洲性色福利视频| 亚洲国产精品一区制服丝袜| 欧美一区二区| 在线视频亚洲一区| 在线观看亚洲| 国产日产欧产精品推荐色| 欧美激情精品久久久六区热门 | 黄色av一区| 国产精品久久毛片a| 蜜桃久久av| 欧美制服丝袜| 午夜精品久久久久久久久久久| 亚洲黄色小视频| 可以看av的网站久久看| 欧美一区免费| 亚洲欧美日韩综合一区| 在线一区二区日韩| 亚洲精品在线视频| 亚洲第一狼人社区| 狠狠色综合一区二区|