@@ -19,6 +19,7 @@ StrConstant macroMarker = "\\W519"
19
19
StrConstant windowMarker = "\\ W520"
20
20
StrConstant procMarker = "\\ W521"
21
21
StrConstant structureMarker = "\\ W522"
22
+ StrConstant menuMarker = "\\ W523"
22
23
23
24
// the idea here: static functions have less intense colors
24
25
StrConstant plainColor = "0,0,0" // black
@@ -239,6 +240,9 @@ Function/S createMarkerForType(type)
239
240
marker = constantMarker
240
241
elseif ( strsearch ( type, "structure" , 0 ) != -1 )
241
242
marker = structureMarker
243
+ elseif ( strsearch ( type, "menu" , 0 ) != -1 )
244
+ marker = menuMarker
245
+ return getColorDef ( plainColor) + marker
242
246
endif
243
247
244
248
// plain definitions
@@ -477,6 +481,56 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWav
477
481
WaveClear wavStructureStart, wavStructureEnd
478
482
End
479
483
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
+
480
534
// input wave (wavStructure) contains text of Structure lineseparated.
481
535
// wavStructure begins with "Structure" definition in first line and ends with "EndStructure" in last line.
482
536
Function /S getStructureElements ( wavStructure)
@@ -612,6 +666,7 @@ Function/S parseProcedure(procedure, [checksumIsCalculated])
612
666
addDecoratedConstants ( procedure. module, procedure. name, decls, lines)
613
667
addDecoratedMacros ( procedure. module, procedure. name, decls, lines)
614
668
addDecoratedStructure ( procedure. module, procedure. name, decls, lines)
669
+ addDecoratedMenu ( procedure. module, procedure. name, decls, lines)
615
670
616
671
// stop timer
617
672
setParsingTime ( timerStop ( timer))
0 commit comments