@@ -43,6 +43,8 @@ StrConstant declarations = "declarations"
4343StrConstant helpWave = "help"
4444// 1D Wave in each row having the line of the function or -1 for macros
4545StrConstant declarationLines = "lines"
46+ // 1D Wave in each row having the procedure id for the corresponing element in lines
47+ StrConstant procedureWave = "procs"
4648// database-like global multidimensional waves for storing parsing results to minimize time.
4749static StrConstant CsaveStrings = "saveStrings"
4850static Strconstant CSaveVariables = "saveVariables"
@@ -52,6 +54,8 @@ static Constant CsaveMaximum = 1024
5254
5355Constant openKey = 46 // ".", the dot
5456
57+ StrConstant CB_selectAll = "<ALL>"
58+
5559// List of igor7 structure elements.
5660static strConstant cstrTypes = "Variable|String|WAVE|NVAR|SVAR|DFREF|FUNCREF|STRUCT|char|uchar|int16|uint16|int32|uint32|int64|uint64|float|double"
5761// Loosely based on the WM procedure from the documentation
@@ -324,8 +328,8 @@ Function/S formatDecl(funcOrMacro, params, subtypeTag, returnType)
324328End
325329
326330// Adds all kind of information to a list of function in current procedure
327- Function addDecoratedFunctions ( module, procedure, declWave, lineWave)
328- string module , procedure
331+ Function addDecoratedFunctions ( procedure, declWave, lineWave)
332+ STRUCT procedure & procedure
329333 Wave /T declWave
330334 Wave /D lineWave
331335
@@ -337,7 +341,7 @@ Function addDecoratedFunctions(module, procedure, declWave, lineWave)
337341 Wave /T helpWave = getHelpWave ()
338342
339343 // list normal, userdefined, override and static functions
340- options = "KIND:18,WIN:" + procedure
344+ options = "KIND:18,WIN:" + procedure. fullname
341345 funcList = FunctionList ( "*" , ";" , options)
342346 numMatches = ItemsInList ( funcList)
343347 numEntries = DimSize ( declWave, 0 )
@@ -346,12 +350,12 @@ Function addDecoratedFunctions(module, procedure, declWave, lineWave)
346350 idx = numEntries
347351 for ( i = 0; i < numMatches; i += 1 )
348352 func = StringFromList ( i , funcList)
349- fi = FunctionInfo ( module + "#" + func, procedure)
353+ fi = FunctionInfo ( procedure . module + "#" + func, procedure. name )
350354 if ( ! cmpstr ( func, "Procedures Not Compiled" ))
351355 fi = ReplaceNumberByKey ( "PROCLINE" , fi, 0 )
352356 endif
353357 if ( isEmpty ( fi))
354- debugPrint ( "macro or other error for " + module + "#" + func)
358+ debugPrint ( "macro or other error for " + procedure . module + "#" + func)
355359 endif
356360 returnType = interpretParamType ( NumberByKey ( "RETURNTYPE" , fi) , 0, fi)
357361 threadsafeTag = interpretThreadsafeTag ( StringByKey ( "THREADSAFE" , fi))
@@ -637,18 +641,18 @@ Function/S getVariableName(strDefinition)
637641 return strVariableName
638642End
639643
640- static Function resetLists ( decls, lines, helps)
644+ static Function resetLists ( decls, lines, procs, helps)
641645 Wave /T decls
642646 Wave /D lines
643- Wave /T helps
644- Redimension / N= ( 0, -1 ) decls, lines, helps
647+ Wave /T procs , helps
648+ Redimension / N= ( 0, -1 ) decls, lines, procs , helps
645649End
646650
647651// @todo IgorPro >= 7 supports SortColumns
648- static Function sortListByLineNumber ( decls, lines, helps)
652+ static Function sortListByLineNumber ( decls, lines, procs, helps)
649653 Wave /T decls
650654 Wave /D lines
651- Wave /T helps
655+ Wave /T procs , helps
652656
653657 // check if sort is necessary
654658 if ( Dimsize ( decls, 0 ) * Dimsize ( lines, 0 ) == 0 )
@@ -659,18 +663,18 @@ static Function sortListByLineNumber(decls, lines, helps)
659663 Duplicate / T/ FREE/ R= [][ 1 ] decls, declCol1
660664 Duplicate / T/ FREE/ R= [][ 0 ] helps, helpCol0
661665 Duplicate / T/ FREE/ R= [][ 1 ] helps, helpCol1
662- Sort / A lines, lines, declCol0, declCol1, helpCol0, helpCol1
666+ Sort / A { procs , lines} , lines, procs , declCol0, declCol1, helpCol0, helpCol1
663667 decls[][ 0 ] = declCol0 [ p][ 0 ]
664668 decls[][ 1 ] = declCol1 [ p][ 0 ]
665669 helps[][ 0 ] = helpCol0 [ p][ 0 ]
666670 helps[][ 1 ] = helpCol1 [ p][ 0 ]
667671End
668672
669673// @todo IgorPro >= 7 supports SortColumns
670- static Function sortListByName ( decls, lines, helps)
674+ static Function sortListByName ( decls, lines, procs, helps)
671675 Wave /T decls
672676 Wave /D lines
673- Wave /T helps
677+ Wave /T procs , helps
674678
675679 // check if sort is necessary
676680 if ( Dimsize ( decls, 0 ) * Dimsize ( lines, 0 ) == 0 )
@@ -681,7 +685,7 @@ static Function sortListByName(decls, lines, helps)
681685 Duplicate / T/ FREE/ R= [][ 1 ] decls, declCol1
682686 Duplicate / T/ FREE/ R= [][ 0 ] helps, helpCol0
683687 Duplicate / T/ FREE/ R= [][ 1 ] helps, helpCol1
684- Sort / A declCol1, lines, declCol0, declCol1, helpCol0, helpCol1
688+ Sort / A declCol1, lines, procs , declCol0, declCol1, helpCol0, helpCol1
685689 decls[][ 0 ] = declCol0 [ p][ 0 ]
686690 decls[][ 1 ] = declCol1 [ p][ 0 ]
687691 helps[][ 0 ] = helpCol0 [ p][ 0 ]
@@ -706,11 +710,12 @@ Function/S parseProcedure(procedure, [checksumIsCalculated])
706710 // load global lists
707711 Wave /T decls = getDeclWave ()
708712 Wave /I lines = getLineWave ()
713+ Wave /T procs = getProcWave ()
709714 Wave /T helps = getHelpWave ()
710715
711716 // scan and add elements to lists
712- resetLists ( decls, lines, helps)
713- addDecoratedFunctions ( procedure. module , procedure . fullName , decls, lines)
717+ resetLists ( decls, lines, procs , helps)
718+ addDecoratedFunctions ( procedure, decls, lines)
714719
715720 WAVE /T procContent = getProcedureTextAsWave ( procedure. module, procedure. fullName)
716721 addDecoratedConstants ( procContent, decls, lines)
@@ -1070,56 +1075,102 @@ End
10701075
10711076// Returns 1 if the procedure file has content which we can show, 0 otherwise
10721077Function updateListBoxHook ()
1073- STRUCT procedure procedure
1074- Variable returnState
10751078
10761079 String searchString = ""
10771080
10781081 // load global lists (for sort)
10791082 Wave /T decls = getDeclWave ()
10801083 Wave /I lines = getLineWave ()
1084+ Wave /T procs = getProcWave ()
10811085 Wave /T helps = getHelpWave ()
10821086
1083- // get procedure information
1084- procedure. fullName = getCurrentItem ( procedure = 1 )
1085- procedure. name = ProcedureWithoutModule ( procedure. fullName)
1086- procedure. module = ModuleWithoutProcedure ( procedure. fullName)
1087- procedure. id = procedure. module + "#" + RemoveEverythingAfter ( procedure. name, ".ipf" )
1088- procedure. row = getSaveRow ( procedure. id)
1089-
1090- // load procedure
1091- returnState = saveLoad ( procedure)
1092- if ( returnState < 0 )
1093- debugPrint ( "parsing Procedure" )
1094- parseProcedure ( procedure)
1095- // return state -2 means checksum already calculated and stored in global variable.
1096- if ( ! ( returnState == -2 ))
1097- setCheckSum ( procedure)
1098- endif
1099- // save information in "database"
1100- saveResults ( procedure)
1101- endif
1087+ loadProcedures ( getCurrentItem ( procedure = 1 ))
11021088
11031089 // check if search is necessary
11041090 searchString = getGlobalStr ( "search" )
11051091 if ( strlen ( searchString) > 0 )
1106- searchAndDelete ( decls, lines, helps, searchString)
1092+ searchAndDelete ( decls, lines, procs , helps, searchString)
11071093 endif
11081094
11091095 // switch sort type
11101096 if ( returnCheckBoxSort ())
1111- sortListByName ( decls, lines, helps)
1097+ sortListByName ( decls, lines, procs , helps)
11121098 else
1113- sortListByLineNumber ( decls, lines, helps)
1099+ sortListByLineNumber ( decls, lines, procs , helps)
11141100 endif
11151101
11161102 return DimSize ( decls, 0 )
11171103End
11181104
1119- Function searchAndDelete ( decls, lines, helps, searchString)
1105+ /// @brief load procedure(s)
1106+ ///
1107+ /// @see generateProcedureList
1108+ ///
1109+ /// @param fullName Procedure identifier from procList
1110+ Function loadProcedures ( fullName)
1111+ string fullName
1112+
1113+ variable returnState, i , numProcedures, oldDecls, numDecls
1114+ STRUCT procedure procedure
1115+ string procList = "" , niceList = ""
1116+
1117+ WAVE /T decls = getDeclWave ()
1118+ WAVE /I lines = getLineWave ()
1119+ Wave /T procs = getProcWave ()
1120+ WAVE /T helps = getHelpWave ()
1121+
1122+ Make / FREE/ T/ N= ( 1, 2 ) fullDecls
1123+ Make / FREE/ I / N= ( 1, 1 ) fullLines
1124+ Make / FREE/ T/ N= ( 1, 1 ) fullProcs
1125+ Make / FREE/ T/ N= ( 1, 2 ) fullHelps
1126+
1127+ procList = fullName
1128+ if ( ! cmpstr ( fullName, CB_selectAll))
1129+ procList = ""
1130+ getProcedureList ( procList, niceList)
1131+ endif
1132+
1133+ numProcedures = ItemsInList ( procList)
1134+ numDecls = 0
1135+ for ( i = 0; i < numProcedures; i += 1 )
1136+ procedure. fullName = StringFromList ( i , procList)
1137+ procedure. name = ProcedureWithoutModule ( procedure. fullName)
1138+ procedure. module = ModuleWithoutProcedure ( procedure. fullName)
1139+ procedure. id = procedure. module + "#" + RemoveEverythingAfter ( procedure. name, ".ipf" )
1140+ procedure. row = getSaveRow ( procedure. id)
1141+
1142+ returnState = saveLoad ( procedure)
1143+ if ( returnState < 0 )
1144+ debugPrint ( "parsing Procedure" )
1145+ parseProcedure ( procedure)
1146+ if ( ! ( returnState == -2 )) // checksum stored in global variable.
1147+ setCheckSum ( procedure)
1148+ endif
1149+ saveResults ( procedure)
1150+ endif
1151+
1152+ oldDecls = numDecls
1153+ numDecls += DimSize ( decls, 0 )
1154+ if ( oldDecls == numDecls)
1155+ continue
1156+ endif
1157+ Redimension / N= ( numDecls, -1 ) fullDecls, fullLines, fullProcs, fullHelps
1158+ fullDecls[ oldDecls, numDecls - 1 ] = decls[ p - oldDecls]
1159+ fullLines[ oldDecls, numDecls - 1 ] = lines[ p - oldDecls]
1160+ fullProcs[ oldDecls, numDecls - 1 ] = procedure. fullName
1161+ fullHelps[ oldDecls, numDecls - 1 ] = helps[ p - oldDecls]
1162+ endfor
1163+
1164+ Duplicate / O/ T fullDecls decls
1165+ Duplicate / O/ I fullLines lines
1166+ Duplicate / O/ T fullHelps helps
1167+ Duplicate / O/ T fullProcs procs
1168+ End
1169+
1170+ Function searchAndDelete ( decls, lines, procs, helps, searchString)
11201171 Wave /T decls
11211172 Wave /I lines
1122- Wave /T helps
1173+ Wave /T procs , helps
11231174 String searchString
11241175
11251176 Variable i , numEntries
@@ -1131,16 +1182,16 @@ Function searchAndDelete(decls, lines, helps, searchString)
11311182
11321183 for ( i = numEntries - 1; i > 0; i -= 1 )
11331184 if ( strsearch ( decls[ i ][ 1 ] , searchString, 0, 2 ) == -1 )
1134- DeletePoints / M=0 i , 1, decls, lines, helps
1185+ DeletePoints / M=0 i , 1, decls, lines, procs , helps
11351186 endif
11361187 endfor
11371188
11381189 // prevent loss of dimension if no match was found at all.
11391190 if ( strsearch ( decls[ 0 ][ 1 ] , searchString, 0, 2 ) == -1 )
11401191 if ( Dimsize ( decls, 0 ) == 1 )
1141- Redimension / N= ( 0, -1 ) decls, lines, helps
1192+ Redimension / N= ( 0, -1 ) decls, lines, procs , helps
11421193 else
1143- DeletePoints / M=0 i , 1, decls, lines, helps
1194+ DeletePoints / M=0 i , 1, decls, lines, procs , helps
11441195 endif
11451196 endif
11461197End
@@ -1155,24 +1206,22 @@ Function DeletePKGfolder()
11551206End
11561207
11571208// Shows the line/function for the function/macro with the given index into decl
1158- // With no index just the procedure file is shown
1159- Function showCode ( procedure, [ index] )
1160- string procedure
1209+ Function showCode ( index)
11611210 variable index
11621211
1163- if ( ParamIsDefault ( index))
1164- DisplayProcedure / W=$ procedure
1165- return NaN
1166- endif
1212+ string procedure
11671213
11681214 Wave /T decl = getDeclWave ()
11691215 Wave /I lines = getLineWave ()
1216+ Wave /T procs = getProcWave ()
11701217
11711218 if ( ! ( index >= 0 ) || index >= DimSize ( decl, 0 ) || index >= DimSize ( lines, 0 ))
11721219 Abort "Index out of range"
11731220 endif
11741221
1222+ procedure = procs[ index]
11751223 if ( lines[ index] < 0 )
1224+ debugPrint ( "No line definition found for selected item." )
11761225 string func = getShortFuncOrMacroName ( decl[ index][ 1 ])
11771226 DisplayProcedure / W=$ procedure func
11781227 else
@@ -1182,7 +1231,13 @@ End
11821231
11831232// Returns a list of all procedures windows in ProcGlobal context
11841233Function /S getGlobalProcWindows ()
1185- string procList = getProcWindows ( "*" , "INDEPENDENTMODULE:0" )
1234+ string filter, procList
1235+
1236+ filter = getGlobalStr ( "procFilter" )
1237+ if ( ! cmpstr ( filter, "" ))
1238+ filter = "*"
1239+ endif
1240+ procList = getProcWindows ( filter, "INDEPENDENTMODULE:0" )
11861241
11871242 return AddToItemsInList ( procList, suffix= " [ProcGlobal]" )
11881243End
@@ -1191,8 +1246,13 @@ End
11911246Function /S getIMProcWindows ( moduleName)
11921247 string moduleName
11931248
1194- string regexp
1195- sprintf regexp, "* [%s]" , moduleName
1249+ string regexp, filter
1250+
1251+ filter = getGlobalStr ( "procFilter" )
1252+ if ( ! cmpstr ( filter, "" ))
1253+ filter = "*"
1254+ endif
1255+ sprintf regexp, "%s [%s]" , filter, moduleName
11961256 return getProcWindows ( regexp, "INDEPENDENTMODULE:1" )
11971257End
11981258
@@ -1259,6 +1319,22 @@ Function/Wave getLineWave()
12591319 return wv
12601320End
12611321
1322+ /// @brief Get a wave which holds the procedures' full name
1323+ ///
1324+ /// @see getLineWave
1325+ ///
1326+ /// @returns 1D Wave having the procedure fullname in each row.
1327+ Function /Wave getProcWave ()
1328+ DFREF dfr = createDFWithAllParents ( pkgFolder)
1329+ WAVE /Z/ T/ SDFR= dfr wv = $ procedureWave
1330+
1331+ if ( ! WaveExists ( wv))
1332+ Make / T dfr:$ procedureWave/Wave = wv
1333+ endif
1334+
1335+ return wv
1336+ End
1337+
12621338// 2D-Wave with Strings
12631339// Return refrence to (string) Wave/T
12641340static Function/Wave getSaveStrings ()
0 commit comments