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

牽著老婆滿街逛

嚴以律己,寬以待人. 三思而后行.
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>
            香蕉久久夜色精品国产使用方法| 国产偷国产偷亚洲高清97cao| 亚洲精品一区二区网址| 久热国产精品视频| 媚黑女一区二区| 欧美成人亚洲成人| 亚洲第一色中文字幕| 亚洲国产日韩一区二区| 夜色激情一区二区| 午夜精品一区二区三区四区| 亚洲男人的天堂在线aⅴ视频| 欧美一区二区三区在线观看视频| 欧美一区免费视频| 免费高清在线一区| 欧美日韩爆操| 欧美激情精品久久久六区热门| 亚洲一区二区四区| 欧美在线观看你懂的| 久久人人爽人人爽| 欧美日韩在线一区| 极品日韩久久| 亚洲天堂成人在线观看| 久久激情视频免费观看| 欧美激情一区三区| 亚洲欧美日韩直播| 欧美精品国产| 黄色一区三区| 午夜一区二区三区不卡视频| 欧美成人午夜影院| 欧美与黑人午夜性猛交久久久| 欧美大片在线看免费观看| 国产女主播一区二区三区| 日韩亚洲在线观看| 久久亚洲精品一区二区| 亚洲深爱激情| 欧美久久久久久| 亚洲国产导航| 久久在线视频在线| 小处雏高清一区二区三区| 欧美日韩国产麻豆| 亚洲国产精品123| 久久综合99re88久久爱| 午夜国产精品视频免费体验区| 欧美日韩综合在线免费观看| 亚洲精品久久久久久久久| 老司机免费视频一区二区| 亚洲一区二区三区中文字幕| 欧美精品 国产精品| 亚洲黄色小视频| 欧美大片va欧美在线播放| 久久久水蜜桃| 在线观看免费视频综合| 久久夜色精品国产噜噜av| 欧美一区二区三区免费看 | 99视频在线精品国自产拍免费观看| 夜夜爽av福利精品导航 | 欧美一级视频| 在线综合亚洲| 国产精品久久一级| 午夜精品一区二区在线观看| 一区二区免费在线播放| 国产精品久久97| 欧美一区二区在线| 欧美一级二区| 久久久99精品免费观看不卡| 国产乱码精品| 午夜精品福利一区二区蜜股av| 99精品99| 国产欧美亚洲一区| 久久嫩草精品久久久久| 久久国产黑丝| 亚洲区一区二| 亚洲精品国产精品久久清纯直播 | 欧美另类videos死尸| 亚洲国产精品专区久久| 免费国产一区二区| 免费亚洲视频| 一区二区高清在线| 亚洲在线视频免费观看| 久久婷婷麻豆| 久久五月婷婷丁香社区| 久久久久久免费| 欧美不卡视频| 亚洲美女色禁图| 欧美大片在线看免费观看| 日韩视频在线观看一区二区| 久久国产欧美| 亚洲国产一区二区精品专区| 亚洲久色影视| 在线日韩av片| 久久精品国亚洲| 亚洲国产一区二区a毛片| 国产拍揄自揄精品视频麻豆| 久久久久久亚洲精品不卡4k岛国| 久久天堂精品| 欧美视频日韩| 亚洲国产精品成人一区二区| 国产精品久久久久9999| 亚洲免费成人av电影| 久热国产精品视频| 久久影院午夜论| 亚洲国产精品久久久久秋霞影院| 麻豆国产精品777777在线| 久久国产精品毛片| 亚洲人被黑人高潮完整版| 亚洲精选视频在线| 国内精品久久久久国产盗摄免费观看完整版 | 欧美一级成年大片在线观看| 午夜在线视频观看日韩17c| 最新亚洲一区| 性色av一区二区三区在线观看| 亚洲精品视频在线看| 亚洲欧美成人一区二区三区| 亚洲日本无吗高清不卡| 久久精品中文| 欧美中文字幕久久| 欧美日本乱大交xxxxx| 久久综合色婷婷| 国产精品亚洲片夜色在线| 亚洲美女诱惑| 亚洲最新视频在线播放| 麻豆亚洲精品| 你懂的一区二区| 激情五月综合色婷婷一区二区| 亚洲免费伊人电影在线观看av| 99视频有精品| 欧美激情在线免费观看| 欧美激情网友自拍| 亚洲高清色综合| 久久久久久穴| 久久综合99re88久久爱| 国产亚洲欧美在线| 午夜免费在线观看精品视频| 亚洲网站在线看| 欧美性做爰毛片| 一区二区三区回区在观看免费视频| 亚洲二区在线| 老司机午夜免费精品视频| 欧美 日韩 国产一区二区在线视频| 经典三级久久| 奶水喷射视频一区| 欧美激情第六页| 亚洲精品国产拍免费91在线| 欧美成人资源网| 亚洲毛片在线观看| 亚洲男人天堂2024| 国产欧美一区二区三区在线老狼| 亚洲欧美日韩国产一区| 久久米奇亚洲| 亚洲国产成人在线视频| 欧美激情 亚洲a∨综合| 亚洲六月丁香色婷婷综合久久| 亚洲婷婷综合色高清在线 | 欧美视频在线观看免费网址| 亚洲免费观看在线观看| 亚洲欧美在线播放| 国产日韩精品综合网站| 亚洲视频欧洲视频| 欧美国产精品专区| 亚洲精品黄网在线观看| 一本久道久久综合中文字幕| 欧美三级电影精品| 午夜在线视频一区二区区别| 欧美成人精品激情在线观看| 99精品国产99久久久久久福利| 欧美精品在线一区二区三区| 一区二区三区精品久久久| 欧美一二三视频| 亚洲激情成人在线| 国产精品国产三级国产 | 欧美一区三区三区高中清蜜桃| 美女图片一区二区| 亚洲图片欧美日产| 国外成人在线| 欧美特黄一级大片| 久久先锋影音| 亚洲深夜av| 亚洲电影免费观看高清| 亚洲欧美在线网| 亚洲欧洲一区二区三区在线观看 | 最新中文字幕一区二区三区| 国产精品免费福利| 免费不卡欧美自拍视频| 中文一区二区| 亚洲国产日韩欧美一区二区三区| 欧美亚洲日本国产| 亚洲视频福利| 亚洲国产日韩欧美一区二区三区| 国产精品美女久久福利网站| 欧美阿v一级看视频| 亚洲欧美日韩在线高清直播| 91久久精品国产91久久| 久久综合九色综合网站 | 亚洲人成在线免费观看| 狼狼综合久久久久综合网| 午夜久久资源| 亚洲无人区一区| 一区二区三区久久| 亚洲精品系列| 亚洲黄色天堂|