Jump to content
Sign in to follow this  
Reaper HGN

Keywords/Call tips highlighted in Scite

Recommended Posts

Reaper HGN

I have been using Autoit long enough now to have my own library of UDFs (some of my own, and many from the site). I really wanted functions from those UDFs to show in Scite regardless of the computer I was working on. To that end, I did some digging in the forums for how this was done manually and put this simple (could be improved quite a bit, I'm sure) script together to update the UDF properties and the Calltips api files. It does this by parsing a directory with UDFs in it, extracting functions and calltips and generating the files. It then copies the files to the right locations based on the registry entries. After a restart of Scite, your custom UDF functions are now highlighted and show in the auto complete.

Basically, I keep the function.au3 in my UDF library directory. Whenever I add a new UDF, right under the function definition I create the calltip comment and run the script to update my files. An example would be:

Func Myfunction(myvariable)
;CALLTIP MyFunction("variable")   <- or however you want the calltip to look like.   Just have to have ;CALLTIP in there.

     ;function code
EndFunc

Then the script reads the UDFs and generates the files, excluding the function.au3 and the two other generated files.

The script appends the calltip indicating which UDF should be included to get that function as well.

These are copied to where the registry indicates AutoIt is installed.

Restarting Scite will show all the calltips and code highlighting after that.

#RequireAdmin
#Include <File.au3>
#Include <Array.au3>

$s_path = StringReplace(RegRead("HKEY_CLASSES_ROOT\AutoIt3Script\Shell\Run\Command",""),'"','')
$i_pathlocal = StringInStr($s_path,"\AutoIt3\")
$s_path = StringLeft($s_path,$i_pathlocal)& "AutoIt3\SciTE\"

ConsoleWrite($s_path)


;get directory listing
$a_files = _GetFiles()


    $fh = FileOpen(@ScriptDir & "\au3.userudfs.properties",2)
    $fh2 = FileOpen(@ScriptDir & "\au3.user.calltips.api",2)
    for $i = 1 to UBound($a_files)-1
        if not(StringInStr("au3.userudfs.properties au3.user.calltips.api function.au3",$a_files[$i])) Then
            Dim $aRecords
            If Not _FileReadToArray($a_files[$i],$aRecords) Then
               MsgBox(4096,"Error", " Error reading log to Array     error:" & @error)
               Exit
            EndIf
            For $x = 1 to $aRecords[0]
                if StringLeft($aRecords[$x],4) == "Func" Then
                    $s_leftparaloc = StringInStr($aRecords[$x],"(")
                    $aRecords[$x] = StringLeft($aRecords[$x],$s_leftparaloc-1)
                    $aRecords[$x] = StringReplace($aRecords[$x], "func", "")
                    ;ConsoleWrite("au3.keywords.user.udfs=" & StringStripWS($aRecords[$x],7) & @CRLF)
                    FileWrite($fh,"au3.keywords.user.udfs=" & StringStripWS($aRecords[$x],7) & @CRLF)
                EndIf

                if StringLeft($aRecords[$x],8) == ";CALLTIP" Then
                    $aRecords[$x] = StringReplace($aRecords[$x], ";CALLTIP", "")
                    ;ConsoleWrite(StringStripWS($aRecords[$x],7) & @CRLF)
                    FileWrite($fh2,StringStripWS($aRecords[$x],7) & " (#include <" & $a_files[$i] & ">)" & @CRLF)
                EndIf

            Next


        EndIf
    Next
    FileClose($fh2)
    FileClose($fh)

FileCopy(@ScriptDir & "\au3.userudfs.properties",$s_path & "Properties\" & "au3.userudfs.properties", 1)
FileCopy(@ScriptDir & "\au3.user.calltips.api",$s_path & "Api\" & "au3.user.calltips.api", 1)

MsgBox(0,"Dont forget....", "Restart Scite editor if it is currently running.")

Func _GetFiles()
    $FileList=_FileListToArray(@ScriptDir)
    If @Error=1 Then
        MsgBox (0,"","No Folders Found.")
        Exit
    EndIf
    If @Error=4 Then
        MsgBox (0,"","No Files Found.")
        Exit
    EndIf

    Return $FileList
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×