Page 1 of 1

Menus file accept comment line

PostPosted: Tue Jun 09, 2020 6:29 am
by luowy
Rsrc/Menus.odc file does not accept comment lines, it's inconvenient when we customize the menu;
they are menu configuration files actually. in linux ,the configuration file accepts comments :
Code: Select all
# comments here

a small patch has made to accept comment line,StdMemuTool.Scan
Code: Select all
   PROCEDURE Scan (VAR s: TextMappers.Scanner);
      VAR ch: CHAR; pos: INTEGER; opts: SET;
      IF s.type = string THEN
         pos := s.rider.Pos() - 1;
         IF ~s.rider.eot THEN DEC(pos) END;
         s.rider.SetPos(pos); s.rider.ReadChar(ch); s.rider.Read;
         IF ch # '"' THEN s.type := keyword END
      ELSIF (s.type = char)&(s.char = '#') THEN
         opts := s.opts;
         s.SetOpts(opts + {TextMappers.returnCtrlChars});
         REPEAT s.Scan(); UNTIL (s.type = TextMappers.line) OR (s.type = TextMappers.eot);
   END Scan;

after patching, you can comment out any menus you dont want, and restore them easily;
Code: Select all
   "&Documentation"   ""   "DevReferences.ShowDocu"   "TextCmds.SelectionGuard"
#"De&pendencies"   ""   "DevDependencies.Deposit;StdCmds.Open"   "TextCmds.SelectionGuard"


Re: Menus file accept comment line

PostPosted: Tue Jun 09, 2020 7:33 am
by Robert
I think this would be a useful feature.

Two other comments:

1 - Is it easy to add attributes to menu entries? In particular I would like to use color.

2 - The last menu entry in the Windows menu is
Code: Select all
   "*"   ""   "HostMenus.WindowList"   ""
where the procedure WindowList is
Code: Select all
   PROCEDURE WindowList*;
   END WindowList;
Is this mechanism explained anywhere? I would like to do something similar in my own menus.

Re: Menus file accept comment line

PostPosted: Tue Jun 09, 2020 3:46 pm
by luowy
1, no, had to subclass some window;

2,"HostMenus.WindowList" ,it's only a flag, indicate this popup menu will append MDI sub window list;
the work is done by the default procedure of MDI client window;

in HostMenus.InitMenus, UpdateMenus
Code: Select all
res := WinApi.SendMessageW(HostWindows.client, WinApi.WM_MDISETMENU, menuBar, winMenu);

"winMenu" is the popup menu which the MDI window list will append to;

Re: Menus file accept comment line

PostPosted: Fri Jun 12, 2020 9:02 pm
by Robert
Does anyone else have an opinion about whether it is worth adding this feature?