/lib/sci.ahk

http://github.com/Skiouros/Macro · AutoHotKey · 2820 lines · 490 code · 191 blank · 2139 comment · 21 complexity · 2728862b27df57b342fabef7e1f2edee MD5 · raw file

Large files are truncated click here to view the full file

  1. ; Title: Scintilla Wrapper for AHK
  2. ; Group: Helper Functions
  3. /*
  4. Function: Add
  5. Creates a Scintilla component and adds it to the Parent GUI.
  6. This function initializes the Scintilla Component.
  7. See <http://www.scintilla.org/Steps.html> for more information on how to add the component to a GUI/Control.
  8. Parameters:
  9. SCI_Add(hParent, [x, y, w, h, Styles, MsgHandler, DllPath])
  10. hParent - Hwnd of the parent control who will host the Scintilla Component
  11. x - x position for the control (default 5)
  12. y - y position for the control (default 15)
  13. w - Width of the control (default 390)
  14. h - Height of the control (default 270)
  15. Styles - List of window style variable names separated by spaces.
  16. The WS_ prefix for the variables is optional.
  17. Full list of Style names can be found at
  18. <http://msdn.microsoft.com/en-us/library/ms632600%28v=vs.85%29.aspx>.
  19. MsgHandler - Name of the function that will handle the window messages sent by the control.
  20. This is very useful for when creating personalized lexing or folding for your control.
  21. DllPath - Path to the SciLexer.dll file, if omitted the function looks for it in *a_scriptdir*.
  22. Returns:
  23. HWND - Component handle.
  24. Examples:
  25. (start code)
  26. ; Add a component with default values.
  27. ; It expects scilexer.dll to be on the script's location.
  28. ; The default values are calculated to fit optimally on a 400x300 GUI/Control
  29. Gui +LastFound
  30. hwnd:=WinExist()
  31. hSci:=SCI_Add(hwnd)
  32. Gui, show, w400 h300
  33. return
  34. ;---------------------
  35. ; Add a component with default values.
  36. ; It expects scilexer.dll to be on the script's location.
  37. ; This script also adds some styles.
  38. ; If variables "x,y,w,h" are empty the default values are used.
  39. Gui +LastFound
  40. hwnd:=WinExist()
  41. hSci:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_BORDER WS_VISIBLE")
  42. Gui, show, w400 h300
  43. return
  44. ;---------------------
  45. ; Add a component embedded in a tab with additional code for
  46. ; hiding/showing the component depending on which tab is open.
  47. ; If variables "x,w,h" are empty the default values are used.
  48. Gui, add, Tab2, HWNDhwndtab x0 y0 w400 h300 gtabHandler vtabLast,one|two
  49. hSci:=SCI_Add(hwndtab,x,25,w,h,"Child Border Visible","",a_desktop "\scilexer.dll")
  50. Gui, show, w400 h300
  51. return
  52. tabHandler: ; Tab Handler for the Scintilla Control
  53. Gui, submit, Nohide
  54. action := tabLast = "one" ? "Show" : "Hide" ; decide which action to take
  55. Control,%action%,,,ahk_id %hSci%
  56. return
  57. (end)
  58. */
  59. SCI_Add(hParent, x=5, y=15, w=390, h=270, Styles="", MsgHandler="", DllPath=""){
  60. static WS_OVERLAPPED:=0x00000000,WS_POPUP:=0x80000000,WS_CHILD:=0x40000000,WS_MINIMIZE:=0x20000000
  61. ,WS_VISIBLE:=0x10000000,WS_DISABLED:=0x08000000,WS_CLIPSIBLINGS:=0x04000000,WS_CLIPCHILDREN:=0x02000000
  62. ,WS_MAXIMIZE:=0x01000000,WS_CAPTION:=0x00C00000,WS_BORDER:=0x00800000,WS_DLGFRAME:=0x00400000
  63. ,WS_VSCROLL:=0x00200000,WS_HSCROLL:=0x00100000,WS_SYSMENU:=0x00080000,WS_THICKFRAME:=0x00040000
  64. ,WS_GROUP:=0x00020000,WS_TABSTOP:=0x00010000,WS_MINIMIZEBOX:=0x00020000,WS_MAXIMIZEBOX:=0x00010000
  65. ,WS_TILED:=0x00000000,WS_ICONIC:=0x20000000,WS_SIZEBOX:=0x00040000,WS_EX_CLIENTEDGE:=0x00000200
  66. ,GuiID:=311210,init:=False, NULL:=0
  67. if !init ; WM_NOTIFY = 0x4E
  68. old:=OnMessage(0x4E,"SCI_onNotify"),init:=True,old!="SCI_onNotify" ? SCI("oldNotify", RegisterCallback(old))
  69. if !SCIModule:=DllCall("LoadLibrary", "Str", DllPath ? DllPath : "SciLexer.dll")
  70. return debug ? A_ThisFunc "> Could not load library: " DllPath : -1
  71. hStyle := WS_CHILD | (VISIBILITY := InStr(Styles, "Hidden") ? 0 : WS_VISIBLE) | WS_TABSTOP
  72. if Styles
  73. Loop, Parse, Styles, %a_tab%%a_space%, %a_tab%%a_space%
  74. hStyle |= %a_loopfield%+0 ? %a_loopfield% : WS_%a_loopfield% ? WS_%a_loopfield% : 0
  75. hSci:=DllCall("CreateWindowEx"
  76. ,Uint ,WS_EX_CLIENTEDGE ; Ex Style
  77. ,Str ,"Scintilla" ; Class Name
  78. ,Str ,"" ; Window Name
  79. ,UInt ,hStyle ; Window Styles
  80. ,Int ,x ? x : 5 ; x
  81. ,Int ,y ? y : 15 ; y
  82. ,Int ,w ? w : 390 ; Width
  83. ,Int ,h ? h : 270 ; Height
  84. ,UInt ,hParent ; Parent HWND
  85. ,UInt ,GuiID ; (HMENU)GuiID
  86. ,UInt ,NULL ; hInstance
  87. ,UInt ,NULL, "UInt") ; lpParam
  88. ,SCI(hSci, True) ; used to check if that handle exist.
  89. ,SCI_sendEditor(hSci) ; initialize SCI_sendEditor function
  90. ,IsFunc(MsgHandler) ? SCI(hSci "MsgHandler", MsgHandler)
  91. return hSci
  92. }
  93. /* Group: Text
  94. Group of funtions that handle the text in the scintilla component.
  95. <http://www.scintilla.org/ScintillaDoc.html#TextRetrievalAndModification>
  96. Each byte in a Scintilla document is followed by an associated byte of styling information. The combination of
  97. a character byte and a style byte is called a cell. Style bytes are interpreted an index into an array of
  98. styles.
  99. Style bytes may be split into an index and a set of indicator bits but this use is discouraged and indicators
  100. should now use *SCI_INDICATORFILLRANGE* and related calls. The default split is with the index in the low 5
  101. bits and 3 high bits as indicators. This allows 32 fundamental styles, which is enough for most languages, and
  102. three independent indicators so that, for example, syntax errors, deprecated names and bad indentation could
  103. all be displayed at once. The number of bits used for styles can be altered with *SCI_SETSTYLEBITS* up to a
  104. maximum of 8 bits. The remaining bits can be used for indicators.
  105. In this document, 'character' normally refers to a byte even when multi-byte characters are used. Lengths
  106. measure the numbers of bytes, not the amount of characters in those bytes.
  107. Positions within the Scintilla document refer to a character or the gap before that character. The first
  108. character in a document is 0, the second 1 and so on. If a document contains nLen characters, the last
  109. character is numbered nLen-1. The caret exists between character positions and can be located from before the
  110. first character (0) to after the last character (nLen).
  111. There are places where the caret can not go where two character bytes make up one character. This occurs when a
  112. DBCS character from a language like Japanese is included in the document or when line ends are marked with the
  113. CP/M standard of a carriage return followed by a line feed. The *INVALID_POSITION* constant (-1) represents an
  114. invalid position within the document.
  115. All lines of text in Scintilla are the same height, and this height is calculated from the largest font in any
  116. current style. This restriction is for performance; if lines differed in height then calculations involving
  117. positioning of text would require the text to be styled first.
  118. */
  119. ; Group: General Text Functions
  120. /*
  121. Function: ReplaceSel
  122. <http://www.scintilla.org/ScintillaDoc.html#SCI_REPLACESEL>
  123. The currently selected text between the anchor and the current position is replaced by the 0 terminated text
  124. string. If the anchor and current position are the same, the text is inserted at the caret position. The caret
  125. is positioned after the inserted text and the caret is scrolled into view.
  126. Parameters:
  127. SCI_ReplaceSel(rStr[, hwnd])
  128. rStr - String of text to use for replacing the current selection.
  129. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  130. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  131. so you can specify it once and only specify it again when you want to operate on a different
  132. component.
  133. Returns:
  134. Zero - Nothing is returned by this function.
  135. Examples:
  136. >SCI_ReplaceSel("replace currently selected text with this", hSci)
  137. */
  138. SCI_ReplaceSel(rStr, hwnd=0){
  139. a_isunicode ? (VarSetCapacity(rStrA, StrPut(rStr, "CP0")), StrPut(rStr, &rStrA, "CP0"))
  140. return SCI_sendEditor(hwnd, "SCI_REPLACESEL", 0, a_isunicode ? &rStrA : &rStr)
  141. }
  142. /*
  143. Function: Allocate
  144. <http://www.scintilla.org/ScintillaDoc.html#SCI_ALLOCATE>
  145. Allocate a document buffer large enough to store a given number of bytes. The document will not be made
  146. smaller than its current contents.
  147. Parameters:
  148. SCI_Allocate(nBytes[, hwnd])
  149. nBytes - Number of bytes to allocate for the document buffer.
  150. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  151. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  152. so you can specify it once and only specify it again when you want to operate on a different
  153. component.
  154. Returns:
  155. Zero - Nothing is returned by this function.
  156. Examples:
  157. >SCI_Allocate(1024, hSci)
  158. */
  159. SCI_Allocate(nBytes, hwnd=0){
  160. return SCI_sendEditor(hwnd, "SCI_ALLOCATE", nBytes)
  161. }
  162. /*
  163. Function: AddText
  164. <http://www.scintilla.org/ScintillaDoc.html#SCI_ADDTEXT>
  165. This inserts the first *len* characters from the string *aStr* at the current position.
  166. The current position is set at the end of the inserted text, but it is *not* scrolled into view.
  167. Parameters:
  168. SCI_AddText(aStr[, len, hwnd])
  169. aStr - The string to be added to the component at current caret position.
  170. len - Lenght of the string that will be added to the component. If 0 or blank it will be calculated
  171. automatically using StrLen()
  172. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  173. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  174. so you can specify it once and only specify it again when you want to operate on a different
  175. component.
  176. Returns:
  177. Zero - Nothing is returned by this function.
  178. Examples:
  179. (start code)
  180. #include ../SCI.ahk
  181. Gui +LastFound
  182. hwnd:=WinExist()
  183. hSci1:=SCI_Add(hwnd, x, y, w, h)
  184. Gui, show, w400 h300
  185. SCI_SetWrapMode(True, hSci1)
  186. SCI_AddText(x:="my text",StrLen(x), hSci)
  187. return
  188. ;---------------------
  189. #include ../SCI.ahk
  190. Gui +LastFound
  191. hwnd:=WinExist()
  192. hSci1:=SCI_Add(hwnd, x, y, w, h)
  193. Gui, show, w400 h300
  194. SCI_SetWrapMode(True, hSci1)
  195. ; stores "This is my truncated text".
  196. SCI_AddText("This is my truncated text, this is not added!",25)
  197. return
  198. ;---------------------
  199. #include ../SCI.ahk
  200. Gui +LastFound
  201. hwnd:=WinExist()
  202. hSci1:=SCI_Add(hwnd, x, y, w, h)
  203. Gui, show, w400 h300
  204. SCI_SetWrapMode(True, hSci1)
  205. ; In this example the whole text is stored because the length is calculated internally.
  206. SCI_AddText("This is my truncated text, this is added!")
  207. return
  208. (end)
  209. */
  210. SCI_AddText(aStr, len=0, hwnd=0){
  211. a_isunicode ? (VarSetCapacity(aStrA, StrPut(aStr, "CP0")), StrPut(aStr, &aStrA, "CP0"))
  212. return SCI_sendEditor(hwnd, "SCI_ADDTEXT", len ? len : strLen(aStr), a_isunicode ? &aStrA : &aStr)
  213. }
  214. ; /* needs work
  215. ; Function: AddStyledText
  216. ; <http://www.scintilla.org/ScintillaDoc.html#SCI_ADDSTYLEDTEXT>
  217. ; This behaves just like <AddText()>, but inserts styled text.
  218. ; Parameters:
  219. ; SCI_AddText(cell[, len, hwnd])
  220. ; cell - The styled string cell to be added to the component at current caret position.
  221. ; len - lenght of the string that will be added to the component. If 0 or blank it will be calculated
  222. ; automatically using StrLen()
  223. ; hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  224. ; Scintilla components in the same script. The wrapper will remember the last used hwnd,
  225. ; so you can specify it once and only specify it again when you want to operate on a different
  226. ; component.
  227. ; Returns:
  228. ; Zero - Nothing is returned by this function.
  229. ; Examples:
  230. ; */
  231. ; SCI_AddStyledText(cell, len=0, hwnd=0){
  232. ; a_isunicode ? (VarSetCapacity(cellA, StrPut(cell, "CP0")), StrPut(cell, &cellA, "CP0"))
  233. ; return SCI_sendEditor(hwnd, "SCI_ADDSTYLEDTEXT", len ? len : strLen(cell), a_isunicode ? &cellA : &cell)
  234. ; }
  235. /*
  236. Function: AppendText
  237. <http://www.scintilla.org/ScintillaDoc.html#SCI_APPENDTEXT>
  238. This adds the first *len* characters from the string *aStr* to the end of the document.
  239. The current selection is not changed and the new text is *not* scrolled into view.
  240. Parameters:
  241. SCI_AppendText(aStr[, len, hwnd])
  242. aStr - The string to be appended to the end of the current document on the selected component.
  243. len - Lenght of the string that will be added to the component. If 0 or blank it will be calculated
  244. automatically using StrLen()
  245. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  246. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  247. so you can specify it once and only specify it again when you want to operate on a different
  248. component.
  249. Returns:
  250. Zero - Nothing is returned by this function.
  251. Examples:
  252. (start code)
  253. #include ../SCI.ahk
  254. Gui +LastFound
  255. hwnd:=WinExist()
  256. hSci1:=SCI_Add(hwnd, x, y, w, h)
  257. Gui, show, w400 h300
  258. SCI_SetWrapMode(True, hSci1)
  259. SCI_AppendText(x:="my text",StrLen(x), hSci)
  260. return
  261. ;---------------------
  262. #include ../SCI.ahk
  263. Gui +LastFound
  264. hwnd:=WinExist()
  265. hSci1:=SCI_Add(hwnd, x, y, w, h)
  266. Gui, show, w400 h300
  267. SCI_SetWrapMode(True, hSci1)
  268. ; stores "This is my truncated text".
  269. SCI_AppendText("This is my truncated text, this is not added!",25)
  270. return
  271. ;---------------------
  272. #include ../SCI.ahk
  273. Gui +LastFound
  274. hwnd:=WinExist()
  275. hSci1:=SCI_Add(hwnd, x, y, w, h)
  276. Gui, show, w400 h300
  277. SCI_SetWrapMode(True, hSci1)
  278. ; In this example the whole text is stored because the length is calculated internally.
  279. SCI_AppendText("This is my truncated text, this is added!")
  280. return
  281. (end)
  282. */
  283. SCI_AppendText(aStr, len=0, hwnd=0){
  284. a_isunicode ? (VarSetCapacity(aStrA, StrPut(aStr, "CP0")), StrPut(aStr, &aStrA, "CP0"))
  285. return SCI_sendEditor(hwnd, "SCI_APPENDTEXT", len ? len : strLen(aStr), a_isunicode ? &aStrA : &aStr)
  286. }
  287. /*
  288. Function: InsertText
  289. <http://www.scintilla.org/ScintillaDoc.html#SCI_INSERTTEXT>
  290. This inserts the text string at position *pos* or at the current position if pos is not specified.
  291. If the current position is after the insertion point then it is moved along with its surrounding text
  292. but no scrolling is performed.
  293. Parameters:
  294. SCI_InsertText(iStr[, pos,hwnd])
  295. iStr - String of text to be inserted.
  296. pos - Position where the text is to be inserted. If not specified it defaults to current caret position.
  297. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  298. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  299. so you can specify it once and only specify it again when you want to operate on a different
  300. component.
  301. Returns:
  302. Zero - Nothing is returned by this function.
  303. Examples:
  304. */
  305. SCI_InsertText(iStr, pos=-1,hwnd=0){
  306. a_isunicode ? (VarSetCapacity(iStrA, StrPut(iStr, "CP0")), StrPut(iStr, &iStrA, "CP0"))
  307. return SCI_sendEditor(hwnd, "SCI_INSERTTEXT", pos, a_isunicode ? &iStrA : &iStr)
  308. }
  309. /*
  310. Function: ClearAll
  311. <http://www.scintilla.org/ScintillaDoc.html#SCI_CLEARALL>
  312. Unless the document is read-only, this deletes all the text.
  313. Parameters:
  314. SCI_ClearAll([hwnd])
  315. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  316. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  317. so you can specify it once and only specify it again when you want to operate on a different
  318. component.
  319. Returns:
  320. Zero - Nothing is returned by this function.
  321. Examples:
  322. >SCI_ClearAll(hSci)
  323. */
  324. SCI_ClearAll(hwnd=0){
  325. return SCI_sendEditor(hwnd, "SCI_CLEARALL")
  326. }
  327. /*
  328. Function: ClearDocumentStyle
  329. <http://www.scintilla.org/ScintillaDoc.html#SCI_CLEARDOCUMENTSTYLE>
  330. When wanting to completely restyle the document, for example after choosing a lexer, the
  331. *ClearDocumentStyle()* can be used to clear all styling information and reset the folding state.
  332. Parameters:
  333. SCI_ClearDocumentStyle([hwnd])
  334. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  335. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  336. so you can specify it once and only specify it again when you want to operate on a different
  337. component.
  338. Returns:
  339. Zero - Nothing is returned by this function.
  340. Examples:
  341. >SCI_ClearDocumentStyle(hSci)
  342. */
  343. SCI_ClearDocumentStyle(hwnd=0){
  344. return SCI_sendEditor(hwnd, "SCI_CLEARDOCUMENTSTYLE")
  345. }
  346. ; /* needs work
  347. ; Function: TargetAsUTF8
  348. ; <http://www.scintilla.org/ScintillaDoc.html#SCI_TARGETASUTF8>
  349. ; This function retrieves the value of the target encoded as UTF-8, so is useful for retrieving text for use in
  350. ; other parts of the user interface, such as find and replace dialogs. The length of the encoded text in bytes
  351. ; is returned.
  352. ; Parameters:
  353. ; SCI_TargetAsUTF8(tStr[, hwnd])
  354. ; tStr - Target string that will be converted to UTF-8 encoding.
  355. ; hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  356. ; Scintilla components in the same script. The wrapper will remember the last used hwnd,
  357. ; so you can specify it once and only specify it again when you want to operate on a different
  358. ; component.
  359. ; Returns:
  360. ; utfLen - Length of the encoded text in bytes.
  361. ; Example:
  362. ; */
  363. ; SCI_TargetAsUTF8(tStr, hwnd=0){
  364. ; a_isunicode ? (VarSetCapacity(tStrA, StrPut(tStr, "CP0")), StrPut(tStr, &tStrA, "CP0"))
  365. ; return SCI_sendEditor(hwnd, "SCI_TARGETASUTF8", 0, a_isunicode ? &tStrA : &tStr)
  366. ; }
  367. ; /* needs work
  368. ; Function: EncodedFromUTF8
  369. ; <http://www.scintilla.org/ScintillaDoc.html#SCI_ENCODEDFROMUTF8>
  370. ; *EncodedFromUTF8()* converts a UTF-8 string into the document's encoding which is useful for taking the
  371. ; results of a find dialog, for example, and receiving a string of bytes that can be searched for in the
  372. ; document. Since the text can contain nul bytes, the <SetLengthForEncode()> function can be used to set the
  373. ; length that will be converted. If set to -1, the length is determined by finding a nul byte. The length of the
  374. ; converted string is returned.
  375. ; Parameters:
  376. ; SCI_EncodedFromUTF8(utf8Str, encStr[, hwnd])
  377. ; utf8Str -
  378. ; encStr -
  379. ; hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  380. ; Scintilla components in the same script. The wrapper will remember the last used hwnd,
  381. ; so you can specify it once and only specify it again when you want to operate on a different
  382. ; component.
  383. ; Examples:
  384. ; */
  385. ; SCI_EncodedFromUTF8(utf8Str, encStr, hwnd=0){
  386. ; return
  387. ; }
  388. ; Group: Text Set Functions
  389. /*
  390. Function: SetText
  391. <http://www.scintilla.org/ScintillaDoc.html#SCI_SETTEXT>
  392. Replaces all the text in the document with the zero terminated text string you pass in.
  393. Parameters:
  394. SCI_SetText(sStr[, hwnd])
  395. sStr - String of text to be set on the Scintilla component.
  396. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  397. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  398. so you can specify it once and only specify it again when you want to operate on a different
  399. component.
  400. Returns:
  401. Zero - Nothing is returned by this function.
  402. Examples:
  403. */
  404. SCI_SetText(sStr, hwnd=0){
  405. a_isunicode ? (VarSetCapacity(sStrA, StrPut(sStr, "CP0")), StrPut(sStr, &sStrA, "CP0"))
  406. return SCI_sendEditor(hwnd, "SCI_SETTEXT", 0, a_isunicode ? &sStrA : &sStr)
  407. }
  408. /*
  409. Function: SetSavePoint
  410. <http://www.scintilla.org/ScintillaDoc.html#SCI_SETSAVEPOINT>
  411. This message tells Scintilla that the current state of the document is unmodified. This is usually done when
  412. the file is saved or loaded, hence the name "save point". As Scintilla performs undo and redo operations, it
  413. notifies the container that it has entered or left the save point with *SCN_SAVEPOINTREACHED* and
  414. *SCN_SAVEPOINTLEFT* notification messages, allowing the container to know if the file should be considered
  415. dirty or not.
  416. Parameters:
  417. SCI_SetSavePoint([hwnd])
  418. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  419. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  420. so you can specify it once and only specify it again when you want to operate on a different
  421. component.
  422. Returns:
  423. Zero - Nothing is returned by this function.
  424. Examples:
  425. */
  426. SCI_SetSavePoint(hwnd=0){
  427. return SCI_sendEditor(hwnd, "SCI_SETSAVEPOINT")
  428. }
  429. /*
  430. Function: SetReadOnly
  431. <http://www.scintilla.org/ScintillaDoc.html#SCI_SETREADONLY>
  432. 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.
  433. Parameters:
  434. SCI_SetReadOnly(roMode[, hwnd])
  435. roMode - True (1) or False (0).
  436. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  437. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  438. so you can specify it once and only specify it again when you want to operate on a different
  439. component.
  440. Returns:
  441. Zero - Nothing is returned by this function.
  442. Examples:
  443. */
  444. SCI_SetReadOnly(roMode, hwnd=0){
  445. return SCI_sendEditor(hwnd, "SCI_SETREADONLY", roMode)
  446. }
  447. /*
  448. Function: SetStyleBits
  449. <http://www.scintilla.org/ScintillaDoc.html#SCI_SETSTYLEBITS>
  450. 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>.
  451. Parameters:
  452. SCI_SetStyleBits(bits[, hwnd])
  453. bits -
  454. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  455. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  456. so you can specify it once and only specify it again when you want to operate on a different
  457. component.
  458. Returns:
  459. Zero - Nothing is returned by this function.
  460. Examples:
  461. */
  462. SCI_SetStyleBits(bits, hwnd=0){
  463. return SCI_sendEditor(hwnd, "SCI_SETSTYLEBITS", bits)
  464. }
  465. /*
  466. Function: SetLengthForEncode
  467. http://www.scintilla.org/ScintillaDoc.html#SCI_SETLENGTHFORENCODE
  468. <EncodedFromUTF8()> converts a UTF-8 string into the document's encoding which is useful for taking the
  469. results of a find dialog, for example, and receiving a string of bytes that can be searched for in the
  470. document. Since the text can contain nul bytes, the *SetLengthForEncode()* method can be used to set the
  471. length that will be converted. If set to -1, the length is determined by finding a nul byte. The length of the
  472. converted string is returned.
  473. Parameters:
  474. SCI_SetLengthForEncode(bytes[, hwnd])
  475. bytes - Length of the string that will be converted with <EncodedFromUTF8()>
  476. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  477. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  478. so you can specify it once and only specify it again when you want to operate on a different
  479. component.
  480. Returns:
  481. Zero - Nothing is returned by this function.
  482. Examples:
  483. */
  484. SCI_SetLengthForEncode(bytes, hwnd=0){
  485. return SCI_sendEditor(hwnd, "SCI_SETLENGTHFORENCODE", bytes)
  486. }
  487. ; Group: Text Get Functions
  488. /*
  489. Function: GetText
  490. <http://www.scintilla.org/ScintillaDoc.html#SCI_GETTEXT>
  491. This returns len-1 characters of text from the start of the document plus one terminating 0 character.
  492. To collect all the text in a document, use <GetLength()> to get the number of characters in the document
  493. (nLen), allocate a character buffer of length nLen+1 bytes, then call *GetText*(nLen+1, vText).
  494. If the vText argument is 0 then the length that should be allocated to store the entire document is returned.
  495. If you then save the text, you should use <SetSavePoint()> to mark the text as unmodified.
  496. See also: <GetSelText()>, <GetCurLine()>, <GetLine()>, <GetStyledText()>, <GetTextRange()>
  497. Parameters:
  498. len -
  499. vText -
  500. Returns:
  501. Examples:
  502. */
  503. SCI_GetText(len=0, Byref vText=0, hwnd=0){
  504. VarSetCapacity(str, len * (a_isunicode ? 2 : 1)), cLen := SCI_sendEditor(hwnd, "SCI_GETTEXT", len, &str)
  505. vText := StrGet(&str, "CP0")
  506. return cLen
  507. }
  508. ; /* needs work (LineLenght() from selection and information)
  509. ; Function: GetLine
  510. ; <http://www.scintilla.org/ScintillaDoc.html#SCI_GETLINE>
  511. ; This fills the buffer defined by text with the contents of the nominated line (lines start at 0). The buffer
  512. ; is not terminated by a 0 character. It is up to you to make sure that the buffer is long enough for the text,
  513. ; use <LineLength()> for that. The returned value is the number of characters copied to the buffer.
  514. ; The returned text includes any end of line characters. If you ask for a line number outside the range of lines
  515. ; in the document, 0 characters are copied. If the text argument is 0 then the length that should be allocated
  516. ; to store the entire line is returned.
  517. ; See also: <GetCurLine()>, <GetSelText()>, <GetTextRange()>, <GetStyledText()>, <GetText()>
  518. ; */
  519. ; SCI_GetLine(line, vText, hwnd=0){
  520. ; VarSetCapacity(str, SCI_LineLength(hwnd) * (a_isunicode ? 2 : 1))
  521. ; cLen := SCI_sendEditor(hwnd, "SCI_GETLINE", len, &str)
  522. ; vText := StrGet(&str, "CP0")
  523. ; return cLen
  524. ; }
  525. /*
  526. Function: GetReadonly
  527. <http://www.scintilla.org/ScintillaDoc.html#SCI_GETREADONLY>
  528. This function gets the read-only flag for the document. If you mark a document as read only, attempts to
  529. modify the text cause the *SCN_MODIFYATTEMPTRO* notification.
  530. Parameters:
  531. */
  532. SCI_GetReadonly(){
  533. return
  534. }
  535. /*
  536. Function: GetTextRange
  537. <http://www.scintilla.org/ScintillaDoc.html#SCI_GETTEXTRANGE>
  538. This collects the text between the positions cpMin and cpMax and copies it to lpstrText (see struct
  539. <SCI_TextRange>). If cpMax is -1, text is returned to the end of the document. The text is 0 terminated, so
  540. you must supply a buffer that is at least 1 character longer than the number of characters you wish to read.
  541. The return value is the length of the returned text not including the terminating 0.
  542. See also: <SCI_GetSelText()>, <SCI_GetLine()>, <SCI_GetCurLine()>, <SCI_GetStyledText()>, <SCI_GetText()>
  543. */
  544. SCI_GetTextRange(){
  545. }
  546. /*
  547. Function: GetCharAt
  548. <http://www.scintilla.org/ScintillaDoc.html#SCI_GETCHARAT>
  549. This returns the character at pos in the document or 0 if pos is negative or past the end of the document.
  550. */
  551. SCI_GetCharAt(){
  552. return
  553. }
  554. /*
  555. Function: GetStyleAt
  556. <http://www.scintilla.org/ScintillaDoc.html#SCI_GETSTYLEAT>
  557. This returns the style at pos in the document, or 0 if pos is negative or past the end of the document.
  558. */
  559. SCI_GetStyleAt(){
  560. return
  561. }
  562. /*
  563. Function: GetStyledText
  564. <http://www.scintilla.org/ScintillaDoc.html#SCI_GETSTYLEDTEXT>
  565. This collects styled text into a buffer using two bytes for each cell, with the character at the lower address
  566. of each pair and the style byte at the upper address. Characters between the positions cpMin and cpMax are
  567. copied to lpstrText (see struct <SCI_TextRange>). Two 0 bytes are added to the end of the text, so the buffer
  568. that lpstrText points at must be at least 2*(cpMax-cpMin)+2 bytes long. No check is made for sensible values
  569. of cpMin or cpMax. Positions outside the document return character codes and style bytes of 0.
  570. See also: <GetSelText()>, <GetLine()>, <GetCurLine()>, <GetTextRange()>, <GetText()>
  571. */
  572. SCI_GetStyledText(){
  573. return
  574. }
  575. /*
  576. Function: GetStyleBits
  577. <http://www.scintilla.org/ScintillaDoc.html#SCI_GETSTYLEBITS>
  578. This routine reads back the number of bits in each cell to use for styling, to a maximum of 8 style bits. The
  579. remaining bits can be used as indicators. The standard setting is *SetStyleBits(5)*. The number of styling
  580. bits needed by the current lexer can be found with <GetStyleBitsNeeded()>.
  581. */
  582. SCI_GetStyleBits(){
  583. return
  584. }
  585. /* Group: Selection and information
  586. */
  587. /*
  588. Function: GetTextLength
  589. <http://www.scintilla.org/ScintillaDoc.html#SCI_GETTEXTLENGTH>
  590. Returns the length of the document in bytes.
  591. Parameters:
  592. SCI_GetTextLength([hwnd])
  593. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  594. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  595. so you can specify it once and only specify it again when you want to operate on a different
  596. component.
  597. Returns
  598. nLen - Length of the document in bytes.
  599. Examples
  600. */
  601. SCI_GetTextLength(hwnd=0){
  602. return SCI_sendEditor(hwnd, "SCI_GETTEXTLENGTH")
  603. }
  604. /*
  605. Function: GetLength
  606. <http://www.scintilla.org/ScintillaDoc.html#SCI_GETLENGTH>
  607. Returns the length of the document in bytes.
  608. Parameters:
  609. SCI_GetLength([hwnd])
  610. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  611. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  612. so you can specify it once and only specify it again when you want to operate on a different
  613. component.
  614. Returns
  615. nLen - Length of the document in bytes.
  616. Examples
  617. */
  618. SCI_GetLength(hwnd=0){
  619. return SCI_sendEditor(hwnd, "SCI_GETLENGTH")
  620. }
  621. /* Group: Style Definition
  622. <http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>
  623. While the style setting messages mentioned above change the style numbers associated with text, these messages
  624. define how those style numbers are interpreted visually. There are 256 lexer styles that can be set, numbered 0
  625. to *STYLE_MAX* (255). Unless you use *SCI_SETSTYLEBITS* to change the number of style bits,
  626. styles 0 to 31 are used to set the text attributes. There are also some predefined numbered styles starting at
  627. 32, The following *STYLE_** constants are defined:
  628. - *STYLE_DEFAULT* (32) This style defines the attributes that all styles receive when the
  629. *SCI_STYLECLEARALL* message is used.
  630. - *STYLE_LINENUMBER* (33) This style sets the attributes of the text used to display line numbers in a line
  631. number margin. The background colour set for this style also sets the background colour for all margins that do
  632. not have any folding mask bits set. That is, any margin for which mask & *SC_MASK_FOLDERS* is 0. See
  633. *SCI_SETMARGINMASKN* for more about masks.
  634. - *STYLE_BRACELIGHT* (34) This style sets the attributes used when highlighting braces with the
  635. *SCI_BRACEHIGHLIGHT* message and when highlighting the corresponding indentation with *SCI_SETHIGHLIGHTGUIDE*.
  636. - *STYLE_BRACEBAD* (35) This style sets the display attributes used when marking an unmatched brace with the
  637. *SCI_BRACEBADLIGHT* message.
  638. - *STYLE_CONTROLCHAR* (36) This style sets the font used when drawing control characters. Only the font, size,
  639. bold, italics, and character set attributes are used and not the colour attributes. See also:
  640. *SCI_SETCONTROLCHARSYMBOL*.
  641. - *STYLE_INDENTGUIDE* (37) This style sets the foreground and background colours used when drawing the
  642. indentation guides.
  643. - *STYLE_CALLTIP* (38) Call tips normally use the font attributes defined by *STYLE_DEFAULT*. Use of
  644. *SCI_CALLTIPUSESTYLE* causes call tips to use this style instead. Only the font face name, font size, foreground
  645. and background colours and character set attributes are used.
  646. - *STYLE_LASTPREDEFINED* (39) To make it easier for client code to discover the range of styles that are
  647. predefined, this is set to the style number of the last predefined style. This is currently set to 39 and the
  648. last style with an identifier is 38, which reserves space for one future predefined style.
  649. - *STYLE_MAX* (255) This is not a style but is the number of the maximum style that can be set. Styles
  650. between *STYLE_LASTPREDEFINED* and *STYLE_MAX* would be appropriate if you used *SCI_SETSTYLEBITS* to set more
  651. than 5 style bits.
  652. 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.
  653. 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.
  654. */
  655. ; Group: General Style Functions
  656. /*
  657. Function: StyleResetDefault
  658. <http://www.scintilla.org/ScintillaDoc.html#SCI_STYLERESETDEFAULT>
  659. This message resets STYLE_DEFAULT to its state when Scintilla was initialised.
  660. Parameters:
  661. SCI_StyleResetDefault([hwnd])
  662. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  663. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  664. so you can specify it once and only specify it again when you want to operate on a different
  665. component.
  666. Returns:
  667. Zero - Nothing is returned by this function.
  668. Examples:
  669. >SCI_StyleResetDefault(hSci)
  670. */
  671. SCI_StyleResetDefault(hwnd=0){
  672. return SCI_sendEditor(hwnd, "SCI_STYLERESETDEFAULT")
  673. }
  674. /*
  675. Function: StyleClearAll
  676. <http://www.scintilla.org/ScintillaDoc.html#SCI_STYLECLEARALL>
  677. This message sets all styles to have the same attributes as STYLE_DEFAULT.
  678. If you are setting up Scintilla for syntax coloring, it is likely that the lexical styles you set
  679. will be very similar. One way to set the styles is to:
  680. - Set STYLE_DEFAULT to the common features of all styles.
  681. - Use SCI_STYLECLEARALL to copy this to all styles.
  682. - Set the style attributes that make your lexical styles different.
  683. Parameters:
  684. SCI_StyleClearAll([hwnd])
  685. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  686. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  687. so you can specify it once and only specify it again when you want to operate on a different
  688. component.
  689. Returns:
  690. Zero - Nothing is returned by this function.
  691. Examples:
  692. >SCI_StyleClearAll(hSci)
  693. */
  694. SCI_StyleClearAll(hwnd=0){
  695. return SCI_sendEditor(hwnd, "SCI_STYLECLEARALL")
  696. }
  697. ; Group: Set Style Functions
  698. /*
  699. Function: StyleSetFont
  700. <http://www.scintilla.org/ScintillaDoc.html#SCI_STYLESETFONT>
  701. These functions (plus SCI_StyleSetCharacterset) set the font attributes that are used to match
  702. the fonts you request to those available. The fName parameter is a zero terminated string holding
  703. the name of a font. Under Windows, only the first 32 characters of the name are used and
  704. the name is not case sensitive. For internal caching, Scintilla tracks fonts by name
  705. and does care about the casing of font names, so please be consistent.
  706. Parameters:
  707. SCI_StyleSetFont(stNumber, fName[, hwnd])
  708. stNumber - Style Number on which to operate.
  709. There are 256 lexer styles that can be set, numbered 0 to *STYLE_MAX* (255)
  710. See: <http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>.
  711. fName - Name of the font to apply.
  712. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  713. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  714. so you can specify it once and only specify it again when you want to operate on a different
  715. component.
  716. Returns:
  717. Zero - Nothing is returned by this function.
  718. Examples:
  719. (Start Code)
  720. #include ../SCI.ahk
  721. Gui +LastFound
  722. hwnd:=WinExist()
  723. hSci1:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_VISIBLE")
  724. hSci2:=SCI_Add(hwnd, x, 290, w, h, "WS_CHILD WS_VISIBLE")
  725. Gui, show, w400 h570
  726. ; Each component will have its own font
  727. SCI_StyleSetFont("STYLE_DEFAULT", "Courier New", hSci1)
  728. SCI_StyleSetFont("STYLE_DEFAULT", "Arial Black", hSci2)
  729. return
  730. (End)
  731. */
  732. SCI_StyleSetFont(stNumber, fName, hwnd=0){
  733. a_isunicode ? (VarSetCapacity(fNameA, StrPut(fName, "CP0")), StrPut(fName, &fNameA, "CP0"))
  734. return SCI_sendEditor(hwnd, "SCI_STYLESETFONT", stNumber, a_isunicode ? &fNameA : &fName)
  735. }
  736. /*
  737. Function: StyleSetSize
  738. <http://www.scintilla.org/ScintillaDoc.html#SCI_STYLESETSIZE>
  739. Parameters:
  740. SCI_StyleSetSize(stNumber, fSize[, hwnd])
  741. stNumber - Style Number on which to operate.
  742. There are 256 lexer styles that can be set, numbered 0 to *STYLE_MAX* (255)
  743. See: <http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>.
  744. fSize - Size in points of the font to apply.
  745. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  746. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  747. so you can specify it once and only specify it again when you want to operate on a different
  748. component.
  749. Returns:
  750. Zero - Nothing is returned by this function.
  751. Examples:
  752. (Start Code)
  753. #include ../SCI.ahk
  754. Gui +LastFound
  755. hwnd:=WinExist()
  756. hSci1:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_VISIBLE")
  757. hSci2:=SCI_Add(hwnd, x, 290, w, h, "WS_CHILD WS_VISIBLE")
  758. Gui, show, w400 h570
  759. ; Each component will have its own font size
  760. SCI_StyleSetSize("STYLE_DEFAULT", 12, hSci1)
  761. SCI_StyleSetSize("STYLE_DEFAULT", 32, hSci2)
  762. return
  763. (End)
  764. */
  765. SCI_StyleSetSize(stNumber, fSize, hwnd=0){
  766. return SCI_sendEditor(hwnd, "SCI_STYLESETSIZE", stNumber, fSize)
  767. }
  768. /*
  769. Function: StyleSetBold
  770. <http://www.scintilla.org/ScintillaDoc.html#SCI_STYLESETBOLD>
  771. Parameters:
  772. SCI_StyleSetBold(stNumber, bMode[, hwnd])
  773. stNumber - Style Number on which to operate.
  774. There are 256 lexer styles that can be set, numbered 0 to *STYLE_MAX* (255)
  775. See: <http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>.
  776. bMode - True (1) or False (0).
  777. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  778. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  779. so you can specify it once and only specify it again when you want to operate on a different
  780. component.
  781. Returns:
  782. Zero - Nothing is returned by this function.
  783. Examples:
  784. (Start Code)
  785. #include ../SCI.ahk
  786. Gui +LastFound
  787. hwnd:=WinExist()
  788. hSci1:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_VISIBLE")
  789. hSci2:=SCI_Add(hwnd, x, 290, w, h, "WS_CHILD WS_VISIBLE")
  790. Gui, show, w400 h570
  791. ; Each component will have its own bold status
  792. SCI_StyleSetBold("STYLE_DEFAULT", True, hSci1)
  793. SCI_StyleSetBold("STYLE_DEFAULT", False, hSci2)
  794. return
  795. (End)
  796. */
  797. SCI_StyleSetBold(stNumber, bMode, hwnd=0){
  798. return SCI_sendEditor(hwnd, "SCI_STYLESETBOLD", stNumber, bMode)
  799. }
  800. /*
  801. Function: StyleSetItalic
  802. <http://www.scintilla.org/ScintillaDoc.html#SCI_STYLESETITALIC>
  803. Parameters:
  804. SCI_StyleSetItalic(stNumber, iMode[, hwnd])
  805. stNumber - Style Number on which to operate.
  806. There are 256 lexer styles that can be set, numbered 0 to *STYLE_MAX* (255)
  807. See: <http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>.
  808. iMode - True (1) or False (0).
  809. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  810. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  811. so you can specify it once and only specify it again when you want to operate on a different
  812. component.
  813. Returns:
  814. Zero - Nothing is returned by this function.
  815. Examples:
  816. (Start Code)
  817. #include ../SCI.ahk
  818. Gui +LastFound
  819. hwnd:=WinExist()
  820. hSci1:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_VISIBLE")
  821. hSci2:=SCI_Add(hwnd, x, 290, w, h, "WS_CHILD WS_VISIBLE")
  822. Gui, show, w400 h570
  823. ; Each component will have its own bold status
  824. SCI_StyleSetItalic("STYLE_DEFAULT", True, hSci1)
  825. SCI_StyleSetItalic("STYLE_DEFAULT", False, hSci2)
  826. return
  827. (End)
  828. */
  829. SCI_StyleSetItalic(stNumber, iMode, hwnd=0){
  830. return SCI_sendEditor(hwnd, "SCI_STYLESETITALIC", stNumber, iMode)
  831. }
  832. /*
  833. Function: StyleSetUnderline
  834. <http://www.scintilla.org/ScintillaDoc.html#SCI_STYLESETUNDERLINE>
  835. Parameters:
  836. SCI_StyleSetUnderline(stNumber, uMode[, hwnd])
  837. stNumber - Style Number on which to operate.
  838. There are 256 lexer styles that can be set, numbered 0 to *STYLE_MAX* (255)
  839. See: <http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>.
  840. uMode - True (1) or False (0).
  841. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  842. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  843. so you can specify it once and only specify it again when you want to operate on a different
  844. component.
  845. Returns:
  846. Zero - Nothing is returned by this function.
  847. Note:
  848. - If you set the underline option for the *STYLE_DEFAULT* style
  849. you *have* to call <StyleClearAll()> for the changes to take effect.
  850. Examples:
  851. (Start Code)
  852. #include ../SCI.ahk
  853. Gui +LastFound
  854. hwnd:=WinExist()
  855. hSci1:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_VISIBLE")
  856. hSci2:=SCI_Add(hwnd, x, 290, w, h, "WS_CHILD WS_VISIBLE")
  857. Gui, show, w400 h570
  858. ; Each component will have its own underline status
  859. SCI_StyleSetUnderline("STYLE_DEFAULT", True, hSci1)
  860. SCI_StyleClearAll() ; the last hwnd is remembered by the wrapper, so no need to put it here.
  861. SCI_StyleSetUnderline("STYLE_DEFAULT", False, hSci2)
  862. SCI_StyleClearAll() ; the last hwnd is remembered by the wrapper, so no need to put it here.
  863. return
  864. (End)
  865. */
  866. SCI_StyleSetUnderline(stNumber, uMode, hwnd=0){
  867. return SCI_sendEditor(hwnd, "SCI_STYLESETUNDERLINE", stNumber, uMode)
  868. }
  869. /*
  870. Function: StyleSetFore
  871. <http://www.scintilla.org/ScintillaDoc.html#SCI_STYLESETFORE>
  872. Sets the foreground color of the specified style number.
  873. Parameters:
  874. SCI_StyleSetFore(stNumber, r, [g, b, hwnd])
  875. stNumber - Style Number on which to operate.
  876. There are 256 lexer styles that can be set, numbered 0 to *STYLE_MAX* (255)
  877. See: <http://www.scintilla.org/ScintillaDoc.html#StyleDefinition>.
  878. r,g,b - Colors are set using the RGB format (Red, Green, Blue). The intensity of each color
  879. is set in the range 0 to 255.
  880. - *Note 1:* If you set all intensities to 255, the color is white.
  881. If you set all intensities to 0, the color is black.
  882. When you set a color, you are making a request.
  883. What you will get depends on the capabilities of the system and the current screen mode.
  884. - *Note 2:* If you omit *g* and *b* you can specify the hex value of the color as
  885. well as one of the many predefined names available.
  886. You can take a look at the available color names with their hex values here:
  887. <http://www.w3schools.com/html/html_colornames.asp>.
  888. - *Note 3:* the parameter *g* can be used to specify the hwnd of the component you want
  889. to control, only if you are using *r* to specify a hex value or a color name.
  890. See the examples below for more information.
  891. hwnd - The hwnd of the control that you want to operate on. Useful for when you have more than 1
  892. Scintilla components in the same script. The wrapper will remember the last used hwnd,
  893. so you can specify it once and only specify it again when you want to operate on a different
  894. component.
  895. Note:
  896. - If you change the color of the *STYLE_DEFAULT* style
  897. you *have* to call <StyleClearAll()> for the changes to take effect.
  898. This is not true for setting the background color though.
  899. Returns:
  900. Zero - Nothing is returned by this function.
  901. Examples:
  902. (Start Code)
  903. ; This all mean the same
  904. SCI_StyleSetFore("STYLE_DEFAULT", 0xFF0000, hSci) ; using the parameter g to specify the hwnd.
  905. SCI_StyleSetFore("STYLE_DEFAULT", "red", hSci)
  906. SCI_StyleSetFore("STYLE_DEFAULT", 255,0,0, hSci) ; using the last parameter to specify the hwnd.
  907. ; Remember to always call SCI_StyleClearAll()
  908. ; if you are setting the foreground color of the STYLE_DEFAULT style
  909. SCI_StyleClearAll()
  910. ;---------------------
  911. #include ../SCI.ahk
  912. Gui +LastFound
  913. hwnd:=WinExist()
  914. hSci1:=SCI_Add(hwnd, x, y, w, h, "WS_CHILD WS_VISIBLE")
  915. hSci2:=SCI_Add(hwnd, x, 290, w, h, "WS_CHILD WS_VISIBLE")
  916. Gui, show, w400 h570
  917. SCI_StyleSetFore("STYLE_DEFAULT", 0xFF0000, hSci1)
  918. SCI_StyleClearAll() ; the last hwnd is remembered by the wrapper, so no need to put it here.
  919. SCI_StyleSetFore("STYLE_DEFAULT", "blue", hSci2)
  920. SCI_StyleClearAll() ; the last hwnd is remembered by the wrapper, so no need to put it here.
  921. return
  922. (End)
  923. */
  924. SCI_StyleSetFore(stNumber, r, g=0, b=0, hwnd=0){