styles.c

来自「C语言编程中算法数据结构中的树行代码」· C语言 代码 · 共 976 行 · 第 1/5 页

C
976
字号
/******************************************************************************
*
*
* Notepad2
*
* Styles.c
*   Scintilla Style Management
*
* See Readme.txt for more information about this source code.
* Please send me your comments to this work.
*
* See License.txt for details about distribution and modification.
*
*                                              (c) Florian Balmer 1996-2008
*                                                  florian.balmer@gmail.com
*                                               http://www.flos-freeware.ch
*
*
******************************************************************************/
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#include <shlobj.h>
#include <shlwapi.h>
#include <stdio.h>
#include "dialogs.h"
#include "helpers.h"
#include "notepad2.h"
#include "scintilla.h"
#include "scilexer.h"
#include "styles.h"
#include "resource.h"


KEYWORDLIST KeyWords_NULL = {
"", "", "", "", "", "", "", "", "" };


EDITLEXER lexDefault = { SCLEX_NULL, "Default Text", "txt;wtx;log;asc;doc;diz;nfo", "", &KeyWords_NULL, {
                /*  0 */ { STYLE_DEFAULT, "Default Style", "font:Lucida Console;size:10", "" },
                /*  1 */ { STYLE_LINENUMBER, "Margins and Line Numbers", "size:-2;fore:#FF0000", "" },
                /*  2 */ { STYLE_BRACELIGHT, "Matching Braces", "size:+1;fore:#FF0000;bold", "" },
                /*  3 */ { STYLE_BRACEBAD, "Matching Braces Error", "size:+1;fore:#000080;bold", "" },
                /*  4 */ { STYLE_CONTROLCHAR, "Control Characters (Unused)", "", "" },
                /*  5 */ { STYLE_INDENTGUIDE, "Indentation Guide (Color only)", "", "" },
                /*  6 */ { SCI_SETSELFORE+SCI_SETSELBACK, "Selected Text (Colors only)", "back:#0A246A;alpha:95;eolfilled", "" },
                /*  7 */ { SCI_SETWHITESPACEFORE+SCI_SETWHITESPACEBACK, "Whitespace (Colors only)", "fore:#FF0000", "" },
                /*  8 */ { SCI_SETCARETLINEBACK, "Current Line Background (Color only)", "back:#FFFF00;alpha:50", "" },
                /*  9 */ { SCI_SETCARETFORE, "Caret Foreground (Color only)", "", "" },
                /* 10 */ { SCI_SETCARETWIDTH, "Caret Width (Size from 1 to 3)", "", "" },
                /* 11 */ { SCI_SETEDGECOLOUR, "Long Line Marker (Colors only)", "", "" },

                /* 12 */ { STYLE_DEFAULT, "2nd Default Style", "font:Courier New;size:10", "" },
                /* 13 */ { STYLE_LINENUMBER, "2nd Margins and Line Numbers", "font:Tahoma;size:-2;fore:#FF0000", "" },
                /* 14 */ { STYLE_BRACELIGHT, "2nd Matching Braces", "fore:#FF0000;bold", "" },
                /* 15 */ { STYLE_BRACEBAD, "2nd Matching Braces Error", "fore:#000080;bold", "" },
                /* 16 */ { STYLE_CONTROLCHAR, "2nd Control Characters (Unused)", "", "" },
                /* 17 */ { STYLE_INDENTGUIDE, "2nd Indentation Guide (Color only)", "", "" },
                /* 18 */ { SCI_SETSELFORE+SCI_SETSELBACK, "2nd Selected Text (Colors only)", "eolfilled", "" },
                /* 19 */ { SCI_SETWHITESPACEFORE+SCI_SETWHITESPACEBACK, "2nd Whitespace (Colors only)", "fore:#FF0000", "" },
                /* 20 */ { SCI_SETCARETLINEBACK, "2nd Current Line Background (Color only)", "", "" },
                /* 21 */ { SCI_SETCARETFORE, "2nd Caret Foreground (Color only)", "", "" },
                /* 22 */ { SCI_SETCARETWIDTH, "2nd Caret Width (Size from 1 to 3)", "", "" },
                /* 23 */ { SCI_SETEDGECOLOUR, "2nd Long Line Marker (Colors only)", "", "" },
                         { -1, "", "", "" } } };


