-
Notifications
You must be signed in to change notification settings - Fork 72
/
ScINTILLA.ahk
2822 lines (2271 loc) · 126 KB
/
ScINTILLA.ahk
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
; Title: Scintilla Wrapper for AHK
; Group: Helper Functions
/*
Function: Add
Creates a Scintilla component and adds it to the Parent GUI.
This function initializes the Scintilla Component.
See <http://www.scintilla.org/Steps.html> for more information on how to add the component to a GUI/Control.
Parameters:
SCI_Add(hParent, [x, y, w, h, Styles, MsgHandler, DllPath])
hParent - Hwnd of the parent control who will host the Scintilla Component
x - x position for the control (default 5)
y - y position for the control (default 15)
w - Width of the control (default 390)
h - Height of the control (default 270)
Styles - List of window style variable names separated by spaces.
The WS_ prefix for the variables is optional.
Full list of Style names can be found at
<http://msdn.microsoft.com/en-us/library/ms632600%28v=vs.85%29.aspx>.
MsgHandler - Name of the function that will handle the window messages sent by the control.
This is very useful for when creating personalized lexing or folding for your control.
DllPath - Path to the SciLexer.dll file, if omitted the function looks for it in *a_scriptdir*.
Returns:
HWND - Component handle.
Examples:
(start code)
; Add a component with default values.
; It expects scilexer.dll to be on the script's location.
; The default values are calculated to fit optimally on a 400x300 GUI/Control
Gui +LastFound
hwnd:=WinExist()
hSci:=SCI_Add(hwnd)
Gui, show, w400 h300
return
;---------------------
; Add a component with default values.
; It expects scilexer.dll to be on the script's location.
; This script also adds some styles.
; If variables "x,y,w,h" are empty the default values are used.
Gui +LastFound
hwnd:=WinExist()
hSci:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_BORDER WS_VISIBLE")
Gui, show, w400 h300
return
;---------------------
; Add a component embedded in a tab with additional code for
; hiding/showing the component depending on which tab is open.
; If variables "x,w,h" are empty the default values are used.
Gui, add, Tab2, HWNDhwndtab x0 y0 w400 h300 gtabHandler vtabLast,one|two
hSci:=SCI_Add(hwndtab,x,25,w,h,"Child Border Visible","",a_desktop "\scilexer.dll")
Gui, show, w400 h300
return
tabHandler: ; Tab Handler for the Scintilla Control
Gui, submit, Nohide
action := tabLast = "one" ? "Show" : "Hide" ; decide which action to take
Control,%action%,,,ahk_id %hSci%
return
(end)
*/
SCI_Add(hParent, x=5, y=15, w=390, h=270, Styles="", MsgHandler="", DllPath=""){
static WS_OVERLAPPED:=0x00000000,WS_POPUP:=0x80000000,WS_CHILD:=0x40000000,WS_MINIMIZE:=0x20000000
,WS_VISIBLE:=0x10000000,WS_DISABLED:=0x08000000,WS_CLIPSIBLINGS:=0x04000000,WS_CLIPCHILDREN:=0x02000000
,WS_MAXIMIZE:=0x01000000,WS_CAPTION:=0x00C00000,WS_BORDER:=0x00800000,WS_DLGFRAME:=0x00400000
,WS_VSCROLL:=0x00200000,WS_HSCROLL:=0x00100000,WS_SYSMENU:=0x00080000,WS_THICKFRAME:=0x00040000
,WS_GROUP:=0x00020000,WS_TABSTOP:=0x00010000,WS_MINIMIZEBOX:=0x00020000,WS_MAXIMIZEBOX:=0x00010000
,WS_TILED:=0x00000000,WS_ICONIC:=0x20000000,WS_SIZEBOX:=0x00040000,WS_EX_CLIENTEDGE:=0x00000200
,GuiID:=311210,init:=False, NULL:=0
if !init ; WM_NOTIFY = 0x4E
old:=OnMessage(0x4E,"SCI_onNotify"),init:=True,old!="SCI_onNotify" ? SCI("oldNotify", RegisterCallback(old))
if !SCIModule:=DllCall("LoadLibrary", "Str", DllPath ? DllPath : "SciLexer.dll")
return debug ? A_ThisFunc "> Could not load library: " DllPath : -1
hStyle := WS_CHILD | (VISIBILITY := InStr(Styles, "Hidden") ? 0 : WS_VISIBLE) | WS_TABSTOP
if Styles
Loop, Parse, Styles, %a_tab%%a_space%, %a_tab%%a_space%
hStyle |= %a_loopfield%+0 ? %a_loopfield% : WS_%a_loopfield% ? WS_%a_loopfield% : 0
hSci:=DllCall("CreateWindowEx"
,Uint ,WS_EX_CLIENTEDGE ; Ex Style
,Str ,"Scintilla" ; Class Name
,Str ,"" ; Window Name
,UInt ,hStyle ; Window Styles
,Int ,x ? x : 5 ; x
,Int ,y ? y : 15 ; y
,Int ,w ? w : 390 ; Width
,Int ,h ? h : 270 ; Height
,UInt ,hParent ; Parent HWND
,UInt ,GuiID ; (HMENU)GuiID
,UInt ,NULL ; hInstance
,UInt ,NULL, "UInt") ; lpParam
,SCI(hSci, True) ; used to check if that handle exist.
,SCI_sendEditor(hSci) ; initialize SCI_sendEditor function
,IsFunc(MsgHandler) ? SCI(hSci "MsgHandler", MsgHandler)
return hSci
}
/* Group: Text
Group of funtions that handle the text in the scintilla component.
<http://www.scintilla.org/ScintillaDoc.html#TextRetrievalAndModification>
Each byte in a Scintilla document is followed by an associated byte of styling information. The combination of
a character byte and a style byte is called a cell. Style bytes are interpreted an index into an array of
styles.
Style bytes may be split into an index and a set of indicator bits but this use is discouraged and indicators
should now use *SCI_INDICATORFILLRANGE* and related calls. The default split is with the index in the low 5
bits and 3 high bits as indicators. This allows 32 fundamental styles, which is enough for most languages, and
three independent indicators so that, for example, syntax errors, deprecated names and bad indentation could
all be displayed at once. The number of bits used for styles can be altered with *SCI_SETSTYLEBITS* up to a
maximum of 8 bits. The remaining bits can be used for indicators.
In this document, 'character' normally refers to a byte even when multi-byte characters are used. Lengths
measure the numbers of bytes, not the amount of characters in those bytes.
Positions within the Scintilla document refer to a character or the gap before that character. The first
character in a document is 0, the second 1 and so on. If a document contains nLen characters, the last
character is numbered nLen-1. The caret exists between character positions and can be located from before the
first character (0) to after the last character (nLen).
There are places where the caret can not go where two character bytes make up one character. This occurs when a
DBCS character from a language like Japanese is included in the document or when line ends are marked with the
CP/M standard of a carriage return followed by a line feed. The *INVALID_POSITION* constant (-1) represents an
invalid position within the document.
All lines of text in Scintilla are the same height, and this height is calculated from the largest font in any
current style. This restriction is for performance; if lines differed in height then calculations involving
positioning of text would require the text to be styled first.
*/
; Group: General Text Functions
/*
Function: ReplaceSel
<http://www.scintilla.org/ScintillaDoc.html#SCI_REPLACESEL>
The currently selected text between the anchor and the current position is replaced by the 0 terminated text
string. If the anchor and current position are the same, the text is inserted at the caret position. The caret
is positioned after the inserted text and the caret is scrolled into view.
Parameters:
SCI_ReplaceSel(rStr[, hwnd])
rStr - String of text to use for replacing the current selection.
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
>SCI_ReplaceSel("replace currently selected text with this", hSci)
*/
SCI_ReplaceSel(rStr, hwnd=0){
a_isunicode ? (VarSetCapacity(rStrA, StrPut(rStr, "CP0")), StrPut(rStr, &rStrA, "CP0"))
return SCI_sendEditor(hwnd, "SCI_REPLACESEL", 0, a_isunicode ? &rStrA : &rStr)
}
/*
Function: Allocate
<http://www.scintilla.org/ScintillaDoc.html#SCI_ALLOCATE>
Allocate a document buffer large enough to store a given number of bytes. The document will not be made
smaller than its current contents.
Parameters:
SCI_Allocate(nBytes[, hwnd])
nBytes - Number of bytes to allocate for the document buffer.
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
>SCI_Allocate(1024, hSci)
*/
SCI_Allocate(nBytes, hwnd=0){
return SCI_sendEditor(hwnd, "SCI_ALLOCATE", nBytes)
}
/*
Function: AddText
<http://www.scintilla.org/ScintillaDoc.html#SCI_ADDTEXT>
This inserts the first *len* characters from the string *aStr* at the current position.
The current position is set at the end of the inserted text, but it is *not* scrolled into view.
Parameters:
SCI_AddText(aStr[, len, hwnd])
aStr - The string to be added to the component at current caret position.
len - Lenght of the string that will be added to the component. If 0 or blank it will be calculated
automatically using StrLen()
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
(start code)
#include ../SCI.ahk
Gui +LastFound
hwnd:=WinExist()
hSci1:=SCI_Add(hwnd, x, y, w, h)
Gui, show, w400 h300
SCI_SetWrapMode(True, hSci1)
SCI_AddText(x:="my text",StrLen(x), hSci)
return
;---------------------
#include ../SCI.ahk
Gui +LastFound
hwnd:=WinExist()
hSci1:=SCI_Add(hwnd, x, y, w, h)
Gui, show, w400 h300
SCI_SetWrapMode(True, hSci1)
; stores "This is my truncated text".
SCI_AddText("This is my truncated text, this is not added!",25)
return
;---------------------
#include ../SCI.ahk
Gui +LastFound
hwnd:=WinExist()
hSci1:=SCI_Add(hwnd, x, y, w, h)
Gui, show, w400 h300
SCI_SetWrapMode(True, hSci1)
; In this example the whole text is stored because the length is calculated internally.
SCI_AddText("This is my truncated text, this is added!")
return
(end)
*/
SCI_AddText(aStr, len=0, hwnd=0){
a_isunicode ? (VarSetCapacity(aStrA, StrPut(aStr, "CP0")), StrPut(aStr, &aStrA, "CP0"))
return SCI_sendEditor(hwnd, "SCI_ADDTEXT", len ? len : strLen(aStr), a_isunicode ? &aStrA : &aStr)
}
/* needs work
; Function: AddStyledText
; <http://www.scintilla.org/ScintillaDoc.html#SCI_ADDSTYLEDTEXT>
; This behaves just like <AddText()>, but inserts styled text.
; Parameters:
; SCI_AddText(cell[, len, hwnd])
; cell - The styled string cell to be added to the component at current caret position.
; len - lenght of the string that will be added to the component. If 0 or blank it will be calculated
; automatically using StrLen()
; hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
; Scintilla components in the same script. The wrapper will remember the last used hwnd,
; so you can specify it once and only specify it again when you want to operate on a different
; component.
; Returns:
; Zero - Nothing is returned by this function.
; Examples:
*/
; SCI_AddStyledText(cell, len=0, hwnd=0){
; a_isunicode ? (VarSetCapacity(cellA, StrPut(cell, "CP0")), StrPut(cell, &cellA, "CP0"))
; return SCI_sendEditor(hwnd, "SCI_ADDSTYLEDTEXT", len ? len : strLen(cell), a_isunicode ? &cellA : &cell)
; }
/*
Function: AppendText
<http://www.scintilla.org/ScintillaDoc.html#SCI_APPENDTEXT>
This adds the first *len* characters from the string *aStr* to the end of the document.
The current selection is not changed and the new text is *not* scrolled into view.
Parameters:
SCI_AppendText(aStr[, len, hwnd])
aStr - The string to be appended to the end of the current document on the selected component.
len - Lenght of the string that will be added to the component. If 0 or blank it will be calculated
automatically using StrLen()
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
(start code)
#include ../SCI.ahk
Gui +LastFound
hwnd:=WinExist()
hSci1:=SCI_Add(hwnd, x, y, w, h)
Gui, show, w400 h300
SCI_SetWrapMode(True, hSci1)
SCI_AppendText(x:="my text",StrLen(x), hSci)
return
;---------------------
#include ../SCI.ahk
Gui +LastFound
hwnd:=WinExist()
hSci1:=SCI_Add(hwnd, x, y, w, h)
Gui, show, w400 h300
SCI_SetWrapMode(True, hSci1)
; stores "This is my truncated text".
SCI_AppendText("This is my truncated text, this is not added!",25)
return
;---------------------
#include ../SCI.ahk
Gui +LastFound
hwnd:=WinExist()
hSci1:=SCI_Add(hwnd, x, y, w, h)
Gui, show, w400 h300
SCI_SetWrapMode(True, hSci1)
; In this example the whole text is stored because the length is calculated internally.
SCI_AppendText("This is my truncated text, this is added!")
return
(end)
*/
SCI_AppendText(aStr, len=0, hwnd=0){
a_isunicode ? (VarSetCapacity(aStrA, StrPut(aStr, "CP0")), StrPut(aStr, &aStrA, "CP0"))
return SCI_sendEditor(hwnd, "SCI_APPENDTEXT", len ? len : strLen(aStr), a_isunicode ? &aStrA : &aStr)
}
/*
Function: InsertText
<http://www.scintilla.org/ScintillaDoc.html#SCI_INSERTTEXT>
This inserts the text string at position *pos* or at the current position if pos is not specified.
If the current position is after the insertion point then it is moved along with its surrounding text
but no scrolling is performed.
Parameters:
SCI_InsertText(iStr[, pos,hwnd])
iStr - String of text to be inserted.
pos - Position where the text is to be inserted. If not specified it defaults to current caret position.
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
*/
SCI_InsertText(iStr, pos=-1,hwnd=0){
a_isunicode ? (VarSetCapacity(iStrA, StrPut(iStr, "CP0")), StrPut(iStr, &iStrA, "CP0"))
return SCI_sendEditor(hwnd, "SCI_INSERTTEXT", pos, a_isunicode ? &iStrA : &iStr)
}
/*
Function: ClearAll
<http://www.scintilla.org/ScintillaDoc.html#SCI_CLEARALL>
Unless the document is read-only, this deletes all the text.
Parameters:
SCI_ClearAll([hwnd])
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
>SCI_ClearAll(hSci)
*/
SCI_ClearAll(hwnd=0){
return SCI_sendEditor(hwnd, "SCI_CLEARALL")
}
/*
Function: ClearDocumentStyle
<http://www.scintilla.org/ScintillaDoc.html#SCI_CLEARDOCUMENTSTYLE>
When wanting to completely restyle the document, for example after choosing a lexer, the
*ClearDocumentStyle()* can be used to clear all styling information and reset the folding state.
Parameters:
SCI_ClearDocumentStyle([hwnd])
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
>SCI_ClearDocumentStyle(hSci)
*/
SCI_ClearDocumentStyle(hwnd=0){
return SCI_sendEditor(hwnd, "SCI_CLEARDOCUMENTSTYLE")
}
/* needs work TargetAsUTF8
; Function: TargetAsUTF8
; <http://www.scintilla.org/ScintillaDoc.html#SCI_TARGETASUTF8>
; This function retrieves the value of the target encoded as UTF-8, so is useful for retrieving text for use in
; other parts of the user interface, such as find and replace dialogs. The length of the encoded text in bytes
; is returned.
; Parameters:
; SCI_TargetAsUTF8(tStr[, hwnd])
; tStr - Target string that will be converted to UTF-8 encoding.
; hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
; Scintilla components in the same script. The wrapper will remember the last used hwnd,
; so you can specify it once and only specify it again when you want to operate on a different
; component.
; Returns:
; utfLen - Length of the encoded text in bytes.
; Example:
; SCI_TargetAsUTF8(tStr, hwnd=0){
; a_isunicode ? (VarSetCapacity(tStrA, StrPut(tStr, "CP0")), StrPut(tStr, &tStrA, "CP0"))
; return SCI_sendEditor(hwnd, "SCI_TARGETASUTF8", 0, a_isunicode ? &tStrA : &tStr)
; }
*/
/* needs work
; Function: EncodedFromUTF8
; <http://www.scintilla.org/ScintillaDoc.html#SCI_ENCODEDFROMUTF8>
; *EncodedFromUTF8()* converts a UTF-8 string into the document's encoding which is useful for taking the
; results of a find dialog, for example, and receiving a string of bytes that can be searched for in the
; document. Since the text can contain nul bytes, the <SetLengthForEncode()> function can be used to set the
; length that will be converted. If set to -1, the length is determined by finding a nul byte. The length of the
; converted string is returned.
; Parameters:
; SCI_EncodedFromUTF8(utf8Str, encStr[, hwnd])
; utf8Str -
; encStr -
; hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
; Scintilla components in the same script. The wrapper will remember the last used hwnd,
; so you can specify it once and only specify it again when you want to operate on a different
; component.
; Examples:
;
; SCI_EncodedFromUTF8(utf8Str, encStr, hwnd=0){
; return
; }
*/
; Group: Text Set Functions
/*
Function: SetText
<http://www.scintilla.org/ScintillaDoc.html#SCI_SETTEXT>
Replaces all the text in the document with the zero terminated text string you pass in.
Parameters:
SCI_SetText(sStr[, hwnd])
sStr - String of text to be set on the Scintilla component.
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
*/
SCI_SetText(sStr, hwnd=0){
a_isunicode ? (VarSetCapacity(sStrA, StrPut(sStr, "CP0")), StrPut(sStr, &sStrA, "CP0"))
return SCI_sendEditor(hwnd, "SCI_SETTEXT", 0, a_isunicode ? &sStrA : &sStr)
}
/*
Function: SetSavePoint
<http://www.scintilla.org/ScintillaDoc.html#SCI_SETSAVEPOINT>
This message tells Scintilla that the current state of the document is unmodified. This is usually done when
the file is saved or loaded, hence the name "save point". As Scintilla performs undo and redo operations, it
notifies the container that it has entered or left the save point with *SCN_SAVEPOINTREACHED* and
*SCN_SAVEPOINTLEFT* notification messages, allowing the container to know if the file should be considered
dirty or not.
Parameters:
SCI_SetSavePoint([hwnd])
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
*/
SCI_SetSavePoint(hwnd=0){
return SCI_sendEditor(hwnd, "SCI_SETSAVEPOINT")
}
/*
Function: SetReadOnly
<http://www.scintilla.org/ScintillaDoc.html#SCI_SETREADONLY>
These messages set and get the read-only flag for the document. If you mark a document as read only, attempts to modify the text cause the *SCN_MODIFYATTEMPTRO* notification.
Parameters:
SCI_SetReadOnly(roMode[, hwnd])
roMode - True (1) or False (0).
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
*/
SCI_SetReadOnly(roMode, hwnd=0){
return SCI_sendEditor(hwnd, "SCI_SETREADONLY", roMode)
}
/*
Function: SetStyleBits
<http://www.scintilla.org/ScintillaDoc.html#SCI_SETSTYLEBITS>
This Routine sets the number of bits in each cell to use for styling, to a maximum of 8 style bits. The remaining bits can be used as indicators. The standard setting is *SCI_SETSTYLEBITS(5)*. The number of styling bits needed by the current lexer can be found with <GetStyleBitsNeeded>.
Parameters:
SCI_SetStyleBits(bits[, hwnd])
bits -
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
*/
SCI_SetStyleBits(bits, hwnd=0){
return SCI_sendEditor(hwnd, "SCI_SETSTYLEBITS", bits)
}
/*
Function: SetLengthForEncode
http://www.scintilla.org/ScintillaDoc.html#SCI_SETLENGTHFORENCODE
<EncodedFromUTF8()> converts a UTF-8 string into the document's encoding which is useful for taking the
results of a find dialog, for example, and receiving a string of bytes that can be searched for in the
document. Since the text can contain nul bytes, the *SetLengthForEncode()* method can be used to set the
length that will be converted. If set to -1, the length is determined by finding a nul byte. The length of the
converted string is returned.
Parameters:
SCI_SetLengthForEncode(bytes[, hwnd])
bytes - Length of the string that will be converted with <EncodedFromUTF8()>
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
*/
SCI_SetLengthForEncode(bytes, hwnd=0){
return SCI_sendEditor(hwnd, "SCI_SETLENGTHFORENCODE", bytes)
}
; Group: Text Get Functions
/*
Function: GetText
<http://www.scintilla.org/ScintillaDoc.html#SCI_GETTEXT>
This returns len-1 characters of text from the start of the document plus one terminating 0 character.
To collect all the text in a document, use <GetLength()> to get the number of characters in the document
(nLen), allocate a character buffer of length nLen+1 bytes, then call *GetText*(nLen+1, vText).
If the vText argument is 0 then the length that should be allocated to store the entire document is returned.
If you then save the text, you should use <SetSavePoint()> to mark the text as unmodified.
See also: <GetSelText()>, <GetCurLine()>, <GetLine()>, <GetStyledText()>, <GetTextRange()>
Parameters:
len -
vText -
Returns:
Examples:
*/
SCI_GetText(len=0, Byref vText=0, hwnd=0){
VarSetCapacity(str, len * (a_isunicode ? 2 : 1)), cLen := SCI_sendEditor(hwnd, "SCI_GETTEXT", len, &str)
vText := StrGet(&str, "CP0")
return cLen
}
/* needs work SCI_GetLine(line, vText, hwnd=0) (LineLenght() from selection and information)
; Function: GetLine
; <http://www.scintilla.org/ScintillaDoc.html#SCI_GETLINE>
; This fills the buffer defined by text with the contents of the nominated line (lines start at 0). The buffer
; is not terminated by a 0 character. It is up to you to make sure that the buffer is long enough for the text,
; use <LineLength()> for that. The returned value is the number of characters copied to the buffer.
; The returned text includes any end of line characters. If you ask for a line number outside the range of lines
; in the document, 0 characters are copied. If the text argument is 0 then the length that should be allocated
; to store the entire line is returned.
; See also: <GetCurLine()>, <GetSelText()>, <GetTextRange()>, <GetStyledText()>, <GetText()>
;
; SCI_GetLine(line, vText, hwnd=0){
; VarSetCapacity(str, SCI_LineLength(hwnd) * (a_isunicode ? 2 : 1))
; cLen := SCI_sendEditor(hwnd, "SCI_GETLINE", len, &str)
; vText := StrGet(&str, "CP0")
; return cLen
; }
*/
/*
Function: GetReadonly
<http://www.scintilla.org/ScintillaDoc.html#SCI_GETREADONLY>
This function gets the read-only flag for the document. If you mark a document as read only, attempts to
modify the text cause the *SCN_MODIFYATTEMPTRO* notification.
Parameters:
*/
SCI_GetReadonly(){
return
}
/*
Function: GetTextRange
<http://www.scintilla.org/ScintillaDoc.html#SCI_GETTEXTRANGE>
This collects the text between the positions cpMin and cpMax and copies it to lpstrText (see struct
<SCI_TextRange>). If cpMax is -1, text is returned to the end of the document. The text is 0 terminated, so
you must supply a buffer that is at least 1 character longer than the number of characters you wish to read.
The return value is the length of the returned text not including the terminating 0.
See also: <SCI_GetSelText()>, <SCI_GetLine()>, <SCI_GetCurLine()>, <SCI_GetStyledText()>, <SCI_GetText()>
*/
SCI_GetTextRange(){
}
/*
Function: GetCharAt
<http://www.scintilla.org/ScintillaDoc.html#SCI_GETCHARAT>
This returns the character at pos in the document or 0 if pos is negative or past the end of the document.
*/
SCI_GetCharAt(){
return
}
/*
Function: GetStyleAt
<http://www.scintilla.org/ScintillaDoc.html#SCI_GETSTYLEAT>
This returns the style at pos in the document, or 0 if pos is negative or past the end of the document.
*/
SCI_GetStyleAt(){
return
}
/*
Function: GetStyledText
<http://www.scintilla.org/ScintillaDoc.html#SCI_GETSTYLEDTEXT>
This collects styled text into a buffer using two bytes for each cell, with the character at the lower address
of each pair and the style byte at the upper address. Characters between the positions cpMin and cpMax are
copied to lpstrText (see struct <SCI_TextRange>). Two 0 bytes are added to the end of the text, so the buffer
that lpstrText points at must be at least 2*(cpMax-cpMin)+2 bytes long. No check is made for sensible values
of cpMin or cpMax. Positions outside the document return character codes and style bytes of 0.
See also: <GetSelText()>, <GetLine()>, <GetCurLine()>, <GetTextRange()>, <GetText()>
*/
SCI_GetStyledText(){
return
}
/*
Function: GetStyleBits
<http://www.scintilla.org/ScintillaDoc.html#SCI_GETSTYLEBITS>
This routine reads back the number of bits in each cell to use for styling, to a maximum of 8 style bits. The
remaining bits can be used as indicators. The standard setting is *SetStyleBits(5)*. The number of styling
bits needed by the current lexer can be found with <GetStyleBitsNeeded()>.
*/
SCI_GetStyleBits(){
return
}
/* Group: Selection and information
*/
/*
Function: GetTextLength
<http://www.scintilla.org/ScintillaDoc.html#SCI_GETTEXTLENGTH>
Returns the length of the document in bytes.
Parameters:
SCI_GetTextLength([hwnd])
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns
nLen - Length of the document in bytes.
Examples
*/
SCI_GetTextLength(hwnd=0){
return SCI_sendEditor(hwnd, "SCI_GETTEXTLENGTH")
}
/*
Function: GetLength
<http://www.scintilla.org/ScintillaDoc.html#SCI_GETLENGTH>
Returns the length of the document in bytes.
Parameters:
SCI_GetLength([hwnd])
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns
nLen - Length of the document in bytes.
Examples
*/
SCI_GetLength(hwnd=0){
return SCI_sendEditor(hwnd, "SCI_GETLENGTH")
}
/* Group: Style Definition
<http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>
While the style setting messages mentioned above change the style numbers associated with text, these messages
define how those style numbers are interpreted visually. There are 256 lexer styles that can be set, numbered 0
to *STYLE_MAX* (255). Unless you use *SCI_SETSTYLEBITS* to change the number of style bits,
styles 0 to 31 are used to set the text attributes. There are also some predefined numbered styles starting at
32, The following *STYLE_** constants are defined:
- *STYLE_DEFAULT* (32) This style defines the attributes that all styles receive when the
*SCI_STYLECLEARALL* message is used.
- *STYLE_LINENUMBER* (33) This style sets the attributes of the text used to display line numbers in a line
number margin. The background colour set for this style also sets the background colour for all margins that do
not have any folding mask bits set. That is, any margin for which mask & *SC_MASK_FOLDERS* is 0. See
*SCI_SETMARGINMASKN* for more about masks.
- *STYLE_BRACELIGHT* (34) This style sets the attributes used when highlighting braces with the
*SCI_BRACEHIGHLIGHT* message and when highlighting the corresponding indentation with *SCI_SETHIGHLIGHTGUIDE*.
- *STYLE_BRACEBAD* (35) This style sets the display attributes used when marking an unmatched brace with the
*SCI_BRACEBADLIGHT* message.
- *STYLE_CONTROLCHAR* (36) This style sets the font used when drawing control characters. Only the font, size,
bold, italics, and character set attributes are used and not the colour attributes. See also:
*SCI_SETCONTROLCHARSYMBOL*.
- *STYLE_INDENTGUIDE* (37) This style sets the foreground and background colours used when drawing the
indentation guides.
- *STYLE_CALLTIP* (38) Call tips normally use the font attributes defined by *STYLE_DEFAULT*. Use of
*SCI_CALLTIPUSESTYLE* causes call tips to use this style instead. Only the font face name, font size, foreground
and background colours and character set attributes are used.
- *STYLE_LASTPREDEFINED* (39) To make it easier for client code to discover the range of styles that are
predefined, this is set to the style number of the last predefined style. This is currently set to 39 and the
last style with an identifier is 38, which reserves space for one future predefined style.
- *STYLE_MAX* (255) This is not a style but is the number of the maximum style that can be set. Styles
between *STYLE_LASTPREDEFINED* and *STYLE_MAX* would be appropriate if you used *SCI_SETSTYLEBITS* to set more
than 5 style bits.
For each style you can set the font name, size and use of bold, italic and underline, foreground and background colour and the character set. You can also choose to hide text with a given style, display all characters as upper or lower case and fill from the last character on a line to the end of the line (for embedded languages). There is also an experimental attribute to make text read-only.
It is entirely up to you how you use styles. If you want to use syntax colouring you might use style 0 for white space, style 1 for numbers, style 2 for keywords, style 3 for strings, style 4 for preprocessor, style 5 for operators, and so on.
*/
; Group: General Style Functions
/*
Function: StyleResetDefault
<http://www.scintilla.org/ScintillaDoc.html#SCI_STYLERESETDEFAULT>
This message resets STYLE_DEFAULT to its state when Scintilla was initialised.
Parameters:
SCI_StyleResetDefault([hwnd])
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
>SCI_StyleResetDefault(hSci)
*/
SCI_StyleResetDefault(hwnd=0){
return SCI_sendEditor(hwnd, "SCI_STYLERESETDEFAULT")
}
/*
Function: StyleClearAll
<http://www.scintilla.org/ScintillaDoc.html#SCI_STYLECLEARALL>
This message sets all styles to have the same attributes as STYLE_DEFAULT.
If you are setting up Scintilla for syntax coloring, it is likely that the lexical styles you set
will be very similar. One way to set the styles is to:
- Set STYLE_DEFAULT to the common features of all styles.
- Use SCI_STYLECLEARALL to copy this to all styles.
- Set the style attributes that make your lexical styles different.
Parameters:
SCI_StyleClearAll([hwnd])
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
>SCI_StyleClearAll(hSci)
*/
SCI_StyleClearAll(hwnd=0){
return SCI_sendEditor(hwnd, "SCI_STYLECLEARALL")
}
; Group: Set Style Functions
/*
Function: StyleSetFont
<http://www.scintilla.org/ScintillaDoc.html#SCI_STYLESETFONT>
These functions (plus SCI_StyleSetCharacterset) set the font attributes that are used to match
the fonts you request to those available. The fName parameter is a zero terminated string holding
the name of a font. Under Windows, only the first 32 characters of the name are used and
the name is not case sensitive. For internal caching, Scintilla tracks fonts by name
and does care about the casing of font names, so please be consistent.
Parameters:
SCI_StyleSetFont(stNumber, fName[, hwnd])
stNumber - Style Number on which to operate.
There are 256 lexer styles that can be set, numbered 0 to *STYLE_MAX* (255)
See: <http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>.
fName - Name of the font to apply.
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
(Start Code)
#include ../SCI.ahk
Gui +LastFound
hwnd:=WinExist()
hSci1:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_VISIBLE")
hSci2:=SCI_Add(hwnd, x, 290, w, h, "WS_CHILD WS_VISIBLE")
Gui, show, w400 h570
; Each component will have its own font
SCI_StyleSetFont("STYLE_DEFAULT", "Courier New", hSci1)
SCI_StyleSetFont("STYLE_DEFAULT", "Arial Black", hSci2)
return
(End)
*/
SCI_StyleSetFont(stNumber, fName, hwnd=0){
a_isunicode ? (VarSetCapacity(fNameA, StrPut(fName, "CP0")), StrPut(fName, &fNameA, "CP0"))
return SCI_sendEditor(hwnd, "SCI_STYLESETFONT", stNumber, a_isunicode ? &fNameA : &fName)
}
/*
Function: StyleSetSize
<http://www.scintilla.org/ScintillaDoc.html#SCI_STYLESETSIZE>
Parameters:
SCI_StyleSetSize(stNumber, fSize[, hwnd])
stNumber - Style Number on which to operate.
There are 256 lexer styles that can be set, numbered 0 to *STYLE_MAX* (255)
See: <http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>.
fSize - Size in points of the font to apply.
hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
Scintilla components in the same script. The wrapper will remember the last used hwnd,
so you can specify it once and only specify it again when you want to operate on a different
component.
Returns:
Zero - Nothing is returned by this function.
Examples:
(Start Code)
#include ../SCI.ahk
Gui +LastFound
hwnd:=WinExist()
hSci1:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_VISIBLE")
hSci2:=SCI_Add(hwnd, x, 290, w, h, "WS_CHILD WS_VISIBLE")