//TH-Header //***************************************************************************************** // Copyright (c) 2003 KURANT Project // All rights reserved. // // $FileName : E:\Program Files\Hammer\Pkg\cCodeTip.pkg // $ProjectName : The Hammer v1.5 // $Authors : Michael Kurz, Sergey V. Natarov // $Created : 18.01.2003 15:05 // $Type : OptionWare // // Contents: // Code Tip (new feature) support //***************************************************************************************** //TH-RevisionStart // 18.01.2003 18:50 Initial revision, header created Ad //TH-RevisionEnd Use set.pkg Class cCodeTip Is a Set Procedure Construct_Object Forward Send Construct_Object Property Integer piInitialized False Property Integer piMaxCodeTips 0 // 0 = no limit Object oFunctions Is an Array End_Object End_Procedure // Function CodeTip_FileExist String sFile Returns Integer Integer iExist If sFile Eq "" Function_Return 0 Direct_Input sFile [Not seqeof] Move 1 To iExist Close_Input Function_Return iExist End_Function // Function DoFormatFunction String sFunc Returns String String sComment Move (Replaces("=",sFunc,"")) To sFunc Move (Replaces(" ",sFunc," ")) To sFunc // If "/" In sFunc Begin // Move (Left(sFunc,Pos("/",sFunc))) To sFunc // Move (Replaces("/",sFunc,"")) To sFunc // End Move (Trim(sFunc)) To sFunc // If (Right(sFunc,1)<>")") Move (sFunc+")") To sFunc Function_Return (Trim(sFunc)) End_Function // Procedure DoRegisterFunction String sDest Integer iPos String sName sFunc Move (Left(sDest,Pos("=",sDest))) To sName Move (Replace(sName,sDest,"")) To sFunc Move (Trim(Replace("=",sName,""))) To sName Move (Uppercase(sName)) To sName Get DoFormatFunction sFunc To sFunc // If ((sName<>"")And(sFunc<>"")) Begin Get Find_Element sName To iPos If (iPos>=0) Procedure_Return Else Begin If ((piMaxCodeTips(Self))And(Item_Count(Self)>=piMaxCodeTips(Self))) Procedure_Return Send Add_Element sName Get Find_Element sName To iPos If (iPos<0) Procedure_Return // Failed to add Set Value Of oFunctions Item iPos To sFunc End End End_Procedure // Function CodeTipFunction String sToken Returns String Integer iPos Get Find_Element (Uppercase(sToken)) To iPos If (iPos<0) Function_Return "" Function_Return (Value(oFunctions(Self),iPos)) End_Function // // We don't want to add: // empty lines // line that starts with "/" as that's a comment line // line that starts with "[" as that's a section name line // // Original code checked for "[" in the whole line, not sure why that was. // Procedure DoReadIniFile String sFile String sLine String sStartChar If (sFile="") Procedure_Return Direct_Input sFile While (Not(seqeof)) Readln sLine Move (Trim(sLine)) To sLine Move (Left(sLine,1)) To sStartChar If (sLine<>"" and sStartChar<>"[" and sStartChar<>"/") Begin Send DoRegisterFunction sLine End Loop Close_Input End_Procedure // DoReadIniFile // Procedure delete_data Forward Send delete_data Broadcast Send Delete_Data End_Procedure // Function CodeTipInitialize Returns Integer Integer bExist ghoIni String sCodeTipIni If (piInitialized(Self)) Function_Return (Item_Count(Self)) Send Delete_Data Move ghoEditorProperties To ghoIni If ghoIni Get psCodeTipIniFile Of ghoIni To sCodeTipIni // Delegate Get psCodeTipIniFile To sCodeTipIni If (sCodeTipIni="") Move "Functions.ini" To sCodeTipIni Get CodeTip_FileExist sCodeTipIni To bExist If (Not(bExist)) Function_Return (Item_Count(Self)) Send DoReadIniFile sCodeTipIni Set piInitialized To True Function_Return (Item_Count(Self)) End_Function // End_Class // Initiate codetip object Global_Variable Integer ghoCodeTip Object oCodeTip Is a cCodeTip // Load on startup Get CodeTipInitialize To ghoCodeTip Move Self To ghoCodeTip // End_Object