KEYWORDLIST KeyWords_HTML = {
"a abbr acronym address applet area b base basefont bdo big blockquote body bordercolor br button caption "
"center cite code col colgroup dd del dfn dir div dl dt em fieldset font form frame frameset h1 h2 "
"h3 h4 h5 h6 head hr html i iframe img input ins isindex kbd label legend li link map menu meta "
"noframes noscript object ol optgroup option p param pre q s samp script select small span strike "
"strong style sub sup table tbody td textarea tfoot th thead title tr tt u ul var xml xmlns abbr "
"accept-charset accept accesskey action align alink alt archive axis background bgcolor border "
"cellpadding cellspacing char charoff charset checked cite class classid clear codebase codetype "
"color cols colspan compact content coords data datafld dataformatas datapagesize datasrc "
"datetime declare defer dir disabled enctype event face for frame frameborder headers height href "
"hreflang hspace http-equiv id ismap label lang language leftmargin link longdesc marginwidth "
"marginheight maxlength media method multiple name nohref noresize noshade nowrap object "
"onblur onchange onclick ondblclick onfocus onkeydown onkeypress onkeyup onload onmousedown "
"onmousemove onmouseover onmouseout onmouseup onreset onselect onsubmit onunload profile "
"prompt readonly rel rev rows rowspan rules scheme scope scrolling selected shape size span src standby "
"start style summary tabindex target text title topmargin type usemap valign value valuetype "
"version vlink vspace width text password checkbox radio submit reset file hidden image public "
"!doctype",
"abstract boolean break byte case catch char class const continue debugger default delete do "
"double else enum export extends final finally float for function goto if implements import in "
"instanceof int interface long native new package private protected public return short static "
"super switch synchronized this throw throws transient try typeof var void volatile while with",
"and begin case call continue do each else elseif end erase error event exit false for function get "
"gosub goto if implement in load loop lset me mid new next not nothing on or property raiseevent "
"rem resume return rset select set stop sub then to true unload until wend while with withevents "
"attribute alias as boolean byref byte byval const compare currency date declare dim double enum "
"explicit friend global integer let lib long module object option optional preserve private property "
"public redim single static string type variant",
"and assert break class continue def del elif else except exec finally for from global if import in is "
"lambda None not or pass print raise return try while yield",
"__class__ __file__ __function__ __line__ __method__ __sleep __wakeup "
"abstract and argc argv array as break case catch cfunction class clone "
"const continue declare default define die do e_all e_error e_parse "
"e_warning echo else elseif empty enddeclare endfor endforeach endif "
"endswitch endwhile eval exception exit extends false final for foreach "
"function global http_cookie_vars http_env_vars http_get_vars "
"http_post_files http_post_vars http_server_vars if implements include "
"include_once interface isset list new not null old_function or parent "
"php_os php_self php_user_filter php_version print private protected "
"public require require_once return static stdclass switch this throw "
"true try unset use var virtual while xor",
"ELEMENT DOCTYPE ATTLIST ENTITY NOTATION",
"", "", "" };


