This document is intended to help writing source code in Amaya. It concerns file names, variables, function signatures, etc.
The root directory is called Amaya and includes 11 sub-directories. The libwww is stored in a separated hierarchy and its root directory libwww must be a sibling of the Amaya root directory.
_tv.h
and their inclusion should be preceded by a
definition of THOT_EXPORT
#DEFINE THOT_EXPORT
or
#DEFINE THOT_EXPORT extern
_f.h
.To avoid conflicts with included libraries and to share the code as often as possible, the Thot library defines its own types for booleans, widgets, buttons, pixmaps and windows. All these declarations are located in files Amaya/thotlib/include/thot_sys.h, Amaya/thotlib/include/thot_gui.h and Amaya/thotlib/include/thot_uio.h. See also Unicode conventions.
We recommand to organize modules in five clearly separated sections:
That concerns local variables, global variables, function headings and function names.
Local variables and function parameters must start with a lowercase character.
Global variables must start with a uppercase character. When they are
global but only used into one module. They must be declared
static
in that module. When they are used in more than one
module they must be declared in a included file:
Amaya/thotlib/internals/var/*tv.h
Amaya/amaya/*h
All functions should include a comment at the top which explains what the function does, what is the signification of parameters, what is the output.
A function must be declared static
if it is only used
into the current module.
Function declarations must be done according to the standard C convention.
By example:
/*---------------------------------------------------------------------- GetStyleContents returns a buffer that contains the whole text of the style element el. It returns NULL if the element is empty. The buffer should be freed by the caller. ----------------------------------------------------------------------*/ STRING GetStyleContents (Element el) { ... }
A function name must start with a uppercase character and more if it includes different words.
There are specific conventions for functions which are exported by the Thotlib.
Amaya/amaya/EDITOR.A
) like the
command CloseView which uses
TtcCloseView
.Adding a new dialogue entry in any Amaya menu is by by several steps:
By example, adding the following line "view:1 Style
button:BValidCSS -> ValidCSS;
" will create a new entry
"BValidCSS" into the "Style" menu, only displayed by the formatted view
of the document (view:1). When selecting that menu entry Amaya will call
the function "ValidCSS (document, view)".
After compiling Amaya, the building will stop because the new function
is not defined, but in the file
Amaya/obj/amaya/EDITORactions.proto
you will find the
declaration of the function (ValidCSS () in our example). Take a copy of
that declaration and put it into the file Amaya/amaya/EDITORactions.c.
Then you have to write the code of the function.
For that, check the position of the new dialogue in the generated file
Amaya/obj/amaya/EDITOR.h
Open the XML base of dialogues:
Amaya/tools/xmldialogues/bases/base_am_dia.xml
It's available on the CVS base but not included in the tar source (please ask us if you need it).
Add the corresponding entry at the right place in the base, but pay attention that this XML base uses UTF-8 characters.
Dialogue files will be then generated by the PERL script
Amaya/tools/xmldialogues/scripts/Am_dial_managment.pl
Amaya/config/ProfileDefs
to make that function available in
right profiles.Amaya/doc/amaya/Configure.html
if that function should be
acceded by a shortcut.Help menu entries are handled as dialogue entries. Therefore, you'll have to add a new dialogue entry, a callback procedure, connect this procedure to the dialogue entry, and make this procedure open the related manual page
Follow the instructions for adding a new dialogue entry, inspiring yourself from the existing help menu entries. For example, the Help/Configure entry is defined as follows in the EDITOR.A file:
view:1 Help_ button:BHelpConfigure -> HelpConfigure;
The callback procedure and the definition of the manual pages are done in
the init.c
file. To associate a manual page to the procedure,
you first need to declare it in the helpmenu.h file. In this find, you'll
find an array called Manual and some macro definitions to associate a names
with the Manual entries. For HelpConfigure, the macro is called
CONFIGURE
.
Once you've done this, open the init file, search for the Help* procedures and add your new procedure. For example, HelpConfigure is specified as follows:
/*---------------------------------------------------------------------- -----------------------------------------------------------------------*/ void HelpConfigure (Document document, View view) { DisplayHelp (document, CONFIGURE); }
The DisplayHelp function will open a new document window and show the
document specified in the Manual index (file helpmenu.h
). Note
that we use the macro rather than the index number to refer to the index
entry.