Menus file accept comment line

Post Reply
luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

Menus file accept comment line

Post 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;
	BEGIN
		s.Scan;
		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);
			s.SetOpts(opts);
			Scan(s);
		END
	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"
luowy
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Menus file accept comment line

Post 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

	SEPARATOR
	"*"	""	"HostMenus.WindowList"	""
where the procedure WindowList is

Code: Select all

	PROCEDURE WindowList*;
	BEGIN
		HALT(127)
	END WindowList;
Is this mechanism explained anywhere? I would like to do something similar in my own menus.
luowy
Posts: 234
Joined: Mon Oct 20, 2014 12:52 pm

Re: Menus file accept comment line

Post 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;
User avatar
Robert
Posts: 1024
Joined: Sat Sep 28, 2013 11:04 am
Location: Edinburgh, Scotland

Re: Menus file accept comment line

Post by Robert »

Does anyone else have an opinion about whether it is worth adding this feature?
Post Reply