EDITLEXER lexHTML = { SCLEX_HTML, "Web Source Code", "html;htm;asp;aspx;shtml;htd;xhtml;php;php3;phtml;htt;cfm;tpl;dtd;hta;htc", "", &KeyWords_HTML, {
                      { STYLE_DEFAULT, "Default", "", "" },
                      //{ SCE_H_DEFAULT, "Default", "", "" },
                      { SCE_H_TAG, "HTML Tag", "fore:#000080", "" },
                      { SCE_H_TAGUNKNOWN, "HTML Unknown Tag", "fore:#000080", "" },
                      { SCE_H_ATTRIBUTE, "HTML Attribute", "fore:#FF0000", "" },
                      { SCE_H_ATTRIBUTEUNKNOWN, "HTML Unknown Attribute", "fore:#FF0000", "" },
                      { SCE_H_VALUE, "HTML Value", "fore:#3A6EA5", "" },
                      { SCE_H_DOUBLESTRING, "HTML String double quoted", "fore:#3A6EA5", "" },
                      { SCE_H_SINGLESTRING, "HTML String single quoted", "fore:#3A6EA5", "" },
                      { SCE_H_OTHER, "HTML Other Inside Tag", "fore:#3A6EA5", "" },
                      { SCE_H_COMMENT, "HTML Comment", "fore:#808080", "" },
                      { SCE_H_ENTITY, "HTML Entity", "fore:#800080", "" },
                      { SCE_H_TAGEND, "XML Closing Tag", "fore:#000080", "" },
                      { SCE_H_XMLSTART, "XML Identifier Start", "bold;fore:#FF0000", "" },
                      { SCE_H_XMLEND, "XML Identifier End", "bold;fore:#FF0000", "" },
                      { SCE_H_ASP, "ASP Start Tag", "", "fore:#000080;bold" },
                      { SCE_H_ASPAT, "ASP Start Tag @", "fore:#000080;bold", "" },
                      //{ SCE_H_SCRIPT, "Script", "", "" },
                      { SCE_H_CDATA, "CDATA", "", "" },
                      //{ SCE_H_XCCOMMENT, "XC Comment", "", "" },
                      { SCE_H_QUESTION, "PHP Start Tag", "fore:#000080;bold", "" },
                      { SCE_HPHP_DEFAULT, "PHP Default", "", "" },
                      { SCE_HPHP_HSTRING, "PHP String", "fore:#008000", "" },
                      { SCE_HPHP_SIMPLESTRING, "PHP Simple String", "fore:#008000", "" },
                      { SCE_HPHP_WORD, "PHP Keyword", "fore:#800080", "" },
                      { SCE_HPHP_NUMBER, "PHP Number", "fore:#FF0000", "" },
                      { SCE_HPHP_VARIABLE, "PHP Variable", "italic;fore:#000080", "" },
                      { SCE_HPHP_HSTRING_VARIABLE, "PHP String Variable", "italic;fore:#000080", "" },
                      { SCE_HPHP_COMPLEX_VARIABLE, "PHP Complex Variable", "italic;fore:#000080", "" },
                      { SCE_HPHP_COMMENT, "PHP Comment", "fore:#FF8000", "" },
                      { SCE_HPHP_COMMENTLINE, "PHP Comment Line", "fore:#FF8000", "" },
                      { SCE_HPHP_OPERATOR, "PHP Operator", "", "" },
                      //{ SCE_HJ_START, "JS Start", "", "" },
                      { SCE_HJ_DEFAULT, "JS Default", "", "" },
                      { SCE_HJ_COMMENT, "JS Comment", "fore:#008000", "" },
                      { SCE_HJ_COMMENTLINE, "JS Comment Line", "fore:#008000", "" },
                      { SCE_HJ_COMMENTDOC, "JS Comment Doc", "fore:#008000", "" },
                      { SCE_HJ_NUMBER, "JS Number", "fore:#FF0000", "" },
                      { SCE_HJ_WORD, "JS Identifier", "", "" },
                      { SCE_HJ_KEYWORD, "JS Keyword", "fore:#0A246A;bold", "" },
                      { SCE_HJ_DOUBLESTRING, "JS Double String", "fore:#008000", "" },
                      { SCE_HJ_SINGLESTRING, "JS Single String", "fore:#008000", "" },
                      { SCE_HJ_STRINGEOL, "JS String EOL", "fore:#008000", "" },
                      { SCE_HJ_SYMBOLS, "JS Symbols", "", "" },
                      { SCE_HJ_REGEX, "JS Regex", "", "" },
                      //{ SCE_HJA_START, "ASP JS Start", "", "" },
                      { SCE_HJA_DEFAULT, "ASP JS Default", "", "" },
                      { SCE_HJA_COMMENT, "ASP JS Comment", "fore:#008000", "" },
                      { SCE_HJA_COMMENTLINE, "ASP JS Commentline", "fore:#008000", "" },
                      { SCE_HJA_COMMENTDOC, "ASP JS Comment Doc", "fore:#008000", "" },
                      { SCE_HJA_NUMBER, "ASP JS Number", "fore:#FF0000", "" },
                      { SCE_HJA_WORD, "ASP JS Identifier", "", "" },
                      { SCE_HJA_KEYWORD, "ASP JS Keyword", "fore:#0A246A;bold", "" },
                      { SCE_HJA_DOUBLESTRING, "ASP JS Double String", "fore:#008000", "" },
                      { SCE_HJA_SINGLESTRING, "ASP JS Single String", "fore:#008000", "" },
                      { SCE_HJA_STRINGEOL, "ASP JS String EOL", "fore:#008000", "" },
                      { SCE_HJA_SYMBOLS, "ASP JS Symbols", "", "" },
                      { SCE_HJA_REGEX, "ASP JS Regex", "", "" },
                      //{ SCE_HB_START, "VBS Start", "", "" },
                      { SCE_HB_DEFAULT, "VBS Default", "", "" },
                      { SCE_HB_COMMENTLINE, "VBS Comment Line", "fore:#008000", "" },
                      { SCE_HB_NUMBER, "VBS Number", "fore:#FF0000", "" },
                      { SCE_HB_WORD, "VBS Keyword", "fore:#800080;bold", "" },
                      { SCE_HB_STRING, "VBS String", "fore:#008000", "" },
                      { SCE_HB_STRINGEOL, "VBS String EOL", "fore:#008000", "" },
                      { SCE_HB_IDENTIFIER, "VBS Identifier", "", "" },
                      //{ SCE_HBA_START, "ASP VBS Start", "", "" },
                      { SCE_HBA_DEFAULT, "ASP VBS Default", "", "" },
                      { SCE_HBA_COMMENTLINE, "ASP VBS Comment Line", "fore:#008000", "" },
                      { SCE_HBA_NUMBER, "ASP VBS Number", "", "" },
                      { SCE_HBA_WORD, "ASP VBS Keyword", "fore:#800080;bold", "" },
                      { SCE_HBA_STRING, "ASP VBS String", "fore:#008000", "" },
                      { SCE_HBA_STRINGEOL, "ASP VBS String EOL", "fore:#008000", "" },
                      { SCE_HBA_IDENTIFIER, "ASP VBS Identifier", "", "" },
                      //{ SCE_HP_START, "Phyton Start", "", "" },
                      //{ SCE_HP_DEFAULT, "Phyton Default", "", "" },
                      //{ SCE_HP_COMMENTLINE, "Phyton Comment Line", "", "" },
                      //{ SCE_HP_NUMBER, "Phyton Number", "", "" },
                      //{ SCE_HP_STRING, "Phyton String", "", "" },
                      //{ SCE_HP_CHARACTER, "Phyton Character", "", "" },
                      //{ SCE_HP_WORD, "Phyton Keyword", "", "" },
                      //{ SCE_HP_TRIPLE, "Phyton Triple", "", "" },
                      //{ SCE_HP_TRIPLEDOUBLE, "Phyton Triple Double", "", "" },

⌨️ 快捷键说明

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