/
Styles.c
3421 lines (3052 loc) · 102 KB
/
Styles.c
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
/******************************************************************************
*
*
* 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-2011
* florian.balmer@gmail.com
* http://www.flos-freeware.ch
*
*
******************************************************************************/
#include <windows.h>
#include <shlwapi.h>
#include <shlobj.h>
#include <commctrl.h>
#include <commdlg.h>
#include <stdio.h>
#include "Notepad2.h"
#include "Edit.h"
#include "Styles.h"
#include "Dialogs.h"
#include "Helpers.h"
#include "SciCall.h"
#include "resource.h"
extern EDITLEXER lexDefault;
extern EDITLEXER lexCPP;
extern EDITLEXER lexJava;
extern EDITLEXER lexCSharp;
extern EDITLEXER lexPython;
extern EDITLEXER lexRuby;
extern EDITLEXER lexPHP;
extern EDITLEXER lexSQL;
extern EDITLEXER lexXML;
extern EDITLEXER lexJSON;
extern EDITLEXER lexHTML;
extern EDITLEXER lexCSS;
extern EDITLEXER lexJS;
extern EDITLEXER lexMatlab;
extern EDITLEXER lexVB;
extern EDITLEXER lexVBS;
extern EDITLEXER lexGroovy;
extern EDITLEXER lexScala;
extern EDITLEXER lexGo;
extern EDITLEXER lexLua;
extern EDITLEXER lexJulia;
extern EDITLEXER lexFortran;
extern EDITLEXER lexTexinfo;
extern EDITLEXER lexLaTeX;
extern EDITLEXER lexASY;
extern EDITLEXER lexDOT;
extern EDITLEXER lexAS;
extern EDITLEXER lexHaXe;
extern EDITLEXER lexD;
extern EDITLEXER lexFSharp;
extern EDITLEXER lexPascal;
extern EDITLEXER lexSmali;
extern EDITLEXER lexCIL;
extern EDITLEXER lexLLVM;
extern EDITLEXER lexASM;
extern EDITLEXER lexVHDL;
extern EDITLEXER lexVerilog;
extern EDITLEXER lexBatch;
extern EDITLEXER lexBash;
extern EDITLEXER lexPerl;
extern EDITLEXER lexTcl;
extern EDITLEXER lexAwk;
extern EDITLEXER lexLisp;
extern EDITLEXER lexVim;
extern EDITLEXER lexPS1;
extern EDITLEXER lexAU3;
extern EDITLEXER lexRC;
//extern EDITLEXER lexIDL;
extern EDITLEXER lexMake;
extern EDITLEXER lexCMake;
extern EDITLEXER lexGradle;
extern EDITLEXER lexJAM;
extern EDITLEXER lexINNO;
extern EDITLEXER lexNsis;
extern EDITLEXER lexCONF;
extern EDITLEXER lexINI;
extern EDITLEXER lexDIFF;
extern EDITLEXER lexANSI;
// This array holds all the lexers...
PEDITLEXER pLexArray[NUMLEXERS] = {
&lexDefault,
&lexCPP,
&lexJava,
&lexCSharp,
&lexPython,
&lexRuby,
&lexPHP,
&lexSQL,
&lexXML,
&lexJSON,
&lexHTML,
&lexCSS,
&lexJS,
&lexMatlab,
&lexVB,
&lexVBS,
&lexGroovy,
&lexScala,
&lexGo,
&lexLua,
&lexJulia,
&lexFortran,
&lexTexinfo,
&lexLaTeX,
&lexASY,
&lexDOT,
&lexAS,
&lexHaXe,
&lexD,
&lexFSharp,
&lexPascal,
&lexSmali,
&lexCIL,
&lexLLVM,
&lexASM,
&lexVHDL,
&lexVerilog,
&lexBatch,
&lexBash,
&lexPerl,
&lexTcl,
&lexAwk,
&lexLisp,
&lexVim,
&lexPS1,
&lexAU3,
&lexRC,
//&lexIDL,
&lexMake,
&lexCMake,
&lexGradle,
&lexJAM,
&lexINNO,
&lexNsis,
&lexCONF,
&lexINI,
&lexDIFF,
&lexANSI
};
#define NUM_MONO_FONT 5
const WCHAR *SysMonoFontName[NUM_MONO_FONT] = {
L"DejaVu Sans Mono",
//L"Bitstream Vera Sans Mono",
L"Consolas",
L"Monaco",
L"Inconsolata",
L"Lucida Console",
};
int np2MonoFontIndex = NUM_MONO_FONT; // Courier New
// Currently used lexer
PEDITLEXER pLexCurrent = &lexDefault;
int np2LexLangIndex = 0;
COLORREF crCustom[16];
BOOL bUse2ndDefaultStyle;
BOOL fStylesModified = FALSE;
BOOL fWarnedNoIniFile = FALSE;
int iBaseFontSize = 11;
int iCurrentDPI = USER_DEFAULT_SCREEN_DPI;
int iDefaultLexer;
BOOL bAutoSelect;
int cxStyleSelectDlg;
int cyStyleSelectDlg;
// Notepad2.c
extern HWND hwndEdit;
extern int iEncoding;
extern int g_DOSEncoding;
extern int iDefaultCodePage;
extern int iDefaultCharSet;
extern BOOL bHiliteCurrentLine;
//=============================================================================
//
// Style_Load()
//
void Style_Load(void) {
unsigned int iLexer;
WCHAR *pIniSection = LocalAlloc(LPTR, sizeof(WCHAR) * 32 * 1024);
int cchIniSection = (int)LocalSize(pIniSection) / sizeof(WCHAR);
// Custom colors
crCustom [0] = RGB(0x00, 0x00, 0x00);
crCustom [1] = RGB(0x0A, 0x24, 0x6A);
crCustom [2] = RGB(0x3A, 0x6E, 0xA5);
crCustom [3] = RGB(0x00, 0x3C, 0xE6);
crCustom [4] = RGB(0x00, 0x66, 0x33);
crCustom [5] = RGB(0x60, 0x80, 0x20);
crCustom [6] = RGB(0x64, 0x80, 0x00);
crCustom [7] = RGB(0xA4, 0x60, 0x00);
crCustom [8] = RGB(0xFF, 0xFF, 0xFF);
crCustom [9] = RGB(0xFF, 0xFF, 0xE2);
crCustom[10] = RGB(0xFF, 0xF1, 0xA8);
crCustom[11] = RGB(0xFF, 0xC0, 0x00);
crCustom[12] = RGB(0xFF, 0x40, 0x00);
crCustom[13] = RGB(0xC8, 0x00, 0x00);
crCustom[14] = RGB(0xB0, 0x00, 0xB0);
crCustom[15] = RGB(0xB2, 0x8B, 0x40);
LoadIniSection(L"Custom Colors", pIniSection, cchIniSection);
for (unsigned int i = 0; i < 16; i++) {
WCHAR tch[32];
WCHAR wch[32];
wsprintf(tch, L"%02u", i + 1);
if (IniSectionGetString(pIniSection, tch, L"", wch, COUNTOF(wch))) {
if (wch[0] == L'#') {
unsigned int irgb;
int itok = swscanf(CharNext(wch), L"%x", &irgb);
if (itok == 1) {
crCustom[i] = RGB((irgb & 0xFF0000) >> 16, (irgb & 0xFF00) >> 8, irgb & 0xFF);
}
}
}
}
LoadIniSection(L"Styles", pIniSection, cchIniSection);
// 2nd default
bUse2ndDefaultStyle = IniSectionGetBool(pIniSection, L"Use2ndDefaultStyle", 0);
// default scheme
iDefaultLexer = IniSectionGetInt(pIniSection, L"DefaultScheme", 0);
iDefaultLexer = minmax_i(iDefaultLexer, 0, NUMLEXERS - 1);
// auto select
bAutoSelect = IniSectionGetBool(pIniSection, L"AutoSelect", 1);
// scheme select dlg dimensions
cxStyleSelectDlg = IniSectionGetInt(pIniSection, L"SelectDlgSizeX", 304);
cxStyleSelectDlg = max_i(cxStyleSelectDlg, 0);
cyStyleSelectDlg = IniSectionGetInt(pIniSection, L"SelectDlgSizeY", 0);
cyStyleSelectDlg = max_i(cyStyleSelectDlg, 324);
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
unsigned int i = 0;
LoadIniSection(pLexArray[iLexer]->pszName, pIniSection, cchIniSection);
if (!IniSectionGetString(pIniSection, L"FileNameExtensions",
pLexArray[iLexer]->pszDefExt,
pLexArray[iLexer]->szExtensions,
COUNTOF(pLexArray[iLexer]->szExtensions)))
lstrcpyn(pLexArray[iLexer]->szExtensions,
pLexArray[iLexer]->pszDefExt,
COUNTOF(pLexArray[iLexer]->szExtensions));
while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
IniSectionGetString(pIniSection, pLexArray[iLexer]->Styles[i].pszName,
pLexArray[iLexer]->Styles[i].pszDefault,
pLexArray[iLexer]->Styles[i].szValue,
COUNTOF(pLexArray[iLexer]->Styles[i].szValue));
i++;
}
}
LocalFree(pIniSection);
}
//=============================================================================
//
// Style_Save()
//
void Style_Save(void) {
unsigned iLexer;
WCHAR *pIniSection = LocalAlloc(LPTR, sizeof(WCHAR) * 32 * 1024);
int cchIniSection = (int)LocalSize(pIniSection) / sizeof(WCHAR);
// Custom colors
for (unsigned int i = 0; i < 16; i++) {
WCHAR tch[32];
WCHAR wch[32];
wsprintf(tch, L"%02u", i + 1);
wsprintf(wch, L"#%02X%02X%02X",
(int)GetRValue(crCustom[i]),
(int)GetGValue(crCustom[i]),
(int)GetBValue(crCustom[i]));
IniSectionSetString(pIniSection, tch, wch);
}
SaveIniSection(L"Custom Colors", pIniSection);
ZeroMemory(pIniSection, cchIniSection);
// auto select
IniSectionSetBool(pIniSection, L"Use2ndDefaultStyle", bUse2ndDefaultStyle);
// default scheme
IniSectionSetInt(pIniSection, L"DefaultScheme", iDefaultLexer);
// auto select
IniSectionSetBool(pIniSection, L"AutoSelect", bAutoSelect);
// scheme select dlg dimensions
IniSectionSetInt(pIniSection, L"SelectDlgSizeX", cxStyleSelectDlg);
IniSectionSetInt(pIniSection, L"SelectDlgSizeY", cyStyleSelectDlg);
SaveIniSection(L"Styles", pIniSection);
if (!fStylesModified) {
LocalFree(pIniSection);
return;
}
ZeroMemory(pIniSection, cchIniSection);
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
unsigned int i = 0;
IniSectionSetString(pIniSection, L"FileNameExtensions",
pLexArray[iLexer]->szExtensions);
while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
IniSectionSetString(pIniSection,
pLexArray[iLexer]->Styles[i].pszName,
pLexArray[iLexer]->Styles[i].szValue);
i++;
}
SaveIniSection(pLexArray[iLexer]->pszName, pIniSection);
ZeroMemory(pIniSection, cchIniSection);
}
LocalFree(pIniSection);
}
//=============================================================================
//
// Style_Import()
//
BOOL Style_Import(HWND hwnd) {
WCHAR szFile[MAX_PATH * 2] = L"";
WCHAR szFilter[256];
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(OPENFILENAME));
GetString(IDS_FILTER_INI, szFilter, COUNTOF(szFilter));
PrepareFilterStr(szFilter);
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = szFilter;
ofn.lpstrFile = szFile;
ofn.lpstrDefExt = L"ini";
ofn.nMaxFile = COUNTOF(szFile);
ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
| OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/;
if (GetOpenFileName(&ofn)) {
unsigned int iLexer;
WCHAR *pIniSection = LocalAlloc(LPTR, sizeof(WCHAR) * 32 * 1024);
int cchIniSection = (int)LocalSize(pIniSection) / sizeof(WCHAR);
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
if (GetPrivateProfileSection(pLexArray[iLexer]->pszName, pIniSection, cchIniSection, szFile)) {
unsigned int i = 0;
if (!IniSectionGetString(pIniSection,
L"FileNameExtensions",
pLexArray[iLexer]->pszDefExt,
pLexArray[iLexer]->szExtensions,
COUNTOF(pLexArray[iLexer]->szExtensions)))
lstrcpyn(pLexArray[iLexer]->szExtensions,
pLexArray[iLexer]->pszDefExt,
COUNTOF(pLexArray[iLexer]->szExtensions));
while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
IniSectionGetString(pIniSection,
pLexArray[iLexer]->Styles[i].pszName,
pLexArray[iLexer]->Styles[i].pszDefault,
pLexArray[iLexer]->Styles[i].szValue,
COUNTOF(pLexArray[iLexer]->Styles[i].szValue));
i++;
}
}
}
LocalFree(pIniSection);
return TRUE;
}
return FALSE;
}
//=============================================================================
//
// Style_Export()
//
BOOL Style_Export(HWND hwnd) {
WCHAR szFile[MAX_PATH * 2] = L"";
WCHAR szFilter[256];
OPENFILENAME ofn;
DWORD dwError = ERROR_SUCCESS;
ZeroMemory(&ofn, sizeof(OPENFILENAME));
GetString(IDS_FILTER_INI, szFilter, COUNTOF(szFilter));
PrepareFilterStr(szFilter);
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = szFilter;
ofn.lpstrFile = szFile;
ofn.lpstrDefExt = L"ini";
ofn.nMaxFile = COUNTOF(szFile);
ofn.Flags = /*OFN_FILEMUSTEXIST |*/ OFN_HIDEREADONLY | OFN_NOCHANGEDIR | OFN_DONTADDTORECENT
| OFN_PATHMUSTEXIST | OFN_SHAREAWARE /*| OFN_NODEREFERENCELINKS*/ | OFN_OVERWRITEPROMPT;
if (GetSaveFileName(&ofn)) {
unsigned int iLexer;
WCHAR *pIniSection = LocalAlloc(LPTR, sizeof(WCHAR) * 32 * 1024);
int cchIniSection = (int)LocalSize(pIniSection) / sizeof(WCHAR);
for (iLexer = 0; iLexer < NUMLEXERS; iLexer++) {
unsigned int i = 0;
IniSectionSetString(pIniSection, L"FileNameExtensions", pLexArray[iLexer]->szExtensions);
while (pLexArray[iLexer]->Styles[i].iStyle != -1) {
IniSectionSetString(pIniSection,
pLexArray[iLexer]->Styles[i].pszName,
pLexArray[iLexer]->Styles[i].szValue);
i++;
}
if (!WritePrivateProfileSection(pLexArray[iLexer]->pszName, pIniSection, szFile)) {
dwError = GetLastError();
}
ZeroMemory(pIniSection, cchIniSection);
}
LocalFree(pIniSection);
if (dwError != ERROR_SUCCESS) {
MsgBox(MBINFO, IDS_EXPORT_FAIL, szFile);
}
return TRUE;
}
return FALSE;
}
void Style_OnDPIChanged(HWND hwnd, int dpi) {
if (iCurrentDPI != dpi) {
iCurrentDPI = dpi;
Style_SetLexer(hwnd, pLexCurrent);
}
}
// set folding style; braces are for scoping only
static const int iMarkerIDs[] = {
SC_MARKNUM_FOLDEROPEN,
SC_MARKNUM_FOLDER,
SC_MARKNUM_FOLDERSUB,
SC_MARKNUM_FOLDERTAIL,
SC_MARKNUM_FOLDEREND,
SC_MARKNUM_FOLDEROPENMID,
SC_MARKNUM_FOLDERMIDTAIL
};
//=============================================================================
// set current lexer
// Style_SetLexer()
//
void Style_SetLexer(HWND hwnd, PEDITLEXER pLexNew) {
//WCHAR *p;
int rgb;
int iValue;
int iIdx;
WCHAR wchCaretStyle[64] = L"";
char msg[10];
// Select default if NULL is specified
if (!pLexNew) {
np2LexLangIndex = 0;
pLexNew = pLexArray[iDefaultLexer];
}
// Lexer
SendMessage(hwnd, SCI_SETLEXER, pLexNew->iLexer, 0);
_itoa(pLexNew->rid - 63000, msg, 10);
SendMessage(hwnd, SCI_SETPROPERTY, (WPARAM)"lexer.lang.type", (LPARAM)msg);
// Code folding
SciCall_SetProperty("fold", "1");
SciCall_SetProperty("fold.foldsyntaxbased", "1");
SciCall_SetProperty("fold.comment", "1");
SciCall_SetProperty("fold.preprocessor", "1");
SciCall_SetProperty("fold.compact", "0");
switch (pLexNew->rid) {
case NP2LEX_HTML:
case NP2LEX_XML:
SciCall_SetProperty("fold.html", "1");
SciCall_SetProperty("fold.hypertext.comment", "1");
SciCall_SetProperty("fold.hypertext.heredoc", "1");
break;
}
Style_UpdateLexKeywords(pLexNew);
// Add KeyWord Lists
if (IsDocLowerKeywords(pLexNew)) {
for (int i = 0; i < NUMKEYWORD; i++) {
const char *pKeywords = pLexNew->pKeyWords->pszKeyWords[i];
if (pKeywords && *pKeywords) {
char *lowerKeywords;
char ch;
iIdx = lstrlenA(pKeywords);
lowerKeywords = LocalAlloc(LPTR, iIdx + 1);
lstrcpyA(lowerKeywords, pKeywords);
while ((ch = *lowerKeywords) != '\0') {
if (ch >= 'A' && ch <= 'Z') {
*lowerKeywords = ch - 'A' + 'a';
}
lowerKeywords++;
}
lowerKeywords -= iIdx;
SendMessage(hwnd, SCI_SETKEYWORDS, i, (LPARAM)lowerKeywords);
LocalFree(lowerKeywords);
} else {
SendMessage(hwnd, SCI_SETKEYWORDS, i, (LPARAM)"");
}
}
} else {
for (int i = 0; i < NUMKEYWORD; i++) {
const char *pKeywords = pLexNew->pKeyWords->pszKeyWords[i];
if (pKeywords && *pKeywords) {
SendMessage(hwnd, SCI_SETKEYWORDS, i, (LPARAM)pKeywords);
} else {
SendMessage(hwnd, SCI_SETKEYWORDS, i, (LPARAM)"");
}
}
}
// Use 2nd default style
iIdx = (bUse2ndDefaultStyle) ? 12 : 0;
// Font quality setup, check availability of Consolas
Style_SetFontQuality(hwnd, lexDefault.Styles[0 + iIdx].szValue);
for (int i = 0; i < NUM_MONO_FONT; i++) {
if (IsFontAvailable(SysMonoFontName[i])) {
np2MonoFontIndex = i;
break;
}
}
// Clear
SendMessage(hwnd, SCI_CLEARDOCUMENTSTYLE, 0, 0);
// Default Values are always set
SendMessage(hwnd, SCI_STYLERESETDEFAULT, 0, 0);
SendMessage(hwnd, SCI_STYLESETCHARACTERSET, STYLE_DEFAULT, (LPARAM)DEFAULT_CHARSET);
Style_SetStyles(hwnd, lexDefault.Styles[0 + iIdx].iStyle, lexDefault.Styles[0 + iIdx].szValue); // default
Style_StrGetSize(lexDefault.Styles[0 + iIdx].szValue, &iBaseFontSize); // base size
// Auto-select codepage according to charset
//Style_SetACPfromCharSet(hwnd);
if (!Style_StrGetColor(TRUE, lexDefault.Styles[0 + iIdx].szValue, &iValue)) {
SendMessage(hwnd, SCI_STYLESETFORE, STYLE_DEFAULT, (LPARAM)GetSysColor(COLOR_WINDOWTEXT)); // default text color
}
if (!Style_StrGetColor(FALSE, lexDefault.Styles[0 + iIdx].szValue, &iValue)) {
SendMessage(hwnd, SCI_STYLESETBACK, STYLE_DEFAULT, (LPARAM)GetSysColor(COLOR_WINDOW)); // default window color
}
if (pLexNew->iLexer != SCLEX_NULL || pLexNew == &lexANSI) {
Style_SetStyles(hwnd, pLexNew->Styles[0].iStyle, pLexNew->Styles[0].szValue); // lexer default
}
SendMessage(hwnd, SCI_STYLECLEARALL, 0, 0);
Style_SetStyles(hwnd, lexDefault.Styles[1 + iIdx].iStyle, lexDefault.Styles[1 + iIdx].szValue); // linenumber
Style_SetStyles(hwnd, lexDefault.Styles[2 + iIdx].iStyle, lexDefault.Styles[2 + iIdx].szValue); // brace light
Style_SetStyles(hwnd, lexDefault.Styles[3 + iIdx].iStyle, lexDefault.Styles[3 + iIdx].szValue); // brace bad
if (pLexNew != &lexANSI) {
Style_SetStyles(hwnd, lexDefault.Styles[4 + iIdx].iStyle, lexDefault.Styles[4 + iIdx].szValue); // control char
}
Style_SetStyles(hwnd, lexDefault.Styles[5 + iIdx].iStyle, lexDefault.Styles[5 + iIdx].szValue); // indent guide
// More default values...
if (Style_StrGetColor(TRUE, lexDefault.Styles[6 + iIdx].szValue, &rgb)) { // selection fore
SendMessage(hwnd, SCI_SETSELFORE, TRUE, rgb);
SendMessage(hwnd, SCI_SETADDITIONALSELFORE, rgb, 0);
} else {
SendMessage(hwnd, SCI_SETSELFORE, 0, 0);
SendMessage(hwnd, SCI_SETADDITIONALSELFORE, 0, 0);
}
if (Style_StrGetColor(FALSE, lexDefault.Styles[6 + iIdx].szValue, &iValue)) { // selection back
SendMessage(hwnd, SCI_SETSELBACK, TRUE, iValue);
SendMessage(hwnd, SCI_SETADDITIONALSELBACK, iValue, 0);
} else {
SendMessage(hwnd, SCI_SETSELBACK, TRUE, RGB(0xC0, 0xC0, 0xC0)); // use a default value...
SendMessage(hwnd, SCI_SETADDITIONALSELBACK, RGB(0xC0, 0xC0, 0xC0), 0);
}
if (Style_StrGetAlpha(lexDefault.Styles[6 + iIdx].szValue, &iValue)) { // selection alpha
SendMessage(hwnd, SCI_SETSELALPHA, iValue, 0);
SendMessage(hwnd, SCI_SETADDITIONALSELALPHA, iValue, 0);
} else {
SendMessage(hwnd, SCI_SETSELALPHA, SC_ALPHA_NOALPHA, 0);
SendMessage(hwnd, SCI_SETADDITIONALSELALPHA, SC_ALPHA_NOALPHA, 0);
}
if (StrStrI(lexDefault.Styles[6 + iIdx].szValue, L"eolfilled")) { // selection eolfilled
SendMessage(hwnd, SCI_SETSELEOLFILLED, 1, 0);
} else {
SendMessage(hwnd, SCI_SETSELEOLFILLED, 0, 0);
}
if (Style_StrGetColor(TRUE, lexDefault.Styles[7 + iIdx].szValue, &rgb)) { // whitespace fore
SendMessage(hwnd, SCI_SETWHITESPACEFORE, TRUE, rgb);
} else {
SendMessage(hwnd, SCI_SETWHITESPACEFORE, 0, 0);
}
if (Style_StrGetColor(FALSE, lexDefault.Styles[7 + iIdx].szValue, &rgb)) { // whitespace back
SendMessage(hwnd, SCI_SETWHITESPACEBACK, TRUE, rgb);
} else {
SendMessage(hwnd, SCI_SETWHITESPACEBACK, 0, 0); // use a default value...
}
// whitespace dot size
iValue = 1;
if (Style_StrGetSize(lexDefault.Styles[7 + iIdx].szValue, &iValue)) {
WCHAR tch[32];
WCHAR wchStyle[COUNTOF(lexDefault.Styles[0].szValue)];
lstrcpyn(wchStyle, lexDefault.Styles[7 + iIdx].szValue, COUNTOF(lexDefault.Styles[0].szValue));
iValue = maxmin_i(iValue, 5, 0);
wsprintf(lexDefault.Styles[7 + iIdx].szValue, L"size:%i", iValue);
if (Style_StrGetColor(TRUE, wchStyle, &rgb)) {
wsprintf(tch, L"; fore:#%02X%02X%02X",
(int)GetRValue(rgb),
(int)GetGValue(rgb),
(int)GetBValue(rgb));
lstrcat(lexDefault.Styles[7 + iIdx].szValue, tch);
}
if (Style_StrGetColor(FALSE, wchStyle, &rgb)) {
wsprintf(tch, L"; back:#%02X%02X%02X",
(int)GetRValue(rgb),
(int)GetGValue(rgb),
(int)GetBValue(rgb));
lstrcat(lexDefault.Styles[7 + iIdx].szValue, tch);
}
}
SendMessage(hwnd, SCI_SETWHITESPACESIZE, iValue, 0);
if (bHiliteCurrentLine) {
if (Style_StrGetColor(FALSE, lexDefault.Styles[8 + iIdx].szValue, &rgb)) { // caret line back
SendMessage(hwnd, SCI_SETCARETLINEVISIBLE, TRUE, 0);
SendMessage(hwnd, SCI_SETCARETLINEBACK, rgb, 0);
if (Style_StrGetAlpha(lexDefault.Styles[8 + iIdx].szValue, &iValue)) {
SendMessage(hwnd, SCI_SETCARETLINEBACKALPHA, iValue, 0);
} else {
SendMessage(hwnd, SCI_SETCARETLINEBACKALPHA, SC_ALPHA_NOALPHA, 0);
}
} else {
SendMessage(hwnd, SCI_SETCARETLINEVISIBLE, FALSE, 0);
}
} else {
SendMessage(hwnd, SCI_SETCARETLINEVISIBLE, FALSE, 0);
}
// caret style and width
if (StrStr(lexDefault.Styles[9 + iIdx].szValue, L"block")) {
SendMessage(hwnd, SCI_SETCARETSTYLE, CARETSTYLE_BLOCK, 0);
lstrcpy(wchCaretStyle, L"block");
} else {
iValue = 1;
if (Style_StrGetSize(lexDefault.Styles[9 + iIdx].szValue, &iValue)) {
WCHAR wch[32];
iValue = maxmin_i(iValue, 3, 1);
wsprintf(wch, L"size:%i", iValue);
lstrcat(wchCaretStyle, wch);
}
SendMessage(hwnd, SCI_SETCARETSTYLE, CARETSTYLE_LINE, 0);
SendMessage(hwnd, SCI_SETCARETWIDTH, iValue, 0);
}
if (StrStr(lexDefault.Styles[9 + iIdx].szValue, L"noblink")) {
SendMessage(hwnd, SCI_SETCARETPERIOD, (WPARAM)0, 0);
if (lstrlen(wchCaretStyle)) {
lstrcat(wchCaretStyle, L"; ");
}
lstrcat(wchCaretStyle, L"noblink");
} else {
SendMessage(hwnd, SCI_SETCARETPERIOD, (WPARAM)GetCaretBlinkTime(), 0);
}
// caret fore
if (!Style_StrGetColor(TRUE, lexDefault.Styles[9 + iIdx].szValue, &rgb)) {
rgb = GetSysColor(COLOR_WINDOWTEXT);
} else {
WCHAR wch[32];
wsprintf(wch, L"fore:#%02X%02X%02X",
(int)GetRValue(rgb),
(int)GetGValue(rgb),
(int)GetBValue(rgb));
if (lstrlen(wchCaretStyle)) {
lstrcat(wchCaretStyle, L"; ");
}
lstrcat(wchCaretStyle, wch);
}
if (!VerifyContrast(rgb, (COLORREF)SendMessage(hwnd, SCI_STYLEGETBACK, 0, 0))) {
rgb = (int)SendMessage(hwnd, SCI_STYLEGETFORE, 0, 0);
}
SendMessage(hwnd, SCI_SETCARETFORE, rgb, 0);
SendMessage(hwnd, SCI_SETADDITIONALCARETFORE, rgb, 0);
lstrcpy(lexDefault.Styles[9 + iIdx].szValue, wchCaretStyle);
if (SendMessage(hwnd, SCI_GETEDGEMODE, 0, 0) == EDGE_LINE) {
if (Style_StrGetColor(TRUE, lexDefault.Styles[10 + iIdx].szValue, &rgb)) { // edge fore
SendMessage(hwnd, SCI_SETEDGECOLOUR, rgb, 0);
} else {
SendMessage(hwnd, SCI_SETEDGECOLOUR, GetSysColor(COLOR_3DLIGHT), 0);
}
} else {
if (Style_StrGetColor(FALSE, lexDefault.Styles[10 + iIdx].szValue, &rgb)) { // edge back
SendMessage(hwnd, SCI_SETEDGECOLOUR, rgb, 0);
} else {
SendMessage(hwnd, SCI_SETEDGECOLOUR, GetSysColor(COLOR_3DLIGHT), 0);
}
}
// Extra Line Spacing
if (Style_StrGetSize(lexDefault.Styles[11 + iIdx].szValue, &iValue) && pLexNew != &lexANSI) {
int iAscent = 0;
int iDescent = 0;
iValue = minmax_i(iValue, 0, 64);
wsprintf(lexDefault.Styles[11 + iIdx].szValue, L"size:%i", iValue);
if ((iValue & 1)) { // iValue % 2
iAscent++;
iValue--;
}
iAscent += iValue / 2;
iDescent += iValue / 2;
SendMessage(hwnd, SCI_SETEXTRAASCENT, (WPARAM)iAscent, 0);
SendMessage(hwnd, SCI_SETEXTRADESCENT, (WPARAM)iDescent, 0);
} else {
SendMessage(hwnd, SCI_SETEXTRAASCENT, 0, 0);
SendMessage(hwnd, SCI_SETEXTRADESCENT, 0, 0);
//wsprintf(lexDefault.Styles[11+iIdx].szValue, L"size:0");
}
// set folding style; braces are for scoping only
{
COLORREF clrFore;
COLORREF clrBack = SciCall_StyleGetBack(STYLE_DEFAULT);
SciCall_SetFoldMarginColour(TRUE, clrBack);
SciCall_SetFoldMarginHiColour(TRUE, clrBack);
#if 0 // use gray fold color
clrFore = SciCall_StyleGetFore(STYLE_DEFAULT);
// Marker fore/back colors
// Set marker color to the average of clrFore and clrBack
clrFore = (((clrFore & 0xFF0000) + (clrBack & 0xFF0000)) >> 1 & 0xFF0000) |
(((clrFore & 0x00FF00) + (clrBack & 0x00FF00)) >> 1 & 0x00FF00) |
(((clrFore & 0x0000FF) + (clrBack & 0x0000FF)) >> 1 & 0x0000FF);
// Rounding hack for pure white against pure black
if (clrFore == 0x7F7F7F) {
clrFore = 0x808080;
}
#else // use blue fold color
clrFore = RGB(0x80, 0x80, 0xFF);
#endif
for (unsigned int i = 0; i < COUNTOF(iMarkerIDs); ++i) {
SciCall_MarkerSetBack(iMarkerIDs[i], clrFore);
SciCall_MarkerSetFore(iMarkerIDs[i], clrBack);
}
} // end set folding style
if (SendMessage(hwnd, SCI_GETINDENTATIONGUIDES, 0, 0) != SC_IV_NONE) {
Style_SetIndentGuides(hwnd, TRUE);
}
if (pLexNew->iLexer != SCLEX_NULL || pLexNew == &lexANSI) {
unsigned int i = 1;
while (pLexNew->Styles[i].iStyle != -1) {
for (unsigned int j = 0; j < 4 && (pLexNew->Styles[i].iStyle8[j] != 0 || j == 0); ++j) {
Style_SetStyles(hwnd, pLexNew->Styles[i].iStyle8[j], pLexNew->Styles[i].szValue);
}
if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HPHP_DEFAULT) {
int iRelated[] = { SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, SCE_HPHP_HEREDOC,
SCE_HPHP_SIMPLESTRING, SCE_HPHP_NOWDOC, SCE_HPHP_NUMBER, SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE,
SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE
};
for (unsigned int j = 0; j < COUNTOF(iRelated); j++) {
Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
}
}
if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJ_DEFAULT) {
int iRelated[] = { SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD,
SCE_HJ_WORD, SCE_HJ_DOUBLESTRING, SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX,
SCE_HJ_NUMBER, SCE_HJ_SYMBOLS
};
for (unsigned int j = 0; j < COUNTOF(iRelated); j++) {
Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
}
}
if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HJA_DEFAULT) {
int iRelated[] = { SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE, SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD,
SCE_HJA_WORD, SCE_HJA_DOUBLESTRING, SCE_HJA_SINGLESTRING, SCE_HJA_STRINGEOL, SCE_HJA_REGEX,
SCE_HJA_NUMBER, SCE_HJA_SYMBOLS
};
for (unsigned int j = 0; j < COUNTOF(iRelated); j++) {
Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
}
}
if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HB_DEFAULT) {
int iRelated[] = { SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER, SCE_HB_STRING,
SCE_HB_STRINGEOL, SCE_HB_NUMBER
};
for (unsigned int j = 0; j < COUNTOF(iRelated); j++) {
Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
}
}
if (pLexNew->iLexer == SCLEX_HTML && pLexNew->Styles[i].iStyle8[0] == SCE_HBA_DEFAULT) {
int iRelated[] = { SCE_HBA_COMMENTLINE, SCE_HBA_WORD, SCE_HBA_IDENTIFIER, SCE_HBA_STRING,
SCE_HBA_STRINGEOL, SCE_HBA_NUMBER
};
for (unsigned int j = 0; j < COUNTOF(iRelated); j++) {
Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
}
}
//if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML)
// && pLexNew->Styles[i].iStyle8[0] == SCE_H_SGML_DEFAULT) {
// int iRelated[] = { SCE_H_SGML_COMMAND, SCE_H_SGML_1ST_PARAM, SCE_H_SGML_DOUBLESTRING,
// SCE_H_SGML_SIMPLESTRING, SCE_H_SGML_ERROR, SCE_H_SGML_SPECIAL, SCE_H_SGML_ENTITY,
// SCE_H_SGML_COMMENT, SCE_H_SGML_1ST_PARAM_COMMENT, SCE_H_SGML_BLOCK_DEFAULT
// };
// for (unsigned int j = 0; j < COUNTOF(iRelated); j++) {
// Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
// }
//}
if ((pLexNew->iLexer == SCLEX_HTML || pLexNew->iLexer == SCLEX_XML)
&& pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) {
int iRelated[] = { SCE_HP_START, SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER, SCE_HP_STRING,
SCE_HP_CHARACTER, SCE_HP_WORD, SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE, SCE_HP_CLASSNAME,
SCE_HP_DEFNAME, SCE_HP_OPERATOR, SCE_HP_IDENTIFIER, SCE_HPA_START, SCE_HPA_DEFAULT,
SCE_HPA_COMMENTLINE, SCE_HPA_NUMBER, SCE_HPA_STRING, SCE_HPA_CHARACTER, SCE_HPA_WORD,
SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME,
SCE_HPA_OPERATOR, SCE_HPA_IDENTIFIER
};
for (unsigned int j = 0; j < COUNTOF(iRelated); j++) {
Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
}
}
if (pLexNew->iLexer == SCLEX_XML && pLexNew->Styles[i].iStyle8[0] == SCE_H_CDATA) {
int iRelated[] = { SCE_H_SCRIPT, SCE_H_ASP, SCE_H_ASPAT, SCE_H_QUESTION, SCE_HPHP_DEFAULT,
SCE_HPHP_COMMENT, SCE_HPHP_COMMENTLINE, SCE_HPHP_WORD, SCE_HPHP_HSTRING, SCE_HPHP_HEREDOC,
SCE_HPHP_SIMPLESTRING, SCE_HPHP_NOWDOC, SCE_HPHP_NUMBER, SCE_HPHP_OPERATOR, SCE_HPHP_VARIABLE,
SCE_HPHP_HSTRING_VARIABLE, SCE_HPHP_COMPLEX_VARIABLE, SCE_HJ_START, SCE_HJ_DEFAULT,
SCE_HJ_COMMENT, SCE_HJ_COMMENTLINE, SCE_HJ_COMMENTDOC, SCE_HJ_KEYWORD, SCE_HJ_WORD,
SCE_HJ_DOUBLESTRING, SCE_HJ_SINGLESTRING, SCE_HJ_STRINGEOL, SCE_HJ_REGEX, SCE_HJ_NUMBER,
SCE_HJ_SYMBOLS, SCE_HJA_START, SCE_HJA_DEFAULT, SCE_HJA_COMMENT, SCE_HJA_COMMENTLINE,
SCE_HJA_COMMENTDOC, SCE_HJA_KEYWORD, SCE_HJA_WORD, SCE_HJA_DOUBLESTRING,
SCE_HJA_SINGLESTRING, SCE_HJA_STRINGEOL, SCE_HJA_REGEX, SCE_HJA_NUMBER, SCE_HJA_SYMBOLS,
SCE_HB_START, SCE_HB_DEFAULT, SCE_HB_COMMENTLINE, SCE_HB_WORD, SCE_HB_IDENTIFIER,
SCE_HB_STRING, SCE_HB_STRINGEOL, SCE_HB_NUMBER, SCE_HBA_START, SCE_HBA_DEFAULT,
SCE_HBA_COMMENTLINE, SCE_HBA_WORD, SCE_HBA_IDENTIFIER, SCE_HBA_STRING, SCE_HBA_STRINGEOL,
SCE_HBA_NUMBER, SCE_HP_START, SCE_HP_DEFAULT, SCE_HP_COMMENTLINE, SCE_HP_NUMBER,
SCE_HP_STRING, SCE_HP_CHARACTER, SCE_HP_WORD, SCE_HP_TRIPLE, SCE_HP_TRIPLEDOUBLE,
SCE_HP_CLASSNAME, SCE_HP_DEFNAME, SCE_HP_OPERATOR, SCE_HP_IDENTIFIER, SCE_HPA_START,
SCE_HPA_DEFAULT, SCE_HPA_COMMENTLINE, SCE_HPA_NUMBER, SCE_HPA_STRING, SCE_HPA_CHARACTER,
SCE_HPA_WORD, SCE_HPA_TRIPLE, SCE_HPA_TRIPLEDOUBLE, SCE_HPA_CLASSNAME, SCE_HPA_DEFNAME,
SCE_HPA_OPERATOR, SCE_HPA_IDENTIFIER
};
for (unsigned int j = 0; j < COUNTOF(iRelated); j++) {
Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
}
}
//if (pLexNew->iLexer == SCLEX_CPP && pLexNew->Styles[i].iStyle8[0] == SCE_C_COMMENT) {
// int iRelated[] = { SCE_C_COMMENTLINE, SCE_C_COMMENTDOC, SCE_C_COMMENTLINEDOC,
// SCE_C_COMMENTDOCKEYWORD, SCE_C_COMMENTDOCKEYWORDERROR };
// for (unsigned int j = 0; j < COUNTOF(iRelated); j++)
// Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
//}
//if (pLexNew -> iLexer == SCLEX_SQL && pLexNew->Styles[i].iStyle8[0] == SCE_SQL_COMMENT) {
// int iRelated[] = { SCE_SQL_COMMENTLINE, SCE_SQL_COMMENTDOC, SCE_SQL_COMMENTLINEDOC,
// SCE_SQL_COMMENTDOCKEYWORD, SCE_SQL_COMMENTDOCKEYWORDERROR };
// for (unsigned int j = 0; j < COUNTOF(iRelated); j++)
// Style_SetStyles(hwnd, iRelated[j], pLexNew->Styles[i].szValue);
//}
i++;
}
}
SendMessage(hwnd, SCI_COLOURISE, 0, (LPARAM) - 1);
// Save current lexer
pLexCurrent = pLexNew;
UpdateStatusBarWidth();
}
//=============================================================================
// find lexer from script interpreter
// Style_SniffShebang()
//
PEDITLEXER __fastcall Style_SniffShebang(char *pchText) {
if (pchText[0] == '#' && pchText[1] == '!') {
size_t len = 0;
char *pch = pchText + 2;
char *name = pch;
while (*pch == ' ' || *pch == '\t') {
pch++;
}
name = pch;
while (*pch && *pch != ' ' && *pch != '\t' && *pch != '\r' && *pch != '\n') {
len = *pch == '\\' || *pch == '/';
pch++;
name = len ? pch : name;
}
if ((pch - name) >= 3 && StrCmpNIA(name, "env", 3) == 0) {
while (*pch == ' ' || *pch == '\t') {
pch++;
}
name = pch;
while (*pch && *pch != ' ' && *pch != '\t' && *pch != '\r' && *pch != '\n') {
len = *pch == '\\' || *pch == '/';
pch++;
name = len ? pch : name;
}
}
*pch = 0;
len = pch - name;
pch = name;
while (*pch) {
*pch |= 32;
if (*pch < 'a' || *pch > 'z') {
*pch = 0;
len = pch - name;
break;
}
pch++;
}
if (len >= 4) {
if (len >= 5) {
if (!StrCmpNA(name, "python", 5)) {
return &lexPython;
}
if (!StrCmpNA(name, "groovy", 5)) {
return &lexGroovy;
}
if (!StrCmpNA(name, "scala", 5)) {
return (&lexScala);
}
}
if (!StrCmpNA(name, "bash", 4) || !StrCmpNA(name, "dash", 4) || !StrCmpNA(name, "tcsh", 4)) {
return &lexBash;
}
if (!StrCmpNA(name, "perl", 4)) {
return &lexPerl;
}
if (!StrCmpNA(name, "ruby", 4)) {
return &lexRuby;
}
if (!StrCmpNA(name, "gawk", 4) || !StrCmpNA(name, "nawk", 4)) {
return &lexAwk;
}
if (!StrCmpNA(name, "node", 4)) {
return &lexJS;
}
if (!StrCmpNA(name, "wish", 4)) {
return &lexTcl;
}
if (!StrCmpNA(name, "wlua", 4)) {