@@ -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
@@ -480,6 +484,56 @@ Function addDecoratedStructure(module, procedureWithoutModule, declWave, lineWav
480
484
WaveClear wavStructureStart, wavStructureEnd
481
485
End
482
486
487
+ Function addDecoratedMenu ( module, procedureWithoutModule, declWave, lineWave)
488
+ String module, procedureWithoutModule
489
+ WAVE /T declWave
490
+ WAVE /D lineWave
491
+
492
+ Variable numLines, idx, numEntries, numMatches
493
+ String procText, re, def, name, type
494
+ String currentMenu = ""
495
+
496
+ // get procedure code
497
+ procText = getProcedureText ( module, procedureWithoutModule)
498
+ numLines = ItemsInList ( procText, "\r " )
499
+
500
+ // search code and return wavLineNumber
501
+ Make / FREE/ N= ( numLines) / T text = StringFromList ( p, procText, "\r " )
502
+ // regexp: match case insensitive (?i) spaces don't matter. search for menu or submenu with a name in double quotes.
503
+ // help for regex on https://regex101.com/
504
+ re = "^(?i)[[:space:]]*(menu|submenu)[[:space:]]+\" ((?:[^\"\\\\ ]|\\\\ .)+)\" (?:[[:space:]]*[,][[:space:]]*(hideable|dynamic|contextualmenu))?"
505
+ Grep / Q/ INDX/ E= re text
506
+ numMatches = !! V_Value
507
+ Wave W_Index
508
+ Duplicate / FREE W_Index wavLineNumber
509
+ KillWaves / Z W_Index
510
+ if ( ! numMatches)
511
+ return 0
512
+ endif
513
+
514
+ numMatches = DimSize ( wavLineNumber, 0 )
515
+ numEntries = DimSize ( declWave, 0 )
516
+ Redimension / N= ( numEntries + numMatches, -1 ) declWave, lineWave
517
+
518
+ for ( idx = numEntries; idx < ( numEntries + numMatches) ; idx += 1 )
519
+ SplitString / E= re text[ wavLineNumber[( idx - numEntries)]] , def, name, type
520
+ def = LowerStr ( def)
521
+ if ( ! cmpstr ( def, "menu" ))
522
+ currentMenu = name
523
+ endif
524
+ declWave[ idx][ 0 ] = createMarkerForType ( def)
525
+ declWave[ idx][ 1 ] = "Menu " + currentMenu
526
+ if ( ! cmpstr ( def, "submenu" ))
527
+ declWave[ idx][ 1 ] += ":" + name
528
+ endif
529
+ if ( cmpstr ( type, "" ))
530
+ declWave[ idx][ 1 ] += "(" + type + ")"
531
+ endif
532
+
533
+ lineWave[ idx] = wavLineNumber[( idx - numEntries)]
534
+ endfor
535
+ End
536
+
483
537
// input wave (wavStructure) contains text of Structure lineseparated.
484
538
// wavStructure begins with "Structure" definition in first line and ends with "EndStructure" in last line.
485
539
Function /S getStructureElements ( wavStructure)
@@ -615,6 +669,7 @@ Function/S parseProcedure(procedure, [checksumIsCalculated])
615
669
addDecoratedConstants ( procedure. module, procedure. name, decls, lines)
616
670
addDecoratedMacros ( procedure. module, procedure. name, decls, lines)
617
671
addDecoratedStructure ( procedure. module, procedure. name, decls, lines)
672
+ addDecoratedMenu ( procedure. module, procedure. name, decls, lines)
618
673
619
674
// stop timer
620
675
setParsingTime ( timerStop ( timer))
0 commit comments