From: Sammy Mitchell
//I am developing a SAL macro for creating HTML. It uses extensive popup
//menus. With a menu option highlighted, is it possible to provide custom
//help by pressing the key?
Yes. This is supported by both versions 2.5 and 2.6. Note that
this feature is undocumented because it is subject to change in the future.
What I would like to replace it with in the future is a help hook, that gets
called if defined. But anyway, back to the current implementation.
The help system always tries to execute a macro called "helphelp.mac".
The macro is passed a command line of the format "-option HelpTopic", where
option is:
'r' indicating that help-topic was found in the help index.
'h' indicating that help-topic was not found in the help index.
help-topic is the current help topic.
If you want TSE to go ahead and process the help normally, your macro should
simply return. Otherwise, before the macro returns, set the MacroCmdLine
editor variable to "true".
Below is a simple macro that illustrates replacing one of the built-in
helps: the mainmenu->file->open, and a new user-defined help, the "This"
menu on the UserMenu.
Name this macro file "helphelp.s", compile it, and place it somewhere in the
TSEPath (this includes the current and LoadDir), and press while the
pen
menu option is hilited. Next, run "foo", and press while the "This"
menu option is hilited.
Note that under 2.5, the macro must exist the first time the help is invoked
during an editing session, e.g., if helphelp.mac does not exist, you are in
the editor, you press help, you create helphelp.mac, the helphelp.mac will
not be called. But, if helphelp.mac exists when the editor is started, it
will be called each time help is pressed.
Since this is an undocumented (and experimental) feature, there
isn't a lot of support I can give you on this. But, I have tested it for my
own use, and it works for me.
Sammy Mitchell
SemWare Corp.
menu UserMenu()
"This"
"That"
"The other Thing"
end
public proc foo()
UserMenu()
end
datadef userhelp
"This is help for a new menu."
"By using this, I can add help"
"for menu items not in the tsehelp.hlp"
"file."
end
datadef replacehelp
"This is my custom help screen!"
"It can be used in place of the"
"TSE Pro help, if you need it."
end
#ifdef WIN32
string filemenu_open[] = "FileMenu->Open"
#else
string filemenu_open[] = "FileMenu->Open..."
#endif
proc main()
string topic[255], cmdline[255]
cmdline = Query(MacroCmdLine)
if cmdline[1] '-'
return ()
endif
topic = Trim(cmdline[4:255])
case cmdline[2]
when 'r' // topic found, do we want to replace it?
if topic == filemenu_open // replace the "Open" help
InsertData(replacehelp)
else
return () // let others pass-through
endif
when 'h' // not found -
case topic
when "UserMenu->This" // help for "This"
InsertData(userhelp)
otherwise // let others pass-through
return ()
endcase
otherwise // unknown option - let system handle it
return ()
endcase
Set(MacroCmdLine, "true") // tell help we got it
// PushKey() //
end
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)
|