Macro Language Primitives | |
Constants | |
BPACKAGES | BRIEF packages default. |
CRISP_OPSYS | Operating system identifier. |
GRBACKUP | Backup path. |
GRDICTIONARIES | Dictionary locales. |
GRDICTIONARY | Dictionary search path. |
GRFILE | Default empty file name. |
GRFLAGS | Default command line arguments. |
GRHELP | Help search path. |
GRINIT_FILE | GRIEF initialisation name. |
GRKBDPATH | Keyboard library search path. |
GRLEVEL | GRIEF Nesting level. |
GRLOG_FILE | GRIEF diagnostics log file name. |
GRPATH | Macro object search path. |
GRPROFILE | Profile directory override. |
GRPROGNAME | GRIEF application path. |
GRRC | GRIEF resource file path. |
GRRC_FILE | GRIEF initialisation name. |
GRRESTORE_FILE | GRIEF restore file name. |
GRSTATE_DB | GRIEF state database name. |
GRSTATE_FILE | GRIEF state file name. |
GRTEMPLATE | Source template search path. |
GRTERM | Terminal override. |
GRTERMCAP | Terminal capability database. |
GRTMP | Temporary dictionary. |
GRVERSIONMAJOR | GRIEF major version. |
GRVERSIONMINOR | GRIEF minor version. |
GRVERSIONS | Backup versions. |
errno | Last system errno number. |
Macros | |
__breaksw | Switch break statement. |
autoload | Register location of one or more macros. |
bless | Associate an object with a class/module. |
break | break statement. |
call_registered_macro | Invoke registered macro callbacks. |
case | Switch case statement. |
catch | Catch statement. |
continue | Loop continuation. |
create_dictionary | Create a dictionary. |
delete_dictionary | Destroy a dictionary. |
delete_macro | Delete a macro from memory. |
dict_clear | Clear a dictionary. |
dict_delete | Remove a dictionary item. |
dict_each | Iterator a dictionary. |
dict_exists | Dictionary item existence check. |
dict_keys | Iterator dictionary keys. |
dict_list | Retrieve dictionary items. |
dict_name | Retrieve a dictionary name. |
dict_values | Iterator dictionary values. |
do | do statement. |
else | else statement. |
execute_macro | Invokes a command by name. |
exit | Exit current process level. |
finally | Finally statement. |
first_time | Determine a macros initialisation status. |
for | for statement. |
foreach | Container iterator. |
fstype | File system type. |
get_property | Retrieve a dictionary item. |
if | if statement. |
inq_btn2_action | Retrieve the second button action. |
inq_called | Get the name of the calling macro. |
inq_macro | Determine whether a macro or primitive exists. |
inq_macro_history | Retrieve macro execution history. |
inq_module | Retrieve the current module. |
inq_msg_level | Get the message level. |
list_of_dictionaries | List of created dictionaries. |
load_macro | Load a macro object. |
macro | Define a macro body. |
module | Assign a module identifier. |
nothing | Noop. |
register_macro | Register a callback procedure. |
reload_buffer | Reload the buffer content. |
replacement | Overload an existing macro definition. |
require | Enforce the use of an external module. |
reregister_macro | Register a unique callback procedure. |
restore_position | Restore a previously saved position. |
return | Return from a macro. |
returns | Return an expression from a macro. |
save_position | Saves current cursor/buffer state. |
set_btn2_action | Set the second button action. |
set_calling_name | Set the name of the calling macro. |
set_macro_history | Set the macro execution history. |
set_property | Set a dictionary item. |
switch | Switch statement. |
throw | Throw an exception. |
try | Try statement. |
unregister_macro | Remove a registered macro. |
while | while statement. |
extern const string BPACKAGES;
BRIEF packages default.
The BPACKAGES global string is used to specify the BRIEF language sensitive editing modes. This is a hangover from the PC version of BRIEF, it is used to configure old-style package support; see the macro source language.cr.
BPACKAGES shall be referenced on the first running of GRIEF and then exported into the GRIEF runtime configuration file. The initial value of BPACKAGES is either imported from the environment or if not available then the following default is used.
.c.cc.CC.cpp.h.H.hpp-c:hilite,t;.default:hilite,template,regular;
You can attach these packages so that they are automatically used with program source files that have special file extensions. The packages configuration is used by all file extension dependent packages.
The format of the package specification is,
package: extension[,extension]...[-equivalent]:\
package [args],package...;extension...
The extension element is the file extension that will invoke a specific style. One or more comma separated extension can be specified for each style.
Note: the special extension “default” is used to specify all extensions not specifically included in the packages string.
The equivalent element is an optional value which specifies that the preceding extensions should be treated the same as the “equivalent extension” by the language sensitive features, an extension override.
All extensions preceding the equivalent extension back to preceding semicolon, another equivalent extension, or the beginning of the packages definition are affected by the command. Hence given:
package: .asm:.r;.cpp.hpp.h-c:smart
GRIEF shall consider extensions .cpp, .hpp and .h equivalent to the extension .c, and would use .c the smart editing package for all three. Note also that since .c has not been explicitly specified as an extension, no packages are assigned to it. The following is required to complete the recipe:
package: .asm:r;.cpp.hpp.h.c-c:smart
GRIEF shall first check for the package using the actual extension before for one with the equivalent extension. If in the previous example, smart indentation was available for .cpp files, GRIEF would use the .cpp support over the .c support.
This feature is useful when the extension is not automatically recognised and is unable to provide smart indenting. Using extension equivalence, informs GRIEF that an unsupported extension should be treated like an equivalent supported one.
package: .default:hilite;.c:hilite,t 1 1 0 1
The extension .default is used as a wild card (or default), to any match an extension not explicitly listed. The above example enables the hilite package on implicitly supported file types, plus an explicit configuration for the .c extension.
Is the macro package attached to the extension. Each extension can have multiple packages associated with it, as long as the package don’t conflict.
extern const string GRBACKUP;
Backup path.
The GRBACKUP global string is used to specify the default backup directory, when buffer backups are enabled. In the absence of any buffer or global set_backup_option BK_DIR configuration nor the GRBACKUP environment variable, GRIEF renames the original file with a .bak extension.
GRBACKUP is equivalent to the BRIEF BBACKUP environment variable.
extern const string GRDICTIONARIES;
Dictionary locales.
The GRDICTIONARIES global string is used to specify the dictionary locales to be applied during spell check operations, stated as a list of comma separated dictionary names.
GRDICTIONARIES=en_GB,en_US
The default value assigned when no value is available.
GRDICTIONARIES=en_US,en_GB,default
The value of GRDICTIONARIES can be dumped by running GRIEF with the --config command line option.
gr --config
extern const string GRDICTIONARY;
Dictionary search path.
The GRDICTIONARY global specifies the directory from which dictionaries are to be sourced during spell check operations.
GRPATH, GRDICTIONARIES, <vars>
extern const string GRFILE;
Default empty file name.
The GRFILE global string is used to specify the file name used on start up as the default buffer name to be created, when no explicit files are stated on the command line.
The initial value of GRFILE is either imported from the environment or if not available then a value of newfile is used.
GRFILE=newfile
extern const string GRFLAGS;
Default command line arguments.
The GRFLAGS global string is used to specify the default implied command line arguments. GRIEF processes the switches stated in GRFLAGS before processing the explicit flags on the command line.
The GRFLAGS variable provides a means to set up private user options to be automatically applied on each execution. For example, your GRIEF profile macro can be automatic loaded on start using:
GRFLAGS="-mmyprofile"
The initial value of GRFLAGS is either imported from the environment or if not available then a system dependent default is used.
GRFLAGS is equivalent to the BRIEF BFLAGS environment variable.
extern const string GRHELP;
Help search path.
The GRHELP global string is used to specify the directory name stating the search path which GRIEF shall utilise to locate the help database. The initial value of GRHELP is either imported from the environment or if not available is derived from the location of the running application.
Directly setting this value within the session environment permits an alternative GRIEF installation.
Default Unix definition.
/usr/local/grief/help
The value of GRHELP can be dumped by running GRIEF with the --config command line option.
gr --config
GRHELP is equivalent to the BRIEF BHELP environment variable.
GRPATH, GRBACKUP, GRDICTIONARIES, <vars>
extern const string GRINIT_FILE;
GRIEF initialisation name.
The GRINIT_FILE global constant is assigned to the system dependent initialisation file name.
The GRINIT_FILE file contains optional runtime configuration settings to initialise GRIEF when it starts.
The standard location of the configuration is either within profile directory or the home directory.
~/.grinit
$HOMEDRIVE\$HOMEPATH\_grinit
Within all environments the GRPROFILE override can be used to state an alternative location.
The sysinfo macro can be used to see the current home and/or profile specifications.
extern const string GRKBDPATH;
Keyboard library search path.
The GRKBDPATH global string is used to specify the directory name stating the location shall utilise to keyboard library definitions. The initial value of GRKBDPATH is either imported from the environment or if not available is derived from GRTEMPLATE.
These macros build the global list variable, kbd_labels, that is then is used by the int_to_key to derive the displayable label.
The keyboard library macro is only relevant within several help functions, so that meaningful keyboard labels can be given. For example, you might have a META key rather than an ALT key.
list
kbd_labels = {
AF(1), "<Meta-F1>",
AF(2), "<Meta-F2>",
AF(3), "<Meta-F3>",
AF(4), "<Meta-F4>",
AF(5), "<Meta-F5>",
AF(6), "<Meta-F6>",
AF(7), "<Meta-F7>",
AF(8), "<Meta-F8>",
AF(9), "<Meta-F9>",
AF(10), "<Meta-F10>",
AF(11), "<Meta-F11>",
AF(12), "<Meta-F12>"
};
extern const int GRLEVEL;
GRIEF Nesting level.
The GRLEVEL global constant is set by GRIEF to the current nesting level, stating the number of current invocations of GRIEF within the same session. This value allows the user to determine that there are nested invocations of GRIEF running; see inq_brief_level.
GRLEVEL is equivalent to the BRIEF BLEVEL environment variable.
It is a hangover from BRIEF which displays the level number in the bottom right corner. Unlike BRIEF the value only represents the number of instances running within the current terminal session; with each terminal maintaining an independent nesting level.
extern const string GRPATH;
Macro object search path.
The GRPATH global string is used to specify one or more directory names stating the search path which GRIEF shall utilise to locate macro objects during autoload and require operations. The initial value of GRPATH is either imported from the environment or if not available is derived from the location of the running application.
Same as the system PATH environment variable, the directories contained within GRPATH should use the operating system dependent delimiter generally either a semi-colon (;) for DOS/Windows or a colon (:) for Unix style systems.
Directly setting this value within the session environment permits an alternative GRIEF installation.
Possible Unix definition, allowing access to both user localised and global macros.
$HOME/grief:/usr/local/grief/macro
The value of GRPATH can be dumped by running GRIEF with the --config command line option.
gr --config
GRPATH is equivalent to the BRIEF BPATH environment variable.
extern const string GRPROFILE;
Profile directory override.
The GRPROFILE global string is used to specify an override to the standard users home directory; it is utilised by several macros to source runtime configuration details. GRPROFILE provides the user a means of stating an alternative location.
extern const string GRRC_FILE;
GRIEF initialisation name.
The GRRC_FILE global constant is assigned to the system dependent resource file name. The resource file is an alternative source of application arguments, equivalent to the GRFLAGS environment variable.
The resource file provides a means to set up private user options to be automatically applied on each execution.
The resource file is used to specify implied command line arguments. GRIEF either processes the switches stated within GRFLAGS or the resource file before processing the explicit flags on the command line. As such, if both are present GRFLAGS has priority.
For example, your GRIEF profile macro can be automatic loaded on start using:
# .grrc example
-mmyprofile
The character `#’ introduces a comment if used at the beginning of a line. Lines starting with `#’ are ignored as are blank lines. One or more white-space separated options can be stated per-line but it is advised to use one for readability.
Processing may be inhibited by using the --norc option on the command line, disabling both GRFLAGS and resource file processing.
The standard location of the configuration is within the home directory.
~/.grrc
$HOMEDRIVE\$HOMEPATH\_grrc
The GRRC global string shall represent the path of the resolved resource file.
The sysinfo macro can be used to see the path of the active resource name.
GRRC, GRINIT_FILE, <vars>
extern const string GRTEMPLATE;
Source template search path.
The GRTEMPLATE global string is used to specify the language sensitive file and function header generator. The initial value of GRTEMPLATE is either imported from the environment or if not available is derived from the location of the running application.
Template syntax examples; see the macro source macro funchead.cr for details.
Synopsis:
%[1%FTYPE% %FNAME%%FOPEN% %FARGS% %FCLOSE% // single arg]%
%[2%FTYPE% %FNAME%%FOPEN% %FARGS(13)% %FCLOSE% // multi arg]%
%FTYPE% %FNAME%
%FOPEN%
%FARGS(,72)%
%FCLOSE%
Purpose:
%FDESC%
Parameters:
FINPUTS(9)
%FINPUTS(9)%
FINPUTS(0,+10)
%FINPUTS(0,+10)%
FINPUTS(0,+10,-2)
%FINPUTS(0,+10,-2)%
FINPUTS(0,32,,80,1,,1)
%FINPUTS(0,32,,80,1,,1)%
FINPUTS(0,32,-4,60,1,1)
%FINPUTS(0,32,-4,60,1,1)%
FINPUTS(0,-1)
%FINPUTS(0,-1)%
FINPUTS(0,20,,70,1,1,1)
%FINPUTS(0,20,,70,1,1,1)%
Returns:
%FTYPE% -
extern const string GRTERM;
Terminal override.
The GRTERM global string is used to specify the identifier for the current terminal type as defined by the UNIX terminfo database, similar to the system TERM environment variable. GRTERM should be considered as an override to the standard system TERM specification; it may be used in preference to TERM allowing a GRIEF specialisation without affecting other console applications.
The leading component of the GRTERM specification consists of the terminal base-name. Following the base-name, you may add any reasonable number of hyphen-separated feature suffixes, for example:
xterm-256color
Some of the standard features include,
Feature |
Description |
---|---|
m, mono |
Mono terminal. |
256, 256color |
Terminal supports 256 colours. |
16, 16color |
Terminal supports 16 colours. |
88 |
Terminal support 88 colours. |
During initialisation GRIEF firstly references GRTERM and then secondary the system TERM environment variable values. The derived terminal base-name causes the associated tty macro is be loaded; this macro has the responsible for configuring GRIEF’s keyboard and screen layout using set_term_feature and set_term_keyboard plus related primitives.
extern const string GRTERMCAP;
Terminal capability database.
The GRTERMCAP global string is used to specify the path to the terminal capability database, similar to the system TERMCAP environment variable. GRTERMCAP should be considered as an override to the standard system TERM specification; it may be used in preference to TERMCAP allowing a GRIEF specialisation without affecting other console applications.
GRTERM, <vars>
extern const string GRTMP;
Temporary dictionary.
The GRTMP global string is used to specify the directory within which temporary files are to be created. GRTMP should be considered as an override to the standard system temporary directory specification.
GRIEF firstly references GRTMP; if this is not defined it tries BTMP secondary and then system dependent alternatives, for example TEMP and TEMPDIR.
If no temporary is not defined, or if it is set to the name of a directory that does not exist, temporary files shall be created within a system dependent default.
GRTMP is equivalent to the BRIEF BTMP environment variable.
GRPATH, <vars>
extern const int GRVERSIONMINOR;
GRIEF minor version.
The GRVERSIONMINOR global constant is set to the minor number of the running GRIEF implementation version.
GRVERSIONMAJOR, <vars>
extern const int GRVERSIONS;
Backup versions.
The GRVERSIONS global string is used to specify the number of backup versions to be maintained for each modified file, when buffer backups are enabled. When stated GRIEF shall keep multiple backup copies of each edited file. In the absence of any buffer or global set_backup_option BK_VERSIONS configuration nor the GRVERSIONS environment variable, GRIEF simple keeps the previous image.
When enabled, GRIEF creates a set of n directories given by GRVERSION named 1 through to n; the directory name being number of previous edit sessions the files contained within represent.
For example, given GRBACKUP=~/.backups and GRVERSIONS=3 the following directory structure shall be maintained.
~/.backups
~/.backups/1
~/.backups/2
~/.backups/3
During backup operations, starting from n-1 in reverse order the previous images are rolled into the higher sequenced directory; with any images within the last directory being removed. Finally the most recent is saved into the root of the tree. On completion the oldest version of a file can be found in the nth directory; the next oldest is in n - 1. The most recent backup is the file in the backup directory.
Given the edited file myfile.txt against the above configuration the following backup images may exist:
~/.backups/myfile.txt [latest]
~/.backups/1/myfile.txt
~/.backups/2/myfile.txt
~/.backups/3/myfile.txt [oldest]
extern int errno;
Last system errno number.
When a system call detects an error, it returns an integer value indicating failure (usually -1) and sets the variable errno accordingly. This allows interpretation of the failure on receiving a -1 and to take action accordingly.
Successful calls never set errno; once set, it remains until another error occurs. It should only be examined after an error. Note that a number of system calls overload the meanings of these error numbers, and that the meanings must be interpreted according to the type and circumstances of the call.
See Error Codes for the list of manifest constants exported.
The values reported by errno are system and function dependent.
__breaksw;
Switch break statement.
The __breaksw statement is used to implement the break statement within switch statements.
The __breaksw() primitive is internal to the macro language. It is generated by the GRIEF macro compiler when a break statement is encountered within a switch statement; it is not intended for direct use.
nothing
Jump Statements, switch, while, do, for
void autoload( string filename, string function, ... )
Register location of one or more macros.
The autoload() primitive informs the macro loader about the existence of global macros. The primitive registers the specified macro function against the macro object image filename, permitting an arbitrary number of macro names after the initial function; as such one or more function references may be associated.
Whenever the macro engine encounters an undefined macro reference, it searches the internal autoload list for a definition. If available, the associated macro object shall be loaded as normal, with the loader searching the GRPATH definition for the underlying object image.
If during an autoload driven load the referenced function was not resolved the following diagnostic shall be generated.
load_macro: macro 'xxx' not resolved during autoload.
A function reference may only be associated with one macro object, with any secondary references ignored generating the following diagnostic message.
autoload: 'xxx' already defined.
Example
The macros modeline and mode are registers against the macro object modeline.
autoload("modeline", "modeline", "mode");
filename | String that contains the name of the compiled macro file. |
function | String containing the name of the macro function. |
... | Additional macro function names. |
nothing
n/a
int bless( [int ref], [string classname] )
Associate an object with a class/module.
The bless primitive is reserved for future use.
This primitive informs the dictionary referenced by ref that it is now an object in the classname package. If classname is omitted, the current module is used. Because a bless is often the last thing in a constructor, it returns the reference for convenience.
The bless primitive enables Perl style objects.
Consider always blessing objects in classname’s that are mixed case, using a leading upper-case; Namespaces with all lowercase names are considered reserved for GRIEF pragmata.
n/a
The bless statement returns the dictionary identifier.
A GriefEdit extension.
break;
break statement.
The break statement is used to terminate switch, while, do and for loops.
nothing
Jump Statements, switch, while, do, for
int call_registered_macro( int type )
Invoke registered macro callbacks.
The call_registered_macro() primitive invokes all of functions which have register against the particular event type type.
See register_macro for the particulars on the different registered event types.
type | Event type to be invoked. |
The call_registered_macro returns nothing.
The set of available events differ between systems.
'case' expr:
Switch case statement.
The switch and case statements help control complex conditional and branching operations.
The body of a switch statement may have an arbitrary number of unique case labels.
If condition evaluates to the value that is equal to the value of one of case expressions, then control is transferred to the statement that is labelled with that expression.
If condition evaluates to the value that does not match any of the case labels, and the default label is present, control is transferred to the statement labelled as the default label.
expr | Case value, which can be an integer, float or string expression. |
nothing
continue;
Loop continuation.
The continue statement forces transfer of control to the controlling expression of the smallest enclosing do, for, or <while >loop.
A continue statement may only appear within a loop body, and causes a jump to the inner-most loop-continuation statement (the end of the loop body).
In a while loop, the jump is effectively back to the while.
In a do loop, the jump is effectively down to the while
In a for statement, the jump is effectively to the closing brace of the compound-statement that is the subject of the for loop. The third expression in the for statement, which is often an increment or decrement operation, is then executed before control is returned to the loop’s conditional expression.
none
nothing.
n/a
int create_dictionary( string ~name, int ~tablesize, int ~tablefactor )
Create a dictionary.
The create_dictionary() primitive creates a new dictionary resource.
A dictionary is a collections of associations. Dictionaries consist of pairs of keys and their corresponding values, both arbitrary data values. Dictionaries are also known as associative arrays or hash tables.
name | Optional string containing the unique dictionary name, if omitted the dictionary shall be unnamed. |
size | Optional position integer specifying the size of the underlying table. |
factor | Optional position integer specifying the table fill factor. |
The create_dictionary() primitive returns the identifier associated with the new dictionary.
A GriefEdit extension.
int delete_dictionary( int obj_id )
Destroy a dictionary.
The delete_dictionary() primitive destroys the specified dictionary obj_id.
obj_id | Dictionary identifier. |
The delete_dictionary() primitive returns 0 on success, otherwise -1 on error.
A GriefEdit extension.
void delete_macro( string macro )
Delete a macro from memory.
The delete_macro macro deletes a macro file, which contains one or more macros, from memory; the underlying macro object retains unchanged.
Any keyboard references and variables, both global and buffer will be retained. If any of the macros within the deleted macro object are referenced at a later time, the normal macro load logical is applied which may in turn reload the object.
This primitive is provided for BRIEF compatibility and is currently a no-op as macros are not directly deletable. The storage allocated to a macro shall be lost when a macro by the same name is loaded from another file.
macro | String containing the name of a macro file to be deleted. If no extension is supplied, then .cm shall be appended. If omitted the user is prompted. |
nothing
Not implemented.
int dict_clear( int obj_id )
Clear a dictionary.
The dict_clear() primitive removes all items of the specified dictionary obj_id.
obj_id | Dictionary identifier. |
The dict_clear() primitive returns 0 on success, otherwise -1 on error.
A GriefEdit extension.
delete_dictionary, dict_delete, dict_each, dict_keys, dict_values
int dict_delete( int obj_id, string key )
Remove a dictionary item.
The dict_delete() primitive removes the item associated with the item key from the specified dictionary obj_id.
obj_id | Dictionary identifier. |
key | Item key. |
The dict_delete() primitive returns 0 on success, otherwise -1 on error.
A GriefEdit extension.
delete_dictionary, dict_clear, dict_each, dict_keys, dict_values
int dict_each( int obj_id, [string key], [declare value] )
Iterator a dictionary.
The dict_each() primitive iterates thru a dictionary.
Returns the element index started at one and populates key and value with the entry details, so one may iterate over all elements within the dictionary.
There is no guarantee of order, entries are returned in an apparently random order; driven by the underlying hashing value.
When the dictionary is entirely read, a zero or FALSE value is returned.
You must not modify the dictionary whilst iterating over it. There is a single iterator for each dictionary, shared by dict_each, dict_keys and dict_values primitives, as such care should be taken not to intermix their usage.
The following prints out your environment like the printenv program, only in a different order:
int index;
while ((index = dict_each(dict, key, value)) >= 0) {
insertf("%d:%s=%s\n", index, key, value);
}
obj_id | Dictionary identifier. |
key | Retrieval key. |
value | Value. |
The primitive returns the positive element index on success, otherwise zero at the end of the dictionary.
A GriefEdit extension.
int dict_exists( int obj_id, string key )
Dictionary item existence check.
The dict_exists() primitive determines the existence of an item within the specified dictionary obj_id.
obj_id | Dictionary identifier. |
key | Item key. |
The dict_exists() primitive returns TRUE on success otherwise FALSE.
A GriefEdit extension.
int dict_keys( int obj_id, [string key] )
Iterator dictionary keys.
The dict_keys() primitive iterates thru a dictionary.
Returns the element index started at one and populates key with the entry details, so one may iterate over all elements within the dictionary.
There is no guarantee of order, entries are returned in an apparently random order; driven by the underlying hashing value.
When the dictionary is entirely read, a zero or FALSE value is returned.
You must not modify the dictionary whilst iterating over it. There is a single iterator for each dictionary, shared by dict_each, dict_keys and dict_values primitives, as such care should be taken not to intermix their usage.
The following prints out your environment like the printenv program, only in a different order:
int index;
while ((index = dict_keys(dict, key)) >= 0) {
insertf("%d:%s\n", index, key);
}
obj_id | Dictionary identifier. |
key | Retrieval key. |
The primitive returns the positive element index on success, otherwise zero at the end of the dictionary.
A GriefEdit extension.
list dict_list( int obj_id, [int keys = TRUE] )
Retrieve dictionary items.
The dict_list() primitive retrieves the keys or values contained within the specified dictionary obj_id.
obj_id | Dictionary identifier. |
keys | Optional boolean value unless FALSE key values are retrieved otherwise values are retrieved. |
The dict_list() primitive returns a list of values containing all the keys or values within the specified dictionary, otherwise a null list.
A GriefEdit extension.
string dict_name( int obj_id )
Retrieve a dictionary name.
The dict_name() primitive retrieves the name associated with the specified dictionary obj_id.
obj_id | Dictionary identifier. |
The dict_name() primitive returns the name of the dictionary otherwise an empty string.
A GriefEdit extension.
int dict_values( int obj_id, [declare value] )
Iterator dictionary values.
The dict_values() primitive iterates thru a dictionary.
Returns the element index started at one and populates value with the entry details, so one may iterate over all elements within the dictionary.
There is no guarantee of order, entries are returned in an apparently random order; driven by the underlying hashing value.
When the dictionary is entirely read, a zero or FALSE value is returned.
You must not modify the dictionary whilst iterating over it. There is a single iterator for each dictionary, shared by dict_each, dict_keys and dict_values primitives, as such care should be taken not to intermix their usage.
The following prints out your environment like the printenv program, only in a different order:
int index;
while ((index = dict_each(dict, value)) >= 0) {
insertf("%d=%s\n", index, value);
}
obj_id | Dictionary identifier. |
value | Value. |
The primitive returns the positive element index on success, otherwise zero at the end of the dictionary.
A GriefEdit extension.
declare execute_macro( [string cmd], ... )
Invokes a command by name.
The execute_macro() primitive invokes the specified command cmd, which if omitted the user shall be prompted as follows:
Command:
When an invoked command is undefined, GRIEF shall attempt to load the associated macro file sourced from the directories listed in the GRPATH. If the macro file is successfully loaded and the command is found, the macro is then executed.
The execute_macro primitive cannot be overloaded with a replacement macro.
cmd | Optional string buffer containing the command to be executed. Otherwise if omitted the user shall be prompted for the command. |
... | Depending on the macro, the executed command may expect a sequence of additional arguments. |
The execute_macro() primitive returns the result of the executed command, otherwise upon an error -2 shall be returned..
n/a
void exit( [string y_or_w] )
Exit current process level.
The exit() primitive signals to leave the current process loop, which if the top level loop causes GriefEdit to terminate to the operating system.
Upon leaving the top level prior to exiting when modified buffers are present the user shall be prompted as to whether or not the buffers should be saved, as follows;
1 buffer has not been saved. Exit [ynw]?
The user may have all modified buffers saved prior to terminating by replying with either “W” or “w”, otherwise terminate without saving any buffers using “Y” or “y”. Alternatively the user may reject the exit signal altogether with a reply of “N” or “n”.
y_or_w | Optional string that is applied to the answer regarding the action to occur when modified buffers are detected; Y or y GriefEdit shall exit without saving any modifiers buffers, whereas W or w all modified buffers are written. Any other values other than “YyWW” shall cause the user to be prompted. In addition, the parameter is ignored if exit is being applied to a secondary process loop, which would not cause GriefEdit to terminate. |
nothing
n/a
int first_time()
Determine a macros initialisation status.
The first_time() primitive returns true if this is the first invocation of the calling macro since loading.
Each macro maintains a first_time status, which during the first execution of the macro is true and all subsequent calls shall be *false. This primitive is generally used to perform run-time subsystem initialisation, for example.
if (first_time()) {
initialise();
}
The loading of macro resets the first_time flag, is effect deleting the macro and reloading will look like it was never loaded.
A GRIEF macro compiler utilises this primitive to perform run-time initialisation of function static variables.
none
The first_time() primitive returns true (non-zero) if the first invocation of the associated macro, zero otherwise.
n/a
for ( [initialise]; [condition]; [increment] ) statements;
for statement.
The for statement implements the for loop construct.
for (initialise; condition; increment)
{
statements;
}
Repeatedly performing statements while the condition is true (non-zero).
When the for function starts, initialise is evaluated once. It evaluates condition and if the result is non-zero, it evaluates the statements. Finally, increment is evaluated, and control returns to the condition evaluation. The process is repeated from here until the condition is evaluated zero.
n/a
void foreach( <body>, <expr>, <key>, <value>, <index>, <increment> )
Container iterator.
The foreach statement is reserved for future use.
n/a
The foreach statement returns the element index retrieved, otherwise -1 upon an end-of-source condition or error.
n/a
int fstype( [string path] )
File system type.
The fstype() primitive retrieves the underlying file-system type.
path | Optional string containing path on the file-system to be tested, if omitted the current working directory is referenced. |
The fstype() primitive returns a system dependent file-system identifier, otherwise -1 on error or not supported.
A GriefEdit extension.
declare get_property( int obj_id, string key )
Retrieve a dictionary item.
The get_property() primitive retrieves the value of an item from the specified dictionary obj_id.
This primitive is generally not required within the GRIEF Macro Language. When the user accesses an object member, the compiler converts the construct into calls to this macro.
The following are equivalent;
get_property(object, "member");
and:
object.member;
obj_id | Dictionary identifier. |
key | Item key. |
The get_property() primitive returns the item value otherwise NULL.
A GriefEdit extension.
if ( expr ) true-body
if statement.
The if statement implements the if-then-else construct. The else is optional. Evaluates the condition expr; if the condition is non-zero, executes the if_statements; otherwise, it executes the else_statements.
if (condition)
{ if_statements }
[else]
{ else_statements }
int inq_btn2_action()
Retrieve the second button action.
The inq_btn2_action() primitive is reserved for future BRIEF compatibility.
The inq_btn2_action() primitive retrieves the current action status of the second mouse button. The function can be used to assign a mouse action handler into a newly pushed keyboard, which shall be automatically removed upon the keyboard destruction.
none
Returns the current action button status.
n/a
string inq_called()
Get the name of the calling macro.
The inq_called() primitive returns the callers name, allowing macros to differentiate between being called directly from the command prompt, or from another macro.
This primitive is provided to support replacement macros and to allow macros to determine whether user prompts get_parm are suitable and message output may be required.
The inq_calling() primitive returns a string containing the name of the macro which called the current macro, otherwise an empty string where invoked from the keyboard.
The set_calling_name can be used to modify the value returned in-turn controlling the behaviour of the macros which are then invoked.
int inq_macro( string name, [int mode = 0] )
Determine whether a macro or primitive exists.
The inq_macro() primitive tests whether the specified macro name exists within a stated namespace(s) defined by mode.
name | String containing the macro name to be tested. |
mode | Optional integer test type, if omitted defaults to 0, see table for mode behaviours. |
Tests
The following test behaviours are available given by mode;
Value |
Description |
---|---|
0x00 |
Default behaviour if mode is omitted. inq_macro tests specified macro name against both runtime loaded macros and built-in primitive. It returns 1 if the macro exists (loaded, autoload or a primitive replacement), 0 if it is a built-in primitive, otherwise -1 if neither a built-in primitive nor macro. Note: The returns are incompatible with the original BRIEF implementation. |
0x01 |
inq_macro only tests whether the specified macro name is runtime loaded macro, ignoring built-in primitives. It returns 1 if the macro is loaded, 2 if it exists as an autoload but has yet to be loaded otherwise 0 if the macro does not exist. |
0x02 |
inq_macro returns the assigned positive module number (See: inq_module) if the macro has been loaded, 0 i it is an autoload, otherwise -1 if the macro does not exist. |
0x03 |
inq_macro only tests whether the specified macro name is a primitive, ignoring runtime loaded macros It returns 1 if the primitive exists, 2 if it has been replaced (See: replacement) otherwise 0 if the primitive does not exist. |
The inq_macro() primitive returns a mode specified value, otherwise -1 if the stated mode was invalid.
The autoload visibility under mode 0x01 and mode 0x03 are GriefEdit extensions.
string inq_macro_history( [int index = 0] )
Retrieve macro execution history.
The inq_macro_history() primitive retrieves the name of the previously executed macro as a result of a keyboard binding.
If index is specified, it specifies the history index starting at an offset of zero, otherwise the most recent (i.e. index 0) is returns.
The home and end macros are good examples of its usage, which modify their behaviour based upon previous operations.
index | Optional int index. |
The inq_macro_history() primitive returns the name of the macro invoked, otherwise an empty string if the item does not exist.
A GriefEdit extension, matching similar CRiSPEdit functionality of the same name.
string inq_module( [int test = 1] )
Retrieve the current module.
The inq_module() primitive retrieves the module name assigned with the calling macro. When loaded macros are automaticly assigned with a unique module name or can be specificly assigned using the module primitive.
Module names are used to implement name spaces for static macro functions or to provide a way of creating a macro package split amongst source files.
void
main(void)
{
register_callback( inq_module() + "::callback" );
}
static void
callback(void)
{
}
The inq_module() primitive returns the name of the current module.
A GriefEdit extension.
int inq_msg_level()
Get the message level.
The inq_msg_level() primitive retrieves the current message level.
0 | All messages are enabled; the default value. |
1 | Normal messages are not displayed, error messages still display. |
2 | Error messages are suppressed. |
3 | Suppress all messages, both message and error. |
none
The inq_msg_level() primitive returns the message level.
n/a
list list_of_dictionaries( [bool nonempty = false], [bool named = false] )
List of created dictionaries.
The list_of_dictionaries() primitive retrieves a list of dictionary identifiers created by the create_dictionary primitive.
nonempty | Empty diction filter. Optional integer boolean flag. If specified and is not-zero, then empty directionaries shall be filtered. |
named | Named dictionary filter. Optional integer boolean flag. If specified and is not-zero, then unnamed directionaries shall be filtered. |
The list_of_dictionaries() primitive retrieves a list of dictionaries.
A GriefEdit extension.
int load_macro( string filename, [int reload = 1] )
Load a macro object.
The load_macro() primitive loads the specified macro object filename, resolving all external references in the file.
If filename does not contain a path specification, then all directories contained within the GRPATH environment variable are searched.
If reload is either omitted or non-zero, the macro shall be reloaded regardless of whether the object image has already been loaded using load_macro or a autoload reference. Otherwise if zero the image shall not be reloaded if a image with the same name was loaded previously.
Once a successful load the macro objects main entry point is executed.
Upon loading pre-compiled macro objects (.cm), several interface checks occur confirming whether the object is compatible with the current GRIEF version, for example engine version number and primitive count. Check failure results in a load error and suitable diagnostics being echoed on the command prompt.
filename | String containing the macro object to be loaded. If the specified file has an extension, then an exact match is located. Otherwise files matching one of the following extensions are .cm, .cr, and .m are located. |
reload | Optional boolean flag, if given as false and the same macro object was previously loaded, nothing shall be loaded. |
The load_macro() primitive returns 1 if macro file was successfully loaded; return 2 if reload is non-zero an a loaded image already exists; otherwise 0 on failure.
Unlike BRIEF, macros in source form (.m files) can be loaded with this macro.
The reload option is an GriefEdit extension.
declare macro( list declaration )
Define a macro body.
The macro internal primitive is the mechanism by which macros are imported during the loading of a macro object.
decl | List containing the macro declaration, including scoping flags, macro name and the function body. |
This interface should be considered as a internal primitive, reserved for exclusive use by the GRIEF Macro Compiler and may change without notice. Management of macro definitions plus any associated argument binding shall be handled automatically by the compiler.
Registering an ill-formed macro declaration shall have undefined effects, most likely resulting in GRIEF crashes.
Result of any main and/or associated internal _init execution.
n/a
int module( string modulename )
Assign a module identifier.
GRIEF provides a mechanism for alternative namespaces, being an abstract container providing context for the items, to protect modules from accessing on each other’s variables.
The purpose of this functionality is to provide data hiding within a set of common macro files (objects), by allowing separate function and variables namespaces. Each namespace creates a container for a set of symbols, providing a level of indirection to specific identifiers, thus making it possible to distinguish between identifiers with the same exact name, in effect reducing naming conflicts in unrelated objects (See: Scope).
The module statement declares the object as being in the given namespace. The scope of the module declaration is from the declaration itself and effects all current and future declarations within the associated object.
The intended usage of the module() primitive is the within the main function in all of the related objects.
The namespace specification should be a string containing a valid sequence of identifier symbols of the form
[A-Za-z_][A-Za-z_0-9]*
Namespaces are in conjunction with static scoping of members ((see static )). If you are writing a set of macros some of which are internal and some for external use, then you can use the static declaration specifier to restrict the visibility of a member variable or function.
However as static functions are hidden from usage outside their own macro file (or module), this can present a problem with functionality which involves the usage of callbacks (e.g. assign_to_key). In this case, the :: (scope resolution) operator is used to qualify hidden names so that they can still be used.
Multiple objects can contained within the same namespace. The module primitive allows you to refer to static functions defined in another macro file explicitly, using the “::” naming modifier, and also allows static macro functions to be accessed in callbacks. Upon a module being associated, it is possible to refer use the syntax “<module-name>::<function>” to refer to a function in callbacks.
void
main()
{
module("my_module");
assign_to_key("<Alt-D>", "my_module::doit");
// which to has the identical behaviour as
assign_to_key("<Alt-D>", "::doit");
// and
assign_to_key("<Alt-D>", inq_module() + "::doit");
}
static void
doit()
{
:
:
}
The module primitive returns 0 on success, otherwise 1 if module already existed or -1 if called outside the context of any macro file.
A GriefEdit extension.
inq_module, <scope>, static, assign_to_key
int register_macro( int type, string macro, [int local = FALSE] )
Register a callback procedure.
The registered_macro() primitive registers a function to be invoked upon the trigger of the event type type. Multiple macros may be associated against any particular event type, in which case upon execution they are called in FIFO order.
The argument macro is the name of a macro to be invoked upon the event being triggered. If local is specified and is non-zero, then the macro is only registered against the current buffer, otherwise the event may be triggered even when the current buffer is not selected.
Registered macros may be invoked using call_registered_macro and removed by using the unregister_macro primitive.
Constant |
Description |
---|---|
REG_TYPED |
Character typed. |
REG_EDIT |
Different file edited. |
REG_ALT_H |
ALT-H pressed in response to a prompt. |
REG_UNASSIGNED |
Unassigned key pressed. |
REG_IDLE |
Idle time expired. |
REG_EXIT |
About to exit. |
REG_NEW |
New file edited and readin. |
REG_CTRLC |
CTRL-C (SIGINT) pressed during macro. |
REG_INVALID |
Invalid key pressed during response input. |
REG_INTERNAL |
Internal error. |
REG_MOUSE |
Mouse callback. |
REG_PROC_INPUT |
Process input available. |
REG_KEYBOARD |
Keyboard buffer empty. |
REG_STARTUP |
Startup complete. |
REG_BOOKMARK |
Bookmark dropped/deleted. |
REG_INSERT_MODE |
Insert mode has changed. |
REG_BUFFER_MOD |
Buffer has been modified. |
REG_BUFFER_WRITE |
Buffer write operation. |
REG_BUFFER_RENAME |
Buffer rename operation. |
REG_BUFFER_DELETE |
buffer delete operation. |
REG_FILE_SAVE |
File write request. |
REG_FILE_WRITTEN |
File write completion. |
REG_FILE_CHANGE |
File external change. |
REG_SIGUSR1 |
SIGUSR1 signal trap. |
REG_SIGUSR2 |
SIGUSR2 signal trap. |
type | Event type against which to register. |
name | Name of the macro to be registered. |
local | Optional int, Whether the trigger is of local or global scope. Note currently local is only effective on REG_TYPED. |
The registered_macro() primitive returns 1 if the macro was successfully registered, 0 if already registered, otherwise -1 on error.
The set of available events differ between systems.
int reload_buffer( [int bufnum], [string encoding] )
Reload the buffer content.
The reload_buffer() primitive is reserved for future use.
bufnum | Optional buffer number, if omitted the current buffer shall be referenced. |
encoding | Optional string containing the character encoding to be applied to the source file. |
n/a
n/a
replacement <macro-definition>
Overload an existing macro definition.
The replacement macro modifier is used to explicity declare overloaded interfaces, which is a macro that supersedes (or complements) either another macro or directly executable function of the same name.
Replacement macros are used to intercept calls to other macros or functions and are usually to enhance existing the functionality of thoses commands without rewriting them completely.
For example the following macro replaces edit_file;
edit_file()
{
edit_file();
beep();
}
Any reference to edit_file() in the replacement macro refers to the function which is replaces; hence in this example edit_file(), then calls the orginal edit_file() and then beeps() on its return.
During a compile when a macro which overloads an built-in macro is encountered, the compiler shall generate a warning message. To suppress the warning the keyword replacement should be stated prior to the function name, as follows:
replacement
edit_file()
{
edit_file();
beep();
}
Note that the only behaviour effected by the replacement keyword is the warning suppression and defining a function the same as built-in shall always result in an implicit function overloading. As such the two examples are functionality equivalent.
n/a
n/a
int require( string filename )
Enforce the use of an external module.
The require() primitive enforces that the specified macro object filename be loaded if it has not already been loaded.
This primitive is similar to using load_macro with a reload option of zero, but is provided as a more convenient and explicit form.
The best practice of this primitive, use require within the main function of any given macro object.
void main(void)
{
require("utils"); // our external dependency
}
autoload and require usage should generally be exclusive for any given macro object.
Within CRiSPEdit™ documentation it is stated that the results are undefined due to the tables maintained for each are separate which can result in the macro being mistakenly loaded more then once. As such the side-effect of the reload shall be any global state the macro was maintained shall be lost.
Under GRIEF their usage may be mixed yet for compatibility this style of usage should be avoided.
Returns 0 if already loaded; 1 if the macro as loaded. Otherwise -1 if the macro file could not be loaded.
n/a
int reregister_macro( int type, string macro, [int local = FALSE] )
Register a unique callback procedure.
The reregistered_macro() primitive registers a unique function to be invoked upon the trigger of the event type type. Similar to register_macro yet only permits a single instance of the given function tp be registered.
This primitive allows macros to unconditionally register handlers without need to know whether a previous instance has been installed, unlike register_macro which shall permit multiple instances to exist.
See register_macro for the particulars on the different registered event types.
type | Event type against which to register. |
name | Name of the macro to be registered. |
local | Optional int, Whether the trigger is of local or global scope. Note currently local is only effective on REG_TYPED. |
The reregistered_macro() primitive returns 1 if the macro was uniquely registered, 0 if already registered, otherwise -1 on error.
The set of available events differ between systems.
int restore_position( [int what = 1] )
Restore a previously saved position.
The restore_position() primitive restores a previously saved position from the position stack. The argument what is an optional integer expression which controls the state that is restored.
When states what, specifies the information which is restored. If omitted what is equivalent to one;
0 | Nothing, with the save information being discarded. |
1 | The cursor position is restored. |
2 | The buffer is restored, with the cursor located in the current window at its previous position. |
3 | Reserved. |
4 | The previous buffer and window are restored, with the cursor located at its previous position. |
what | Optional integer states the what elements of the position state to be restored. |
The restore_position() primitive returns 1 on success, otherwise zero or less on error.
n/a
return [<expression>];
Return from a macro.
The return() primitive terminate the current macro and returns the given value expression. If specified expression may be an integer, string or list expression which matches the return type of the associated macro.
If return or returns is not called, the return value for a macro is indeterminate.
expression | Optional value to be returned, which should match the return type of the associated macro. |
nothing
returns ( expression );
Return an expression from a macro.
The returns() primitive sets the return value of the current macro to expression, which may be an integer, string or list expression which matches the return type of the associated macro.
This primitive is similar to the return statement, except it does not cause the current macro to terminate. It simply sets GRIEF’s internal accumulator with the value of the expression; as such any following may overwrite the value.
This primitive is not strictly compatible with the returns macro of BRIEF and is not generally recommended as statements following may have side effects.
expression | Value to be returned, which should match the return type of the associated macro. |
nothing
void save_position()
Saves current cursor/buffer state.
The save_position() primitive pushes the current buffer, window and cursor position into the position stack, allowing them to be restored later using restore_position.
As these states are maintained by a stack in LIFO (Last In First Out) order each invocation of save_position should have a corresponding invocation of restore_position, otherwise saved positions shall accumulate consuming system resources.
That the position stack is an independent of any buffer permitting restore_position to be called to pop off the top entry of the stack even when the current buffer is not the same as buffer referenced by the top of the saved position stack.
none
nothing
n/a
int set_btn2_action( [int action] )
Set the second button action.
The set_btn2_action() primitive is reserved for future BRIEF compatibility.
The set_btn2_action() primitive sets or toggles the default action for the second mouse button. If action is zero, the Quick-Edit action will be the default. If action is non-zero, the Quick-Menu action will be the default. If action is omitted, the current setting shall be toggled.
action | Optional integer, the new Quick-Menu button action. |
Returns the previous action button status.
n/a
void set_calling_name( string name = NULL )
Set the name of the calling macro.
The set_calling_name() primitive sets the calling name of the current macro, which is the name that would be returned by inq_name() within any macros called. If omitted then the name is cleared and returned to the original name.
set_calling_name is used to modify the value returned in-turn controlling the behaviour of the macros which are then invoked.
Another common use is within replacement macros, to forward the original callers name onto the next macro.
set_calling_name(inq_called());
Nothing
string set_macro_history( [int index = 0], [string value] )
Set the macro execution history.
The set_macro_history() primitive replaces an entry within the macro execution history.
index specifies the history index starting at an offset of zero. value is new replace name.
GRIEF maintains the history to the depth of 16.
index | Optional int index. |
The set_macro_history() primitive returns the previous value name of entry replaced, otherwise an empty string if the item does not exist.
A GriefEdit extension, matching similar CRiSPEdit functionality of the same name.
int set_property( int obj_id, string key, [declare value] )
Set a dictionary item.
The set_property() primitive sets the value of an item within the specified dictionary obj_id.
This primitive is generally not required within the GRIEF Macro Language. When the user accesses an object member, the compiler converts the construct into calls to this macro.
The following are equivalent;
set_property(object, "member", value);
and:
object.member = value;
obj_id | Dictionary identifier. |
key | Item key. |
value | Item value. |
The set_property() primitive returns TRUE on success otherwise FALSE.
A GriefEdit extension.
switch( expr ) statement
Switch statement.
The switch and case statements help control complex conditional and branching operations. The switch statement transfers control to a statement within its body. The body of a switch statement may have an arbitrary number of unique case labels, for example.
switch (value) {
case 1:
w = "one";
break;
case 2:
w = "two";
break;
default:
w = "others";
break;
}
If condition evaluates to the value that is equal to the value of one of case expressions, then control is transferred to the statement that is labelled with that expression.
If condition evaluates to the value that does not match any of the case labels, and the default label is present, control is transferred to the statement labelled as the default label.
The break statement, when encountered in statement exits the switch statement.
expr | Switch value, which can be an integer, float or string expression. |
nothing
n/a
throw expr;
Throw an exception.
The throw statement is reserved for future use.
Exceptions are used to indicate that an error has occurred while running the program. Exception objects that describe an error are created and then thrown with the throw primitive. The runtime then searches for the most compatible exception handler.
expr | Exception value. |
nothing
A GriefEdit extension.
try statement; catch statement; finally statement;
Try statement.
The try statement is reserved for future use, which shall implement try, catch and finally exception constructs.
Exceptions are used to indicate that an error has occurred while running the program. Exception objects that describe an error are created and then thrown with the throw primitive. The runtime then searches for the most compatible exception handler.
try {
statement;
} catch type {
statement;
} finally {
statement;
}
none
nothing
A GriefEdit extension.
int unregister_macro( int type, string macro, [int local = FALSE] )
Remove a registered macro.
The unregistered_macro() primitive removes a previously registered macro.
If a particular macro has been registered multiple times than for each successful registration a corresponding unregister must occur to remove all instances; unregister_macro may be called in a loop until all instances are removed.
type | Event type against which to unregister. |
name | Name of the macro to be unregistered. |
local | Optional int, Whether the trigger is of local or global scope. Note currently local is only effective on REG_TYPED. |
The unregistered_macro() primitive returns 1 if macro was registered and has now been unregistered, otherwise 0.
The set of available events differ between systems.
while ( [condition] ) statements;
while statement.
The while statement implements the while loop construct.
while (condition)
{
statements;
}
Repeatedly performs statements while the condition is true (non-zero). In each iteration of the loop, it first tests the condition, and if it is true it executes statement. This cycle is continued until condition is false (zero).
n/a
Iteration Statements, break, continue, for, do
$Id: $
To send feedback on this topic email: grie@gmai l.com fedit
Copyright © Adam Young All Rights Reserved.
BRIEF packages default.
extern const string BPACKAGES;
Operating system identifier.
extern const string CRISP_OPSYS;
Backup path.
extern const string GRBACKUP;
Dictionary locales.
extern const string GRDICTIONARIES;
Dictionary search path.
extern const string GRDICTIONARY;
Default empty file name.
extern const string GRFILE;
Default command line arguments.
extern const string GRFLAGS;
Help search path.
extern const string GRHELP;
GRIEF initialisation name.
extern const string GRINIT_FILE;
Keyboard library search path.
extern const string GRKBDPATH;
GRIEF Nesting level.
extern const int GRLEVEL;
GRIEF diagnostics log file name.
extern const string GRLOG_FILE;
Macro object search path.
extern const string GRPATH;
Profile directory override.
extern const string GRPROFILE;
GRIEF application path.
extern const string GRPROGNAME;
GRIEF resource file path.
extern const string GRRC;
GRIEF initialisation name.
extern const string GRRC_FILE;
GRIEF restore file name.
extern const string GRRESTORE_FILE;
GRIEF state database name.
extern const string GRSTATE_DB;
GRIEF state file name.
extern const string GRSTATE_FILE;
Source template search path.
extern const string GRTEMPLATE;
Terminal override.
extern const string GRTERM;
Terminal capability database.
extern const string GRTERMCAP;
Temporary dictionary.
extern const string GRTMP;
GRIEF major version.
extern const int GRVERSIONMAJOR;
GRIEF minor version.
extern const int GRVERSIONMINOR;
Backup versions.
extern const int GRVERSIONS;
Last system errno number.
extern int errno;
Switch break statement.
__breaksw;
Register location of one or more macros.
void autoload( string filename, string function, ... )
Associate an object with a class/module.
int bless( [int ref], [string classname] )
break statement.
break;
Invoke registered macro callbacks.
int call_registered_macro( int type )
Switch case statement.
'case' expr:
Catch statement.
catch statement;
Loop continuation.
continue;
Create a dictionary.
int create_dictionary( string ~name, int ~tablesize, int ~tablefactor )
Destroy a dictionary.
int delete_dictionary( int obj_id )
Delete a macro from memory.
void delete_macro( string macro )
Clear a dictionary.
int dict_clear( int obj_id )
Remove a dictionary item.
int dict_delete( int obj_id, string key )
Iterator a dictionary.
int dict_each( int obj_id, [string key], [declare value] )
Dictionary item existence check.
int dict_exists( int obj_id, string key )
Iterator dictionary keys.
int dict_keys( int obj_id, [string key] )
Retrieve dictionary items.
list dict_list( int obj_id, [int keys = TRUE] )
Retrieve a dictionary name.
string dict_name( int obj_id )
Iterator dictionary values.
int dict_values( int obj_id, [declare value] )
do statement.
do statement; while ( condition );
else statement.
if ( expr ) true-body else false-body
Invokes a command by name.
declare execute_macro( [string cmd], ... )
Exit current process level.
void exit( [string y_or_w] )
Finally statement.
finally statement;
Determine a macros initialisation status.
int first_time()
for statement.
for ( [initialise]; [condition]; [increment] ) statements;
Container iterator.
void foreach( <body>, <expr>, <key>, <value>, <index>, <increment> )
File system type.
int fstype( [string path] )
Retrieve a dictionary item.
declare get_property( int obj_id, string key )
if statement.
if ( expr ) true-body
Retrieve the second button action.
int inq_btn2_action()
Get the name of the calling macro.
string inq_called()
Determine whether a macro or primitive exists.
int inq_macro( string name, [int mode = 0] )
Retrieve macro execution history.
string inq_macro_history( [int index = 0] )
Retrieve the current module.
string inq_module( [int test = 1] )
Get the message level.
int inq_msg_level()
List of created dictionaries.
list list_of_dictionaries( [bool nonempty = false], [bool named = false] )
Load a macro object.
int load_macro( string filename, [int reload = 1] )
Define a macro body.
declare macro( list declaration )
Assign a module identifier.
int module( string modulename )
Noop.
void nothing()
Register a callback procedure.
int register_macro( int type, string macro, [int local = FALSE] )
Reload the buffer content.
int reload_buffer( [int bufnum], [string encoding] )
Overload an existing macro definition.
replacement <macro-definition>
Enforce the use of an external module.
int require( string filename )
Register a unique callback procedure.
int reregister_macro( int type, string macro, [int local = FALSE] )
Restore a previously saved position.
int restore_position( [int what = 1] )
Return from a macro.
return [<expression>];
Return an expression from a macro.
returns ( expression );
Saves current cursor/buffer state.
void save_position()
Set the second button action.
int set_btn2_action( [int action] )
Set the name of the calling macro.
void set_calling_name( string name = NULL )
Set the macro execution history.
string set_macro_history( [int index = 0], [string value] )
Set a dictionary item.
int set_property( int obj_id, string key, [declare value] )
Switch statement.
switch( expr ) statement
Throw an exception.
throw expr;
Try statement.
try statement; catch statement; finally statement;
Remove a registered macro.
int unregister_macro( int type, string macro, [int local = FALSE] )
while statement.
while ( [condition] ) statements;
Set backup options.
int set_backup_option( int what, [int bufnum], parameter )
Convert an keycode to mnemonic key string.
string int_to_key( int key )
Retrieve the editor nesting level.
int inq_brief_level()
Set a terminal attribute.
int set_term_feature( int|string ident, [string|int value] )
Define terminal keyboard definitions.
int set_term_keyboard( list kbd )
Print error.
string perror( [int errnum = errno], string format, ... )
String error.
string strerror( [int errnum = errno], [string &manifest], [int multi = FALSE] )
Abnormal process.
void abort()
Invoke a Grief engine.
void process()
Define a function or module scope.
static var1, var2, ..;
Iterator though the list elements.
int list_each( list lst, declare & value, [int increment = 1] )
Obtain file information.
int stat( [string path], [int size], [int mtime], [int ctime], [int atime], [int mode], [int uid], [string uid2name], [int gid], [string gid2name], [int nlink], [int inode] )
Retrieve the value of a macro parameter.
int get_parm( [int argument], declare & symbol, [string prompt], [int length = MAXPROMPT], [declare default], [int one = FALSE] )
Display a message on the command line.
int message( string format, ... )
Retrieve name of last keyboard command.
string inq_command()
Set level of informational messages.
int set_msg_level( int level )
Macro entry point.
void main()
Internal macro initialisation.
void _init()
Assign command to key or key sequence.
int assign_to_key( [string key], [string macro] )
Issue an error message on the command line.
int error( string format, ... )
Edit a file.
int edit_file( ... )
Declare an external variable.
extern <type> sym1, sym2, ..;
Declare a global variable.
global sym1, sym2, ..;