Yes, you misunderstand some things.
first of all:
SetStyle is a subroutine of coloring line and this line must not the active one, so it isn't a good method to find the word here.
Find_Proc/Struc/etc. Search the word in the list and yes, the list is updating while tipping text. (These does the Find_Term routines in combination with notifiy-messages insert/deleteText and beforeinsert/Delete (see windowcallback).
How would i do this:
I would wait until the Cursor moves out of a word.
Look in the Window-Callback-procedure and the notify-message
#SCN_UPDATEUI
Code: Select all
If (WordUnderCursorPos>Pos Or Pos>WordUnderCursorEnd)
WordUnderCursorPos=Pos:WordUnderCursorEnd=Pos ; also coloring, when the cursor moves out the word
Find_NewTerm(1,line,0,0)
UpdateList(#False)
ColoringLine(#True,-1,line) ; because word under cursor doesn't colored!
EndIf
Here is a check, it the Cursor is moved out of a word. When the Cursor is in a word, it is never colored right (i use the style of the first char in the Word) and is never replaced. So you can type endPOS, without that the editor change end to End.
WordUnderCursorPos and WordUnderCursorEnd show the beginn and end of the word and WordUnderCursorType holds the #style_xyz.
This position is perfekt to check, if a tooltip should appear.
Some additionals:
I have in the ListInfo-Structure a Add-Type. I planed to used this add to store addition informations, like Tool-Tip-String-Adress.
There are checks, that this Words never earsed out of the list and are always in. But this check only check the first byte.
so search all \add (not more, because i had maybe add spaces), and replace all "& 1=0" with "=0" and "&1" with "".
Now you can store in the \add variable a adress to the string with the tooltip.
To add this, do something like this
Code: Select all
structure string
s.s
endstructure
newlist tooltip.string()
Proc$="Abs":Tooltip$="Abs (Number.f) - Returns the Absolute value (no sign) of the given float valueee. - Result.f = Abs(Number.f)"
if find_proc(proc$)=0
; word not found, and here is a good insert position (because the list is alphabetic and the find_ set a good position to insert proc$)
addelement(proc())
proc()\s=proc$
;else
; already in the list, but now we insert a tooltip
endif
addelement tooltip()
tooltip()\s=tooltip$
proc()\add=@tooltip()\s ; structure here, because @tooltip$() will not show the right adress, it will give you the adress to the element thing.
Another Tip: If you don't want to add a tooltip, but you want to add a name to the list and this name should never earesed, then set \add to 1 (because a tooltip can never set to this adress). But you should test before writing the tooltip, that the adress<>1 or your code will crash.
P.S.: A save the LIst (proc/struc/etc) in memory while switch between the sourecodes and so the switch is fast as in the editor. Your version will allways recreate the complete list, when you switch the code and this can be very slow.
p.p.s.: The compiler creates automatic a list with all definited functions and there tooltip. Look in the original code of the editor.