1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181
|
// This module implements the QsciLexerHTML class.
//
// Copyright (c) 2015 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of QScintilla.
//
// This file may be used under the terms of the GNU General Public License
// version 3.0 as published by the Free Software Foundation and appearing in
// the file LICENSE included in the packaging of this file. Please review the
// following information to ensure the GNU General Public License version 3.0
// requirements will be met: http://www.gnu.org/copyleft/gpl.html.
//
// If you do not wish to use this file under the terms of the GPL version 3.0
// then you may purchase a commercial license. For more information contact
// info@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#include "Qsci/qscilexerhtml.h"
#include <qcolor.h>
#include <qfont.h>
#include <qsettings.h>
#include "Qsci/qscilexerjavascript.h"
#include "Qsci/qscilexerpython.h"
// The ctor.
QsciLexerHTML::QsciLexerHTML(QObject *parent)
: QsciLexer(parent),
fold_compact(true), fold_preproc(true), case_sens_tags(false),
fold_script_comments(false), fold_script_heredocs(false),
django_templates(false), mako_templates(false)
{
}
// The dtor.
QsciLexerHTML::~QsciLexerHTML()
{
}
// Returns the language name.
const char *QsciLexerHTML::language() const
{
return "HTML";
}
// Returns the lexer name.
const char *QsciLexerHTML::lexer() const
{
return "hypertext";
}
// Return the auto-completion fillup characters.
const char *QsciLexerHTML::autoCompletionFillups() const
{
return "/>";
}
// Return the string of characters that comprise a word.
const char *QsciLexerHTML::wordCharacters() const
{
return "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-";
}
// Returns the foreground colour of the text for a style.
QColor QsciLexerHTML::defaultColor(int style) const
{
switch (style)
{
case Default:
case JavaScriptDefault:
case JavaScriptWord:
case JavaScriptSymbol:
case ASPJavaScriptDefault:
case ASPJavaScriptWord:
case ASPJavaScriptSymbol:
case VBScriptDefault:
case ASPVBScriptDefault:
case PHPOperator:
return QColor(0x00,0x00,0x00);
case Tag:
case XMLTagEnd:
case Script:
case SGMLDefault:
case SGMLCommand:
case VBScriptKeyword:
case VBScriptIdentifier:
case VBScriptUnclosedString:
case ASPVBScriptKeyword:
case ASPVBScriptIdentifier:
case ASPVBScriptUnclosedString:
return QColor(0x00,0x00,0x80);
case UnknownTag:
case UnknownAttribute:
return QColor(0xff,0x00,0x00);
case Attribute:
case VBScriptNumber:
case ASPVBScriptNumber:
return QColor(0x00,0x80,0x80);
case HTMLNumber:
case JavaScriptNumber:
case ASPJavaScriptNumber:
case PythonNumber:
case PythonFunctionMethodName:
case ASPPythonNumber:
case ASPPythonFunctionMethodName:
return QColor(0x00,0x7f,0x7f);
case HTMLDoubleQuotedString:
case HTMLSingleQuotedString:
case JavaScriptDoubleQuotedString:
case JavaScriptSingleQuotedString:
case ASPJavaScriptDoubleQuotedString:
case ASPJavaScriptSingleQuotedString:
case PythonDoubleQuotedString:
case PythonSingleQuotedString:
case ASPPythonDoubleQuotedString:
case ASPPythonSingleQuotedString:
case PHPKeyword:
return QColor(0x7f,0x00,0x7f);
case OtherInTag:
case Entity:
case VBScriptString:
case ASPVBScriptString:
return QColor(0x80,0x00,0x80);
case HTMLComment:
case SGMLComment:
return QColor(0x80,0x80,0x00);
case XMLStart:
case XMLEnd:
case PHPStart:
case PythonClassName:
case ASPPythonClassName:
return QColor(0x00,0x00,0xff);
case HTMLValue:
return QColor(0xff,0x00,0xff);
case SGMLParameter:
return QColor(0x00,0x66,0x00);
case SGMLDoubleQuotedString:
case SGMLError:
return QColor(0x80,0x00,0x00);
case SGMLSingleQuotedString:
return QColor(0x99,0x33,0x00);
case SGMLSpecial:
return QColor(0x33,0x66,0xff);
case SGMLEntity:
return QColor(0x33,0x33,0x33);
case SGMLBlockDefault:
return QColor(0x00,0x00,0x66);
case JavaScriptStart:
case ASPJavaScriptStart:
return QColor(0x7f,0x7f,0x00);
case JavaScriptComment:
case JavaScriptCommentLine:
case ASPJavaScriptComment:
case ASPJavaScriptCommentLine:
case PythonComment:
case ASPPythonComment:
case PHPDoubleQuotedString:
return QColor(0x00,0x7f,0x00);
case JavaScriptCommentDoc:
return QColor(0x3f,0x70,0x3f);
case JavaScriptKeyword:
case ASPJavaScriptKeyword:
case PythonKeyword:
case ASPPythonKeyword:
case PHPVariable:
case PHPDoubleQuotedVariable:
return QColor(0x00,0x00,0x7f);
case ASPJavaScriptCommentDoc:
return QColor(0x7f,0x7f,0x7f);
case VBScriptComment:
case ASPVBScriptComment:
return QColor(0x00,0x80,0x00);
case PythonStart:
case PythonDefault:
case ASPPythonStart:
case ASPPythonDefault:
return QColor(0x80,0x80,0x80);
case PythonTripleSingleQuotedString:
case PythonTripleDoubleQuotedString:
case ASPPythonTripleSingleQuotedString:
case ASPPythonTripleDoubleQuotedString:
return QColor(0x7f,0x00,0x00);
case PHPDefault:
return QColor(0x00,0x00,0x33);
case PHPSingleQuotedString:
return QColor(0x00,0x9f,0x00);
case PHPNumber:
return QColor(0xcc,0x99,0x00);
case PHPComment:
return QColor(0x99,0x99,0x99);
case PHPCommentLine:
return QColor(0x66,0x66,0x66);
}
return QsciLexer::defaultColor(style);
}
// Returns the end-of-line fill for a style.
bool QsciLexerHTML::defaultEolFill(int style) const
{
switch (style)
{
case JavaScriptDefault:
case JavaScriptComment:
case JavaScriptCommentDoc:
case JavaScriptUnclosedString:
case ASPJavaScriptDefault:
case ASPJavaScriptComment:
case ASPJavaScriptCommentDoc:
case ASPJavaScriptUnclosedString:
case VBScriptDefault:
case VBScriptComment:
case VBScriptNumber:
case VBScriptKeyword:
case VBScriptString:
case VBScriptIdentifier:
case VBScriptUnclosedString:
case ASPVBScriptDefault:
case ASPVBScriptComment:
case ASPVBScriptNumber:
case ASPVBScriptKeyword:
case ASPVBScriptString:
case ASPVBScriptIdentifier:
case ASPVBScriptUnclosedString:
case PythonDefault:
case PythonComment:
case PythonNumber:
case PythonDoubleQuotedString:
case PythonSingleQuotedString:
case PythonKeyword:
case PythonTripleSingleQuotedString:
case PythonTripleDoubleQuotedString:
case PythonClassName:
case PythonFunctionMethodName:
case PythonOperator:
case PythonIdentifier:
case ASPPythonDefault:
case ASPPythonComment:
case ASPPythonNumber:
case ASPPythonDoubleQuotedString:
case ASPPythonSingleQuotedString:
case ASPPythonKeyword:
case ASPPythonTripleSingleQuotedString:
case ASPPythonTripleDoubleQuotedString:
case ASPPythonClassName:
case ASPPythonFunctionMethodName:
case ASPPythonOperator:
case ASPPythonIdentifier:
case PHPDefault:
return true;
}
return QsciLexer::defaultEolFill(style);
}
// Returns the font of the text for a style.
QFont QsciLexerHTML::defaultFont(int style) const
{
QFont f;
switch (style)
{
case Default:
case Entity:
#if defined(Q_OS_WIN)
f = QFont("Times New Roman",11);
#elif defined(Q_OS_MAC)
f = QFont("Times New Roman", 12);
#else
f = QFont("Bitstream Charter",10);
#endif
break;
case HTMLComment:
#if defined(Q_OS_WIN)
f = QFont("Verdana",9);
#elif defined(Q_OS_MAC)
f = QFont("Verdana", 12);
#else
f = QFont("Bitstream Vera Sans",8);
#endif
break;
case SGMLCommand:
case PythonKeyword:
case PythonClassName:
case PythonFunctionMethodName:
case PythonOperator:
case ASPPythonKeyword:
case ASPPythonClassName:
case ASPPythonFunctionMethodName:
case ASPPythonOperator:
f = QsciLexer::defaultFont(style);
f.setBold(true);
break;
case JavaScriptDefault:
case JavaScriptCommentDoc:
case JavaScriptKeyword:
case JavaScriptSymbol:
case ASPJavaScriptDefault:
case ASPJavaScriptCommentDoc:
case ASPJavaScriptKeyword:
case ASPJavaScriptSymbol:
#if defined(Q_OS_WIN)
f = QFont("Comic Sans MS",9);
#elif defined(Q_OS_MAC)
f = QFont("Comic Sans MS", 12);
#else
f = QFont("Bitstream Vera Serif",9);
#endif
f.setBold(true);
break;
case JavaScriptComment:
case JavaScriptCommentLine:
case JavaScriptNumber:
case JavaScriptWord:
case JavaScriptDoubleQuotedString:
case JavaScriptSingleQuotedString:
case ASPJavaScriptComment:
case ASPJavaScriptCommentLine:
case ASPJavaScriptNumber:
case ASPJavaScriptWord:
case ASPJavaScriptDoubleQuotedString:
case ASPJavaScriptSingleQuotedString:
case VBScriptComment:
case ASPVBScriptComment:
case PythonComment:
case ASPPythonComment:
case PHPComment:
#if defined(Q_OS_WIN)
f = QFont("Comic Sans MS",9);
#elif defined(Q_OS_MAC)
f = QFont("Comic Sans MS", 12);
#else
f = QFont("Bitstream Vera Serif",9);
#endif
break;
case VBScriptDefault:
case VBScriptNumber:
case VBScriptString:
case VBScriptIdentifier:
case VBScriptUnclosedString:
case ASPVBScriptDefault:
case ASPVBScriptNumber:
case ASPVBScriptString:
case ASPVBScriptIdentifier:
case ASPVBScriptUnclosedString:
#if defined(Q_OS_WIN)
f = QFont("Lucida Sans Unicode",9);
#elif defined(Q_OS_MAC)
f = QFont("Lucida Grande", 12);
#else
f = QFont("Bitstream Vera Serif",9);
#endif
break;
case VBScriptKeyword:
case ASPVBScriptKeyword:
#if defined(Q_OS_WIN)
f = QFont("Lucida Sans Unicode",9);
#elif defined(Q_OS_MAC)
f = QFont("Lucida Grande", 12);
#else
f = QFont("Bitstream Vera Serif",9);
#endif
f.setBold(true);
break;
case PythonDoubleQuotedString:
case PythonSingleQuotedString:
case ASPPythonDoubleQuotedString:
case ASPPythonSingleQuotedString:
#if defined(Q_OS_WIN)
f = QFont("Courier New",10);
#elif defined(Q_OS_MAC)
f = QFont("Courier New", 12);
#else
f = QFont("Bitstream Vera Sans Mono",9);
#endif
break;
case PHPKeyword:
case PHPVariable:
case PHPDoubleQuotedVariable:
f = QsciLexer::defaultFont(style);
f.setItalic(true);
break;
case PHPCommentLine:
#if defined(Q_OS_WIN)
f = QFont("Comic Sans MS",9);
#elif defined(Q_OS_MAC)
f = QFont("Comic Sans MS", 12);
#else
f = QFont("Bitstream Vera Serif",9);
#endif
f.setItalic(true);
break;
default:
f = QsciLexer::defaultFont(style);
}
return f;
}
// Returns the set of keywords.
const char *QsciLexerHTML::keywords(int set) const
{
if (set == 1)
return
"a abbr acronym address applet area "
"b base basefont bdo big blockquote body 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 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";
if (set == 2)
return QsciLexerJavaScript::keywordClass;
if (set == 3)
return
// Move these to QsciLexerVisualBasic when we
// get round to implementing it.
"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";
if (set == 4)
return QsciLexerPython::keywordClass;
if (set == 5)
return
"and argv as argc break case cfunction class continue "
"declare default do die "
"echo else elseif empty enddeclare endfor endforeach "
"endif endswitch endwhile e_all e_parse e_error "
"e_warning eval exit extends "
"false for foreach function global "
"http_cookie_vars http_get_vars http_post_vars "
"http_post_files http_env_vars http_server_vars "
"if include include_once list new not null "
"old_function or "
"parent php_os php_self php_version print "
"require require_once return "
"static switch stdclass this true var xor virtual "
"while "
"__file__ __line__ __sleep __wakeup";
if (set == 6)
return "ELEMENT DOCTYPE ATTLIST ENTITY NOTATION";
return 0;
}
// Returns the user name of a style.
QString QsciLexerHTML::description(int style) const
{
switch (style)
{
case Default:
return tr("HTML default");
case Tag:
return tr("Tag");
case UnknownTag:
return tr("Unknown tag");
case Attribute:
return tr("Attribute");
case UnknownAttribute:
return tr("Unknown attribute");
case HTMLNumber:
return tr("HTML number");
case HTMLDoubleQuotedString:
return tr("HTML double-quoted string");
case HTMLSingleQuotedString:
return tr("HTML single-quoted string");
case OtherInTag:
return tr("Other text in a tag");
case HTMLComment:
return tr("HTML comment");
case Entity:
return tr("Entity");
case XMLTagEnd:
return tr("End of a tag");
case XMLStart:
return tr("Start of an XML fragment");
case XMLEnd:
return tr("End of an XML fragment");
case Script:
return tr("Script tag");
case ASPAtStart:
return tr("Start of an ASP fragment with @");
case ASPStart:
return tr("Start of an ASP fragment");
case CDATA:
return tr("CDATA");
case PHPStart:
return tr("Start of a PHP fragment");
case HTMLValue:
return tr("Unquoted HTML value");
case ASPXCComment:
return tr("ASP X-Code comment");
case SGMLDefault:
return tr("SGML default");
case SGMLCommand:
return tr("SGML command");
case SGMLParameter:
return tr("First parameter of an SGML command");
case SGMLDoubleQuotedString:
return tr("SGML double-quoted string");
case SGMLSingleQuotedString:
return tr("SGML single-quoted string");
case SGMLError:
return tr("SGML error");
case SGMLSpecial:
return tr("SGML special entity");
case SGMLComment:
return tr("SGML comment");
case SGMLParameterComment:
return tr("First parameter comment of an SGML command");
case SGMLBlockDefault:
return tr("SGML block default");
case JavaScriptStart:
return tr("Start of a JavaScript fragment");
case JavaScriptDefault:
return tr("JavaScript default");
case JavaScriptComment:
return tr("JavaScript comment");
case JavaScriptCommentLine:
return tr("JavaScript line comment");
case JavaScriptCommentDoc:
return tr("JavaDoc style JavaScript comment");
case JavaScriptNumber:
return tr("JavaScript number");
case JavaScriptWord:
return tr("JavaScript word");
case JavaScriptKeyword:
return tr("JavaScript keyword");
case JavaScriptDoubleQuotedString:
return tr("JavaScript double-quoted string");
case JavaScriptSingleQuotedString:
return tr("JavaScript single-quoted string");
case JavaScriptSymbol:
return tr("JavaScript symbol");
case JavaScriptUnclosedString:
return tr("JavaScript unclosed string");
case JavaScriptRegex:
return tr("JavaScript regular expression");
case ASPJavaScriptStart:
return tr("Start of an ASP JavaScript fragment");
case ASPJavaScriptDefault:
return tr("ASP JavaScript default");
case ASPJavaScriptComment:
return tr("ASP JavaScript comment");
case ASPJavaScriptCommentLine:
return tr("ASP JavaScript line comment");
case ASPJavaScriptCommentDoc:
return tr("JavaDoc style ASP JavaScript comment");
case ASPJavaScriptNumber:
return tr("ASP JavaScript number");
case ASPJavaScriptWord:
return tr("ASP JavaScript word");
case ASPJavaScriptKeyword:
return tr("ASP JavaScript keyword");
case ASPJavaScriptDoubleQuotedString:
return tr("ASP JavaScript double-quoted string");
case ASPJavaScriptSingleQuotedString:
return tr("ASP JavaScript single-quoted string");
case ASPJavaScriptSymbol:
return tr("ASP JavaScript symbol");
case ASPJavaScriptUnclosedString:
return tr("ASP JavaScript unclosed string");
case ASPJavaScriptRegex:
return tr("ASP JavaScript regular expression");
case VBScriptStart:
return tr("Start of a VBScript fragment");
case VBScriptDefault:
return tr("VBScript default");
case VBScriptComment:
return tr("VBScript comment");
case VBScriptNumber:
return tr("VBScript number");
case VBScriptKeyword:
return tr("VBScript keyword");
case VBScriptString:
return tr("VBScript string");
case VBScriptIdentifier:
return tr("VBScript identifier");
case VBScriptUnclosedString:
return tr("VBScript unclosed string");
case ASPVBScriptStart:
return tr("Start of an ASP VBScript fragment");
case ASPVBScriptDefault:
return tr("ASP VBScript default");
case ASPVBScriptComment:
return tr("ASP VBScript comment");
case ASPVBScriptNumber:
return tr("ASP VBScript number");
case ASPVBScriptKeyword:
return tr("ASP VBScript keyword");
case ASPVBScriptString:
return tr("ASP VBScript string");
case ASPVBScriptIdentifier:
return tr("ASP VBScript identifier");
case ASPVBScriptUnclosedString:
return tr("ASP VBScript unclosed string");
case PythonStart:
return tr("Start of a Python fragment");
case PythonDefault:
return tr("Python default");
case PythonComment:
return tr("Python comment");
case PythonNumber:
return tr("Python number");
case PythonDoubleQuotedString:
return tr("Python double-quoted string");
case PythonSingleQuotedString:
return tr("Python single-quoted string");
case PythonKeyword:
return tr("Python keyword");
case PythonTripleDoubleQuotedString:
return tr("Python triple double-quoted string");
case PythonTripleSingleQuotedString:
return tr("Python triple single-quoted string");
case PythonClassName:
return tr("Python class name");
case PythonFunctionMethodName:
return tr("Python function or method name");
case PythonOperator:
return tr("Python operator");
case PythonIdentifier:
return tr("Python identifier");
case ASPPythonStart:
return tr("Start of an ASP Python fragment");
case ASPPythonDefault:
return tr("ASP Python default");
case ASPPythonComment:
return tr("ASP Python comment");
case ASPPythonNumber:
return tr("ASP Python number");
case ASPPythonDoubleQuotedString:
return tr("ASP Python double-quoted string");
case ASPPythonSingleQuotedString:
return tr("ASP Python single-quoted string");
case ASPPythonKeyword:
return tr("ASP Python keyword");
case ASPPythonTripleDoubleQuotedString:
return tr("ASP Python triple double-quoted string");
case ASPPythonTripleSingleQuotedString:
return tr("ASP Python triple single-quoted string");
case ASPPythonClassName:
return tr("ASP Python class name");
case ASPPythonFunctionMethodName:
return tr("ASP Python function or method name");
case ASPPythonOperator:
return tr("ASP Python operator");
case ASPPythonIdentifier:
return tr("ASP Python identifier");
case PHPDefault:
return tr("PHP default");
case PHPDoubleQuotedString:
return tr("PHP double-quoted string");
case PHPSingleQuotedString:
return tr("PHP single-quoted string");
case PHPKeyword:
return tr("PHP keyword");
case PHPNumber:
return tr("PHP number");
case PHPVariable:
return tr("PHP variable");
case PHPComment:
return tr("PHP comment");
case PHPCommentLine:
return tr("PHP line comment");
case PHPDoubleQuotedVariable:
return tr("PHP double-quoted variable");
case PHPOperator:
return tr("PHP operator");
}
return QString();
}
// Returns the background colour of the text for a style.
QColor QsciLexerHTML::defaultPaper(int style) const
{
switch (style)
{
case ASPAtStart:
return QColor(0xff,0xff,0x00);
case ASPStart:
case CDATA:
return QColor(0xff,0xdf,0x00);
case PHPStart:
return QColor(0xff,0xef,0xbf);
case HTMLValue:
return QColor(0xff,0xef,0xff);
case SGMLDefault:
case SGMLCommand:
case SGMLParameter:
case SGMLDoubleQuotedString:
case SGMLSingleQuotedString:
case SGMLSpecial:
case SGMLEntity:
case SGMLComment:
return QColor(0xef,0xef,0xff);
case SGMLError:
return QColor(0xff,0x66,0x66);
case SGMLBlockDefault:
return QColor(0xcc,0xcc,0xe0);
case JavaScriptDefault:
case JavaScriptComment:
case JavaScriptCommentLine:
case JavaScriptCommentDoc:
case JavaScriptNumber:
case JavaScriptWord:
case JavaScriptKeyword:
case JavaScriptDoubleQuotedString:
case JavaScriptSingleQuotedString:
case JavaScriptSymbol:
return QColor(0xf0,0xf0,0xff);
case JavaScriptUnclosedString:
case ASPJavaScriptUnclosedString:
return QColor(0xbf,0xbb,0xb0);
case JavaScriptRegex:
case ASPJavaScriptRegex:
return QColor(0xff,0xbb,0xb0);
case ASPJavaScriptDefault:
case ASPJavaScriptComment:
case ASPJavaScriptCommentLine:
case ASPJavaScriptCommentDoc:
case ASPJavaScriptNumber:
case ASPJavaScriptWord:
case ASPJavaScriptKeyword:
case ASPJavaScriptDoubleQuotedString:
case ASPJavaScriptSingleQuotedString:
case ASPJavaScriptSymbol:
return QColor(0xdf,0xdf,0x7f);
case VBScriptDefault:
case VBScriptComment:
case VBScriptNumber:
case VBScriptKeyword:
case VBScriptString:
case VBScriptIdentifier:
return QColor(0xef,0xef,0xff);
case VBScriptUnclosedString:
case ASPVBScriptUnclosedString:
return QColor(0x7f,0x7f,0xff);
case ASPVBScriptDefault:
case ASPVBScriptComment:
case ASPVBScriptNumber:
case ASPVBScriptKeyword:
case ASPVBScriptString:
case ASPVBScriptIdentifier:
return QColor(0xcf,0xcf,0xef);
case PythonDefault:
case PythonComment:
case PythonNumber:
case PythonDoubleQuotedString:
case PythonSingleQuotedString:
case PythonKeyword:
case PythonTripleSingleQuotedString:
case PythonTripleDoubleQuotedString:
case PythonClassName:
case PythonFunctionMethodName:
case PythonOperator:
case PythonIdentifier:
return QColor(0xef,0xff,0xef);
case ASPPythonDefault:
case ASPPythonComment:
case ASPPythonNumber:
case ASPPythonDoubleQuotedString:
case ASPPythonSingleQuotedString:
case ASPPythonKeyword:
case ASPPythonTripleSingleQuotedString:
case ASPPythonTripleDoubleQuotedString:
case ASPPythonClassName:
case ASPPythonFunctionMethodName:
case ASPPythonOperator:
case ASPPythonIdentifier:
return QColor(0xcf,0xef,0xcf);
case PHPDefault:
case PHPDoubleQuotedString:
case PHPSingleQuotedString:
case PHPKeyword:
case PHPNumber:
case PHPVariable:
case PHPComment:
case PHPCommentLine:
case PHPDoubleQuotedVariable:
case PHPOperator:
return QColor(0xff,0xf8,0xf8);
}
return QsciLexer::defaultPaper(style);
}
// Refresh all properties.
void QsciLexerHTML::refreshProperties()
{
setCompactProp();
setPreprocProp();
setCaseSensTagsProp();
setScriptCommentsProp();
setScriptHeredocsProp();
setDjangoProp();
setMakoProp();
}
// Read properties from the settings.
bool QsciLexerHTML::readProperties(QSettings &qs,const QString &prefix)
{
int rc = true;
fold_compact = qs.value(prefix + "foldcompact", true).toBool();
fold_preproc = qs.value(prefix + "foldpreprocessor", false).toBool();
case_sens_tags = qs.value(prefix + "casesensitivetags", false).toBool();
fold_script_comments = qs.value(prefix + "foldscriptcomments", false).toBool();
fold_script_heredocs = qs.value(prefix + "foldscriptheredocs", false).toBool();
django_templates = qs.value(prefix + "djangotemplates", false).toBool();
mako_templates = qs.value(prefix + "makotemplates", false).toBool();
return rc;
}
// Write properties to the settings.
bool QsciLexerHTML::writeProperties(QSettings &qs,const QString &prefix) const
{
int rc = true;
qs.setValue(prefix + "foldcompact", fold_compact);
qs.setValue(prefix + "foldpreprocessor", fold_preproc);
qs.setValue(prefix + "casesensitivetags", case_sens_tags);
qs.setValue(prefix + "foldscriptcomments", fold_script_comments);
qs.setValue(prefix + "foldscriptheredocs", fold_script_heredocs);
qs.setValue(prefix + "djangotemplates", django_templates);
qs.setValue(prefix + "makotemplates", mako_templates);
return rc;
}
// Set if tags are case sensitive.
void QsciLexerHTML::setCaseSensitiveTags(bool sens)
{
case_sens_tags = sens;
setCaseSensTagsProp();
}
// Set the "html.tags.case.sensitive" property.
void QsciLexerHTML::setCaseSensTagsProp()
{
emit propertyChanged("html.tags.case.sensitive",(case_sens_tags ? "1" : "0"));
}
// Set if folds are compact
void QsciLexerHTML::setFoldCompact(bool fold)
{
fold_compact = fold;
setCompactProp();
}
// Set the "fold.compact" property.
void QsciLexerHTML::setCompactProp()
{
emit propertyChanged("fold.compact",(fold_compact ? "1" : "0"));
}
// Set if preprocessor blocks can be folded.
void QsciLexerHTML::setFoldPreprocessor(bool fold)
{
fold_preproc = fold;
setPreprocProp();
}
// Set the "fold.html.preprocessor" property.
void QsciLexerHTML::setPreprocProp()
{
emit propertyChanged("fold.html.preprocessor",(fold_preproc ? "1" : "0"));
}
// Set if script comments can be folded.
void QsciLexerHTML::setFoldScriptComments(bool fold)
{
fold_script_comments = fold;
setScriptCommentsProp();
}
// Set the "fold.hypertext.comment" property.
void QsciLexerHTML::setScriptCommentsProp()
{
emit propertyChanged("fold.hypertext.comment",(fold_script_comments ? "1" : "0"));
}
// Set if script heredocs can be folded.
void QsciLexerHTML::setFoldScriptHeredocs(bool fold)
{
fold_script_heredocs = fold;
setScriptHeredocsProp();
}
// Set the "fold.hypertext.heredoc" property.
void QsciLexerHTML::setScriptHeredocsProp()
{
emit propertyChanged("fold.hypertext.heredoc",(fold_script_heredocs ? "1" : "0"));
}
// Set if Django templates are supported.
void QsciLexerHTML::setDjangoTemplates(bool enable)
{
django_templates = enable;
setDjangoProp();
}
// Set the "lexer.html.django" property.
void QsciLexerHTML::setDjangoProp()
{
emit propertyChanged("lexer.html.django", (django_templates ? "1" : "0"));
}
// Set if Mako templates are supported.
void QsciLexerHTML::setMakoTemplates(bool enable)
{
mako_templates = enable;
setMakoProp();
}
// Set the "lexer.html.mako" property.
void QsciLexerHTML::setMakoProp()
{
emit propertyChanged("lexer.html.mako", (mako_templates ? "1" : "0"));
}
|