File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ struct menu *menu_get_menu_or_parent_menu(struct menu *menu);
102
102
int get_jump_key_char (void );
103
103
struct gstr get_relations_str (struct symbol * * sym_arr , struct list_head * head );
104
104
void menu_get_ext_help (struct menu * menu , struct gstr * help );
105
+ void menu_dump (void );
105
106
106
107
/* symbol.c */
107
108
void sym_clear_all_valid (void );
Original file line number Diff line number Diff line change @@ -788,3 +788,77 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help)
788
788
if (sym )
789
789
get_symbol_str (help , sym , NULL );
790
790
}
791
+
792
+ /**
793
+ * menu_dump - dump all menu entries in a tree-like format
794
+ */
795
+ void menu_dump (void )
796
+ {
797
+ struct menu * menu = & rootmenu ;
798
+ unsigned long long bits = 0 ;
799
+ int indent = 0 ;
800
+
801
+ while (menu ) {
802
+
803
+ for (int i = indent - 1 ; i >= 0 ; i -- ) {
804
+ if (bits & (1ULL << i )) {
805
+ if (i > 0 )
806
+ printf ("| " );
807
+ else
808
+ printf ("|-- " );
809
+ } else {
810
+ if (i > 0 )
811
+ printf (" " );
812
+ else
813
+ printf ("`-- " );
814
+ }
815
+ }
816
+
817
+ switch (menu -> type ) {
818
+ case M_CHOICE :
819
+ printf ("choice \"%s\"\n" , menu -> prompt -> text );
820
+ break ;
821
+ case M_COMMENT :
822
+ printf ("comment \"%s\"\n" , menu -> prompt -> text );
823
+ break ;
824
+ case M_IF :
825
+ printf ("if\n" );
826
+ break ;
827
+ case M_MENU :
828
+ printf ("menu \"%s\"" , menu -> prompt -> text );
829
+ if (!menu -> sym ) {
830
+ printf ("\n" );
831
+ break ;
832
+ }
833
+ printf (" + " );
834
+ /* fallthrough */
835
+ case M_NORMAL :
836
+ printf ("symbol %s\n" , menu -> sym -> name );
837
+ break ;
838
+ }
839
+ if (menu -> list ) {
840
+ bits <<= 1 ;
841
+ menu = menu -> list ;
842
+ if (menu -> next )
843
+ bits |= 1 ;
844
+ else
845
+ bits &= ~1 ;
846
+ indent ++ ;
847
+ continue ;
848
+ }
849
+
850
+ while (menu && !menu -> next ) {
851
+ menu = menu -> parent ;
852
+ bits >>= 1 ;
853
+ indent -- ;
854
+ }
855
+
856
+ if (menu ) {
857
+ menu = menu -> next ;
858
+ if (menu -> next )
859
+ bits |= 1 ;
860
+ else
861
+ bits &= ~1 ;
862
+ }
863
+ }
864
+ }
You can’t perform that action at this time.
0 commit comments