So, using the answer in this thread: https://stackoverflow.com/questions/92565/how-can-i-highlight-text-in-scintilla
I decided to try to make the same for the maxScript Editor.
Here is the code I have so far:
(
g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
mxse = g.TheMxsEditorInterface
editorHandle = mxse.EditorGetMainHWND
currentlyOpenTab = mxse.EditorGetEditHWND
windowsSendMessage = windows.SendMessage
windowsGetchildrenhwnd = windows.getchildrenhwnd
function SendCommandToScintilla inCommand inLParam inWParam =
windowsSendMessage currentlyOpenTab inCommand inLParam inWParam
scriptText = undefined
for c in (windowsGetchildrenhwnd editorHandle) where c[1] == currentlyOpenTab do scriptText = c[5]
SCI_GETLINECOUNT = 2154
SCI_SETINDICATORCURRENT = 2500
SCI_INDICSETSTYLE = 2080
SCI_INDICATORCLEARRANGE = 2505
SCI_INDICSETUNDER = 2510
SCI_INDICSETALPHA = 2523
SCI_INDICSETFORE = 2082
SCI_INDICSETOUTLINEALPHA = 2558
SCI_INDICATORFILLRANGE = 2504
SCI_SETTARGETSTART = 2190
SCI_SETTARGETEND = 2192
SCI_SETSEARCHFLAGS = 2198
SCI_SEARCHINTARGET = 2197
SCI_GETINDICATORCURRENT = 2501
INDIC_BOX = 6
indic = 9
-- SendCommandToScintilla SCI_SETINDICATORCURRENT indic 0
SendCommandToScintilla SCI_SETINDICATORCURRENT 0 indic
SendCommandToScintilla SCI_INDICATORCLEARRANGE indic scriptText.count
SendCommandToScintilla SCI_INDICSETSTYLE indic INDIC_BOX
SendCommandToScintilla SCI_INDICSETUNDER indic 1
SendCommandToScintilla SCI_INDICSETFORE indic 0x0000ff
SendCommandToScintilla SCI_INDICSETOUTLINEALPHA indic 50
SendCommandToScintilla SCI_INDICSETALPHA indic 100
SendCommandToScintilla SCI_SETTARGETSTART 0 0
SendCommandToScintilla SCI_SETTARGETEND scriptText.count 0
-- SendCommandToScintilla SCI_SETSEARCHFLAGS 0 SCFIND_NONE
curIndic = SendCommandToScintilla SCI_GETINDICATORCURRENT 0 0
-- always return 0 !?
format "curIndic: %\n" curIndic
wordToHighlight = "marshal"
marshal = dotnetclass "System.Runtime.InteropServices.Marshal"
ptr = marshal.StringToHGlobalUni wordToHighlight
wordLength = wordToHighlight.count
-- find word "marshal"
offset = SendCommandToScintilla SCI_SEARCHINTARGET wordLength ptr
format "offset: %\n" offset
-- highlight the word
SendCommandToScintilla SCI_INDICATORFILLRANGE offset (wordLength + 1)
)
But it does not highlight any word. The code must find and highlight the word “marshal” and it finds the word, but the highlight part does not work. Also, the SCI_SETINDICATORCURRENT is also not working. Maybe this is the reason no words to be highlighted.
I have no idea if the words(more than one) highlighting is possible in MaxScript Editor.
Maybe someone have more experience with SCI_ commands?