@@ -19,6 +19,7 @@ StrConstant macroMarker = "\\W519"
1919StrConstant windowMarker = "\\ W520"
2020StrConstant procMarker = "\\ W521"
2121StrConstant structureMarker = "\\ W522"
22+ StrConstant menuMarker = "\\ W523"
2223
2324// the idea here: static functions have less intense colors
2425StrConstant plainColor = "0,0,0" // black
@@ -239,6 +240,9 @@ Function/S createMarkerForType(type)
239240 marker = constantMarker
240241 elseif ( strsearch ( type, "structure" , 0 ) != -1 )
241242 marker = structureMarker
243+ elseif ( strsearch ( type, "menu" , 0 ) != -1 )
244+ marker = menuMarker
245+ return getColorDef ( plainColor) + marker
242246 endif
243247
244248 // plain definitions
@@ -477,6 +481,56 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWav
477481 WaveClear wavStructureStart, wavStructureEnd
478482End
479483
484+ Function addDecoratedMenu ( module, procedureWithoutModule, declWave, lineWave)
485+ String module, procedureWithoutModule
486+ WAVE /T declWave
487+ WAVE /D lineWave
488+
489+ Variable numLines, idx, numEntries, numMatches
490+ String procText, re, def, name, type
491+ String currentMenu = ""
492+
493+ // get procedure code
494+ procText = getProcedureText ( module, procedureWithoutModule)
495+ numLines = ItemsInList ( procText, "\r " )
496+
497+ // search code and return wavLineNumber
498+ Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
499+ // regexp: match case insensitive (?i) spaces don't matter. search for menu or submenu with a name in double quotes.
500+ // help for regex on https://regex101.com/
501+ re = "^(?i)[[:space:]]*(menu|submenu)[[:space:]]+\" ((?:[^\"\\\\ ]|\\\\ .)+)\" (?:[[:space:]]*[,][[:space:]]*(hideable|dynamic|contextualmenu))?"
502+ Grep / Q/ INDX/ E= re text
503+ numMatches = !! V_Value
504+ Wave W_Index
505+ Duplicate / FREE W_Index wavLineNumber
506+ KillWaves / Z W_Index
507+ if ( ! numMatches)
508+ return 0
509+ endif
510+
511+ numMatches = DimSize ( wavLineNumber, 0 )
512+ numEntries = DimSize ( declWave, 0 )
513+ Redimension / N= ( numEntries + numMatches, -1 ) declWave, lineWave
514+
515+ for ( idx = numEntries; idx < ( numEntries + numMatches) ; idx += 1 )
516+ SplitString / E= re text[ wavLineNumber[( idx - numEntries)]] , def, name, type
517+ def = LowerStr ( def)
518+ if ( ! cmpstr ( def, "menu" ))
519+ currentMenu = name
520+ endif
521+ declWave[ idx][ 0 ] = createMarkerForType ( def)
522+ declWave[ idx][ 1 ] = "Menu " + currentMenu
523+ if ( ! cmpstr ( def, "submenu" ))
524+ declWave[ idx][ 1 ] += ":" + name
525+ endif
526+ if ( cmpstr ( type, "" ))
527+ declWave[ idx][ 1 ] += "(" + type + ")"
528+ endif
529+
530+ lineWave[ idx] = wavLineNumber[( idx - numEntries)]
531+ endfor
532+ End
533+
480534// input wave (wavStructure) contains text of Structure lineseparated.
481535// wavStructure begins with "Structure" definition in first line and ends with "EndStructure" in last line.
482536Function /S getStructureElements ( wavStructure)
@@ -612,6 +666,7 @@ Function/S parseProcedure(procedure, [checksumIsCalculated])
612666 addDecoratedConstants ( procedure. module, procedure. name, decls, lines)
613667 addDecoratedMacros ( procedure. module, procedure. name, decls, lines)
614668 addDecoratedStructure ( procedure. module, procedure. name, decls, lines)
669+ addDecoratedMenu ( procedure. module, procedure. name, decls, lines)
615670
616671 // stop timer
617672 setParsingTime ( timerStop ( timer))
0 commit comments