J'utilise l'outil développé par Yashied pour la coloration syntaxique (voir ce sujet).
J'ai donc repris le code de Yashied pour y ajouter une option supplémentaire.
Cela permet dorénavant lors de l'ajout d'une fonction personnalisée dans le fichier au3.keywords.properties (Coloration syntaxique) d'avoir en plus
"une petite aide" sur la fonction (affichage des paramètres de la fonction dans le Tip) lors de la création de scripts dans Scite
(Cela se résume à la création d'un enregistrement dans le fichier au3.user.calltips.api.
► Afficher le texteExemple en captures :
NB 2 : Tlem en parle dans ce post et explique en détail le principe.
NB 3 :Attendu que c'est un code pondu initialement par Yashied, si ça posait le moindre problème que je poste à mon tour le code source modifié ici,
n'hésitez pas à me prévenir auquel cas je supprimerais de suite mon post
Pour ceux qui utilisent l'outil de Yashied, cela apporte un tout petit plus
► Afficher le texteCode Source
Code : Tout sélectionner
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Icons\UDF Keyword Manager.ico
#AutoIt3Wrapper_Outfile=Output\UDF Keyword Manager.exe
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_Description=Management of UDF keyword for SciTE editor
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_Run_AU3Check=n
#AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, DIALOG, 1000,
#AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, MENU, 166,
#AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, ICON, 164,
#AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -delete %out%, %out%, ICON, 169,
#AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -add %out%, %out%, Icons\162.ico, ICON, 164, 0
#AutoIt3Wrapper_Run_After=Utilities\ResHacker\ResHacker.exe -add %out%, %out%, Icons\162.ico, ICON, 169, 0
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.0.0
Author: Yashied
Script Function:
UDF Keyword Manager for SciTE editor.
[08/06/2012] : Script New function => Add func help for Scite editor (in file au3.user.calltips.api)
All changes are notified by ; [Add By TopXm]
NB : It's running only if user use button "Load from UDF" and Removing items
#ce ----------------------------------------------------------------------------
#region AutoIt3Wrapper
#endregion AutoIt3Wrapper
#region Initialization
#include <GUIConstantsEx.au3>
#include <GUIEdit.au3>
#include <GUIListView.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Global Const $GUI_NAME = 'UDF Keyword Manager'
Global Const $REG_KEY_NAME = 'HKCU\SOFTWARE\' & $GUI_NAME
Global $AU3UserUDFProperties = StringStripWS(RegRead($REG_KEY_NAME, 'AU3UserUDFProperties'), 3)
Global $AutoItDir = StringStripWS(RegRead('HKLM\SOFTWARE\AutoIt v3\AutoIt', 'InstallDir'), 3)
If ($AU3UserUDFProperties = '') And ($AutoItDir > '') Then
$AU3UserUDFProperties = $AutoItDir & '\SciTE\Properties\au3.userudfs.properties'
RegWrite($REG_KEY_NAME, 'AU3UserUDFProperties', 'REG_SZ', $AU3UserUDFProperties)
EndIf
; [Add By TopXm] --------------------------------------------------------------------
; CheckBox for adding function in au3.user.calltips.api
Global $ChkUserCalltip
; au3.user.calltips.api
Global Const $AU3UserCallTipsApi = $AutoItDir & '\Scite\Api\au3.user.calltips.api'
; Array with User Functions in the UDF
Global $ListF[1] = [0]
; Array with User functions in au3.user.calltips.api
Global $AllF[1] = [0]
; Array with Deleted User functions
Global $DelF[1] = [0]
; UDF filename
Global $UDFfilename
; [Add By TopXm - End] --------------------------------------------------------------
Global $Form, $Edit, $ListView, $Input, $ButtonAdd, $ButtonRemove, $ButtonUDF, $ButtonClear, $ButtonDelete, $ButtonPath, $ButtonSave, $ButtonCancel, $Msg
Global $fState[2] = [0, 0]
Global $n, $b, $data, $func, $item, $file, $path = @MyDocumentsDir
Dim $List[1] = [0]
#endregion Initialization
#region Main State
CreateForm()
_ListLoad()
For $i = 1 To $List[0]
GUICtrlCreateListViewItem($List[$i], $ListView)
Next
ReDim $List[1]
$List[0] = 0
While 1
$Msg = GUIGetMsg()
Select
Case ($Msg = $GUI_EVENT_CLOSE)
Exit
Case ($Msg = $ButtonAdd)
$data = StringRegExpReplace(GUICtrlRead($Edit), '[' & @CR & @LF & @TAB & ']', ' ')
$data = StringLower(StringStripWS($data, 7))
While $data > ''
$n = StringInStr($data, ' ')
If $n > 0 Then
$func = StringLeft($data, $n - 1)
Else
$func = $data
EndIf
$data = StringTrimLeft($data, StringLen($func) + 1)
$n = _GUICtrlListView_GetItemCount($ListView)
$b = 0
For $i = 0 To $n - 1
$item = _GUICtrlListView_GetItem($ListView, $i)
If $item[3] = $func Then
$b = 1
ExitLoop
EndIf
Next
If Not $b Then
GUICtrlCreateListViewItem($func, $ListView)
EndIf
WEnd
Case ($Msg = $ButtonUDF)
$file = FileOpenDialog('Select File', $path, 'AutoIt v3 Script (*.au3)|All files (*.*)', 1 + 2, '', $Form)
If $file > '' Then
$path = StringRegExpReplace($file, '\\[^\\]*$', '')
_ListLoadFromUDF($file)
For $i = 1 To $List[0]
_GUICtrlEdit_AppendText($Edit, $List[$i] & @CRLF)
Next
;[Add By TopXm]
If $List[0] > 0 Then
$UDFfilename = $file
EndIf
;[Add By TopXm End]
EndIf
Case ($Msg = $ButtonClear)
GUICtrlSetData($Edit, '')
Case ($Msg = $ButtonDelete) Or ($Msg = $ButtonRemove)
$i = 0
While $i < _GUICtrlListView_GetItemCount($ListView)
$item = _GUICtrlListView_GetItem($ListView, $i)
If BitAND($item[0], 8) = 8 Then
_GUICtrlListView_DeleteItem($ListView, $i)
If $Msg = $ButtonRemove Then
_GUICtrlEdit_AppendText($Edit, $item[3] & @CRLF)
EndIf
;[Add By TopXm]
$DelF[0] += 1
ReDim $DelF[$DelF[0] + 1]
$DelF[$DelF[0]] = $item[3]
;[Add By TopXm End]
Else
$i += 1
EndIf
WEnd
Case ($Msg = $ButtonPath)
$file = FileSelectFolder('Location au3.userudfs.properties to', '', 2, StringRegExpReplace($AU3UserUDFProperties, '\\[^\\]*$', ''), $Form)
If $file > '' Then
If StringRight($file, 1) <> '\' Then
$file &= '\'
EndIf
$file &= 'au3.userudfs.properties'
If $AU3UserUDFProperties <> $file Then
$AU3UserUDFProperties = $file
RegWrite($REG_KEY_NAME, 'AU3UserUDFProperties', 'REG_SZ', $AU3UserUDFProperties)
GUICtrlSetData($Input, $AU3UserUDFProperties)
If FileExists($AU3UserUDFProperties) Then
_GUICtrlListView_DeleteAllItems($ListView)
_ListLoad()
For $i = 1 To $List[0]
GUICtrlCreateListViewItem($List[$i], $ListView)
Next
ReDim $List[1]
$List[0] = 0
;[Add By TopXm]
ReDim $ListF[1]
$ListF[0] = 0
;[Add By TopXm End]
EndIf
EndIf
EndIf
Case ($Msg = $ButtonSave)
$n = _GUICtrlListView_GetItemCount($ListView)
ReDim $List[$n + 1]
$List[0] = $n
For $i = 1 To $List[0]
$item = _GUICtrlListView_GetItem($ListView, $i - 1)
$List[$i] = $item[3]
Next
_ListSave()
ReDim $List[1]
$List[0] = 0
;[Add By TopXm]
ReDim $ListF[1]
$ListF[0] = 0
;[Add By TopXm - End]
Case ($Msg = $ButtonCancel)
Exit
EndSelect
WEnd
#endregion Main State
#region Additional Functions
Func CreateForm()
$Form = GUICreate($GUI_NAME, 586, 600)
GUICtrlCreateLabel('Add functions:', 16, 14, 250, 14)
$Edit = GUICtrlCreateEdit('', 16, 30, 250, 410)
GUICtrlCreateLabel('Available functions:', 318, 14, 250, 14)
$ListView = GUICtrlCreateListView(' ', 318, 30, 250, 410, BitOR($LVS_NOCOLUMNHEADER, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING))
GUICtrlSetColor(-1, 0x0080FF)
_GUICtrlListView_SetColumnWidth($ListView, 0, 224 + 18 - 18)
$ButtonAdd = GUICtrlCreateButton('>', 278, 202, 28, 28)
$ButtonRemove = GUICtrlCreateButton('<', 278, 240, 28, 28)
$ButtonUDF = GUICtrlCreateButton('Load from UDF...', 15, 448, 120, 23)
$ButtonClear = GUICtrlCreateButton('Clear', 147, 448, 120, 23)
$ButtonDelete = GUICtrlCreateButton('Delete Selected', 383, 448, 120, 23)
GUICtrlCreateLabel('', 16, 493, 555, 2, $SS_ETCHEDHORZ)
GUICtrlCreateLabel('Path:', 16, 519, 28, 14)
$Input = GUICtrlCreateInput($AU3UserUDFProperties, 46, 516, 494, 21, $ES_READONLY)
GUICtrlSetBkColor(-1, 0xFFFFFF)
$ButtonPath = GUICtrlCreateButton('...', 546, 515, 23, 23)
; [Add By TopXm] : Add CheckBox to manage au3.user.calltips.api
$ChkUserCalltip = GUICtrlCreateCheckbox("Add function help in au3.user.calltips.api file", 46, 540, 300, 23)
; [Add By TopXm End]
$ButtonSave = GUICtrlCreateButton('Save', 414, 564, 75, 23)
If $AU3UserUDFProperties = '' Then
GUICtrlSetState(-1, $GUI_DISABLE)
Else
$fState[0] = 1
$fState[1] = 1
EndIf
$ButtonCancel = GUICtrlCreateButton('Cancel', 495, 564, 75, 23)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState()
EndFunc ;==>CreateForm
Func _ListLoadFromUDF($FileName)
Local $j = 0, $f, $t, $s, $n, $m
ReDim $List[1]
$List[0] = 0
$f = FileOpen($FileName, 0)
If $f = -1 Then
Return
EndIf
Do
$t = FileReadLine($f)
If @error Then
FileClose($f)
Return
EndIf
$t = StringStripWS(StringReplace($t, @TAB, ' '), 1)
$n = StringInStr($t, ' ')
If $n > 0 Then
$s = StringLeft($t, $n - 1)
Else
$s = $t
EndIf
$s = StringLower($s)
Select
Case ($s = '#comments-start') Or ($s = '#cs')
$j += 1
Case ($s = '#comments-end') Or ($s = '#ce')
$j -= 1
Case ($s = 'func')
If $j <= 0 Then
$t = StringTrimLeft($t, 4)
If StringLeft($t, 1) = ' ' Then
$t = StringStripWS($t, 1)
$n = StringInStr($t, '(')
$m = StringInStr($t, ' ')
If ($m < $n) And ($m > 0) Then
$n = $m
EndIf
If $n = 0 Then
ContinueLoop
EndIf
$s = StringLeft($t, $n - 1)
If $s > '' Then
ReDim $List[$List[0] + 2]
$List[0] += 1
$List[$List[0]] = $s
;[Add By TopXm]
$ListF[0] += 1
ReDim $ListF[$ListF[0] + 1]
$ListF[$ListF[0]] = $t
EndIf
EndIf
EndIf
EndSelect
Until 0
EndFunc ;==>_ListLoadFromUDF
Func _ListLoad()
Local $f, $t, $s, $n, $b = True
ReDim $List[1]
$List[0] = 0
$f = FileOpen($AU3UserUDFProperties, 0)
If $f = -1 Then
Return
EndIf
Do
$t = FileReadLine($f)
If @error Then
FileClose($f)
Return
EndIf
$t = StringRegExpReplace($t, '[\\' & @CR & @LF & @TAB & ']', ' ')
$t = StringLower(StringStripWS($t, 7))
If $b Then
If StringLeft($t, 22) = 'au3.keywords.user.udfs' Then
$t = StringStripWS(StringTrimLeft($t, 22), 1)
If StringLeft($t, 1) = '=' Then
$t = StringStripWS(StringTrimLeft($t, 1), 1)
$b = 0
EndIf
Else
ContinueLoop
EndIf
EndIf
While $t > ''
$n = StringInStr($t, ' ')
If $n > 0 Then
$s = StringLeft($t, $n - 1)
Else
$s = $t
EndIf
$t = StringTrimLeft($t, StringLen($s) + 1)
ReDim $List[$List[0] + 2]
$List[0] += 1
$List[$List[0]] = $s
WEnd
Until 0
EndFunc ;==>_ListLoad
Func _ListSave()
Local $f, $t
$f = FileOpen($AU3UserUDFProperties, 2)
If $f = -1 Then
Return
EndIf
; [Add By TopXm] : Load file au3.user.calltips.api
If GUICtrlRead($ChkUserCalltip) = 1 Then
_LoadUserCalltips()
EndIf
; [Add By TopXm End]
If $List[0] > 0 Then
$t = 'au3.keywords.user.udfs='
For $i = 1 To $List[0]
$t = $t & $List[$i] & ' '
If (StringLen($t) > 100) Or ($i = $List[0]) Then
If $i < $List[0] Then
$t &= '\'
EndIf
FileWriteLine($f, $t)
$t = @TAB
EndIf
; [Add By TopXm] If $ChkUserCalltip => _SetUserCalltipsApi(AU3FileName, Func)
If GUICtrlRead($ChkUserCalltip) = 1 Then
_SetUserCalltipsApi($UDFfilename, $List[$i])
EndIf
; [Add By TopXm End]
Next
EndIf
FileClose($f)
; [Add By TopXm] : Rewrite file au3.user.calltips.api
If GUICtrlRead($ChkUserCalltip) = 1 Then
; [Add By TopXm] : Remove all Func from $ButtonDelete Or $ButtonRemove
For $i = 1 To $DelF[0]
_RemoveFunction($DelF[$i])
Next
$f = FileOpen($AU3UserCallTipsApi, 2)
For $i = 1 To $AllF[0]
FileWriteLine($f, $AllF[$i])
Next
FileClose($f)
EndIf
; [Add By TopXm End]
EndFunc ;==>_ListSave
; [Add By TopXm] : Remove from array $AllF all functions in array $DelF
Func _RemoveFunction($FuncName)
Local $j, $k
For $j = 1 To $AllF[0]
If StringInStr($AllF[$j] , $FuncName) > 0 Then
If $j = $AllF[0] Then
$AllF[0] -= 1
ReDim $AllF[$AllF[0] + 1]
Return
EndIf
For $k = $j + 1 To $AllF[0]
$AllF[$k - 1] = $AllF[$k]
Next
$AllF[0] -= 1
ReDim $AllF[$AllF[0] + 1]
Return
EndIf
Next
EndFunc
; [Add By TopXm] : Load file au3.user.calltips.api in array an save it
Func _LoadUserCalltips()
ReDim $AllF[1]
$AllF[0] = 0
If Not FileExists($AU3UserCallTipsApi) Then Return
Local $hf = FileOpen($AU3UserCallTipsApi)
If $hf = -1 Then Return
Local $r = FileRead($hf)
FileClose($hf)
If StringRight($r, 1) = @LF Then $r = StringTrimRight($r, 1)
If StringRight($r, 1) = @CR Then $r = StringTrimRight($r, 1)
$AllF = StringSplit(StringStripCR($r), @LF)
EndFunc ;==>_LoadUserCalltips
Func _SetUserCalltipsApi($FileName, $FuncName)
$FileName = StringMid($FileName, StringInStr($FileName, '\', 0, -1) + 1, StringLen($FileName))
; Find Function detail (Function name and parms)
Local $k, $l, $m = ''
For $k = 1 To $ListF[0]
If StringInStr($ListF[$k], $FuncName) Then
$m = $ListF[$k]
ExitLoop
EndIf
Next
If $m = '' Then Return
; Prepare string to put into au3.user.calltips.api
Local $HLP, $sPos, $ePos, $Param, $EndParam = '', $o, $Sep, $EndSep = ''
Local $nFunc = StringReplace($m, 'func', '')
$sPos = StringInStr($m, '(')
$ePos = StringInStr($m, ')')
If $ePos <= $sPos Then Return SetError(1)
$Param = StringMid($m, $sPos + 1, $ePos - $sPos - 1)
$nFunc = StringLeft($m, StringInStr($m, '(') - 1)
Local $aParam = StringSplit($Param, ',')
$HLP = $nFunc & '('
If $Param <> '' Then
For $o = 1 To $aParam[0]
$Sep = ''
If StringInStr($aParam[$o], '=') > 0 Then
$Sep = '['
$EndSep &= ']'
EndIf
If $o = 1 Then
$HLP &= $Sep & _Trim($aParam[$o])
Else
$HLP &= $Sep & ', ' & _Trim($aParam[$o])
EndIf
Next
EndIf
$HLP &= $EndSep & ') (Requires: #include <' & $FileName & '>)'
;Find in au3.user.calltips.api if function already exists and replace it, Otherwise add it
$m = ''
For $k = 1 To $AllF[0]
If StringInStr($AllF[$k], $FuncName) Then
$m = $AllF[$k]
$AllF[$k] = $HLP
ExitLoop
EndIf
Next
;Add New function in au3.user.calltips.api
If $m = '' Then
$AllF[0] += 1
ReDim $AllF[$AllF[0] + 1]
$AllF[$AllF[0]] = $HLP
EndIf
EndFunc ;==>_SetUserCalltipsApi
; Trim Left and Right string
Func _Trim($Str, $TrimL = True, $TrimR = True)
Local $u, $oStr = $Str
If $TrimL Then
While StringLeft($oStr, 1) = ' '
$oStr = StringTrimLeft($oStr, 1)
WEnd
EndIf
If $TrimR Then
While StringRight($oStr, 1) = ' '
$oStr = StringTrimRight($oStr, 1)
WEnd
EndIf
Return $oStr
EndFunc
; [Add By TopXm End]
#endregion Additional Functions
#region Windows Message Functions
Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
Switch BitAND($wParam, 0xFFFF)
Case $Input
Switch BitShift($wParam, 16)
Case $EN_CHANGE
$fState[0] = ($AU3UserUDFProperties > '')
If $fState[0] <> $fState[1] Then
GUICtrlSetState($ButtonSave, $GUI_ENABLE * $fState[0] + $GUI_DISABLE * (Not $fState[0]))
$fState[1] = $fState[0]
EndIf
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
#endregion Windows Message Functions