@@ -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
@@ -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,10 +710,11 @@ 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)
717+ resetLists ( decls, lines, procs , helps)
713718 addDecoratedFunctions ( procedure. module, procedure. fullName, decls, lines)
714719
715720 WAVE /T procContent = getProcedureTextAsWave ( procedure. module, procedure. fullName)
@@ -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
@@ -1259,6 +1308,22 @@ Function/Wave getLineWave()
12591308 return wv
12601309End
12611310
1311+ /// @brief Get a wave which holds the procedures' full name
1312+ ///
1313+ /// @see getLineWave
1314+ ///
1315+ /// @returns 1D Wave having the procedure fullname in each row.
1316+ Function /Wave getProcWave ()
1317+ DFREF dfr = createDFWithAllParents ( pkgFolder)
1318+ WAVE /Z/ T/ SDFR= dfr wv = $ procedureWave
1319+
1320+ if ( ! WaveExists ( wv))
1321+ Make / T dfr:$ procedureWave/Wave = wv
1322+ endif
1323+
1324+ return wv
1325+ End
1326+
12621327// 2D-Wave with Strings
12631328// Return refrence to (string) Wave/T
12641329static Function/Wave getSaveStrings ()
0 commit comments