Hi,
ihr wisst ja alle, dass wenn man seine eigenen Funktionen bastelt, sie immer so unschön Schwarz sind.
Hiermit konfiguriert ihr SciTE gemütlich so, dass eure Funktionen bei euch Blau sind.
Man kann auch einfach eine Libary/Include/UDF's/Skript Datei wählen, wo dann alle Funktionen blau gefärbt werden die in dieser Datei gebaut sind.
Ich finde das selbst recht nützlich *g*.
Lass ich einfach über eine gedownloadede 'UDF' laufen und die Funktionen werden blau, dann weiss ich auch, dass ich sie richtig geschrieben habe.
Die Funtkionen werden aber nur eingefärbt, wenn sie auch in dem ausgewählten Skript 'gebaut' wurden.
So, genug gelabert, hier das Skript. [vorläufige version!]
Spoiler anzeigen
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Version=beta
#AutoIt3Wrapper_icon=icon.ico
#AutoIt3Wrapper_Res_Comment=color your own or someone others function's in your SciTE
#AutoIt3Wrapper_Res_Description=color your own or someone others function's in your SciTE
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Copyright © 2008 qon
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GuiConstants.au3>
#include <file.au3>
#include <array.au3>
#include <String.au3>
$EditorPath = _RegRead("HKEY_CURRENT_USER\Software\Funcadder","EditorPath",RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\AutoIt","InstallDir") & "\SciTE")
[/autoit] [autoit][/autoit] [autoit]$Gui = GuiCreate("Funcadder 1.0.0.0 © qon",500,235)
$Label = GuiCtrlCreateLabel("This was made to add functions to SciTE properties, so the function is shown bright blue in SciTE." & @CRLF & "It's kept simply. This tool also can automaticly scan whole files and make all black own functions blue.",5,10)
$SingleGroup = GuiCtrlCreateGroup("Single",20,50,390,60)
$SingleAddInput = GuiCtrlCreateInput("_ExampleFunc",33,73,240,22)
$SingleAddButton = GuiCtrlCreateButton("Add",290,71,100)
$FileGroup = GuiCtrlCreateGroup("File",20,120,460,60)
$FileAddInput = GuiCtrlCreateInput("C:\ExampleFile.au3",33,143,240,22)
$FileAddButton = GuiCtrlCreateButton("Scan and add",283,141,85)
$FileSelectButton = GuiCtrlCreateButton("Select...",380,141,85)
$EditorLabel = GuiCtrlCreateLabel("SciTE Path",8,203)
$EditorPathInput = GuiCtrlCreateInput($EditorPath,73,200,300)
$EditorBrowse = GuiCtrlCreateButton("Browse...",383,200,101,20)
Global $LastBrowse = @DesktopDir
[/autoit] [autoit][/autoit] [autoit]GuiSetBkColor(0x18C3DF,$Gui)
[/autoit] [autoit][/autoit] [autoit]GuiSetState()
[/autoit] [autoit][/autoit] [autoit]While 1
Switch GuiGetMsg()
Case $GUI_EVENT_CLOSE
RegWrite("HKEY_CURRENT_USER\Software\Funcadder","EditorPath","REG_SZ",GuiCtrlRead($EditorPathInput))
Exit
;;;
Case $EditorBrowse
$EditorPathSelect = FileSelectFolder("Select SciTE folder","")
IF Not @error then GuiCtrlSetData($EditorPathInput,$EditorPathSelect)
;;;
Case $FileSelectButton
$FilePathSelect = FileOpenDialog("Please choose an Autoit source file",$LastBrowse,"Autoit Source (*.au3)")
If Not @error Then
GuiCtrlSetData($FileAddInput,$FilePathSelect)
Dim $szDrive, $szDir, $szFName, $szExt
$SplitPath = _PathSplit($FilePathSelect, $szDrive, $szDir, $szFName, $szExt)
IF Not @Error Then $LastBrowse = $SplitPath[1] & $SplitPath[2]
EndIf
;;;
Case $SingleAddButton
$PropertyFilePath = GuiCtrlRead($EditorPathInput) & "\Properties\au3.keywords.properties"
$PropertyFileHandle = FileOpen($PropertyFilePath,0)
$PropertyFileText = FileRead($PropertyFileHandle)
If Not @error Then
IF StringInStr($PropertyFileText,GuiCtrlRead($SingleAddInput) & " ") Then
Msgbox(48,"Already exists","This function does already exist.")
FileClose($PropertyFileHandle)
Else
$NewText = _InsertFunc(GuiCtrlRead($SingleAddInput),$PropertyFileText)
IF Not @error Then
FileClose($PropertyFileHandle)
FileDelete($PropertyFilePath)
$PropertyFileHandle = FileOpen($PropertyFilePath,2)
FileWrite($PropertyFileHandle,$NewText)
FileClose($PropertyFileHandle)
Msgbox(64,"Added","The function was added successfully!")
Else
GuiCtrlSetData($SingleAddInput,"error while adding.")
FileClose($PropertyFileHandle)
EndIf
EndIf
Else
Msgbox(48,"Error","Error opening property file, maybe SciTE path invalid.")
EndIf
;;;
Case $FileAddButton
$SourceFilePath = GuiCtrlRead($FileAddInput)
If Not FileExists($SourceFilePath) or StringRight($SourceFilePath,4) <> ".au3" Then
Msgbox(48,"Error","File does not exist or invalid file extension.")
Else
$SourceFile = FileOpen($SourceFilePath,0)
$Source = FileRead($SourceFile)
If @error Then
Msgbox(48,"Error","Error while reading source file or file is empty.")
FileClose($SourceFile)
Else
$FuncFound = _StringBetween($Source, 'Func ', '(')
If @error Then
Msgbox(64,"No founds","No user functions found.")
FileClose($SourceFile)
Else
FileClose($SourceFile)
$PropertyFilePath = GuiCtrlRead($EditorPathInput) & "\Properties\au3.keywords.properties"
$PropertyFileHandle = FileOpen($PropertyFilePath,0)
$PropertyFileText = FileRead($PropertyFileHandle)
If @error then
Msgbox(48,"Error","Error while reading property file.")
FileClose($PropertyFileHandle)
Else
$Founds = 0
For $i = 0 to UBound($FuncFound)-1
If Not StringInStr($PropertyFileText,$FuncFound[$i] & " ") Then
$PropertyFileText = _InsertFunc($FuncFound[$i],$PropertyFileText)
$Founds += 1
EndIf
Next
FileClose($PropertyFileHandle)
FileDelete($PropertyFilePath)
$PropertyFileHandle = FileOpen($PropertyFilePath,2)
FileWrite($PropertyFileHandle,$PropertyFileText)
FileClose($PropertyFileHandle)
Msgbox(64,"Added",$Founds & " functions were made blue")
EndIf
EndIf
EndIf
EndIf
EndSwitch
WEnd
Func _InsertFunc($sFuncName,$sFileText)
$Pos = StringInStr($sFileText,"au3.keywords.udfs=")
IF @error Then SetError(1,0,0)
$Start = StringLeft($sFileText, $Pos + 17)
$End = StringRight($sFileText, StringLen($sFileText) - $Pos - 17)
Return $Start & StringLower($sFuncName) & " \" & @CRLF & $End
EndFunc
;===============================================================================
;
; Function Name: _regread()
; Description: Reads a registry entry ( with a given standard )
; Parameter(s): $iKeyname - The registry key to read
; $iValuename - The value to read
; $iStandard - The standard that will be returned if registry entry does not exists [optional]
; Requirement(s): None
; Return Value(s): On Success - Returns the Registry Value, if @error occurres ( can't find key / unknown format ) the standard will be returned.
; On Failure - If no standard is set and can't read Key, the @error number from regread will be returned ( Helpfile ).
; Author(s): qon
;
;===============================================================================
func _regread($sKeyname,$sValuename,$vStandard = "")
Local $vValue
Local $iError
$vValue = Regread($sKeyname,$sValuename)
$iError = @error
If $iError <> 0 Then
If $vStandard = "" Then
Seterror($iError)
Return ""
EndIf
Return $vStandard
EndIf
Return $vValue
EndFunc
Im Anhang nochmal kompiliiert und Source.
ToDo für mich:
- schöneren Gui
- Auflistung aller bereits selbst hinzugefügten Funktionen
- Löschen hinzugefügter Funktionen
Gruß
qon