Buffer Primitives

Summary
Buffer Primitives
Constants
Buffer FlagsBuffer attribute constants.
Macros
attach_bufferAttach a buffer to a window.
create_bufferCreate and load a buffer.
create_nested_bufferCreate or reference a buffer.
delete_bufferDelete a buffer.
delete_charDelete character.
delete_lineDelete current line.
delete_to_eolDelete to end-of-line.
find_line_flagsLocate next line with specific flags.
find_markerLocate next marker.
goto_bookmarkSeek a bookmark.
inq_attributeRetrieve the current attributes.
inq_buffer_flagsRetrieve buffer flags.
inq_buffer_titleRetrieve a buffer title.
inq_buffer_typeRetrieve buffer type.
inq_byte_posGet current position in buffer stream.
inq_encodingRetrieve a buffers character encoding.
inq_file_changeDetermine state of underlying file.
inq_indentGet current indentation settings.
inq_line_flagsRetrieve a lines associated flags.
inq_line_lengthDetermine the longest line length.
inq_linesRetrieve the line count.
inq_marginsRetrieve buffer formatting margins.
inq_modifiedDetermine a buffers modification status.
inq_namesRetrieve associated buffer names.
inq_positionRetrieve current buffer position.
inq_process_positionGet position of process buffer.
inq_rulerRetrieves the ruler specification.
inq_systemDetermine if buffer is a system buffer.
inq_tabDerive the tab increment.
inq_tabsRetrieves the buffer tab specification.
inq_terminatorRetrieve a buffers line terminator.
inq_timeRetrieve the last modification time.
mark_lineCreate a line marker.
mode_stringConversion stat mode to a string representation.
next_bufferIdentifier of the next buffer.
previous_bufferIdentifier of the previous buffer.
printPrint formatted string to stdout.
set_attributeSet the color attributes.
set_bufferSet the current buffer.
set_buffer_flagsSet buffer flags.
set_buffer_titleSet a buffers title.
set_buffer_typeSet the buffer storage type.
set_encodingSet a buffers character encoding.
set_indentSet the buffers default indentation.
set_line_flagsAssociate line flags.
set_marginsSet buffer formatting margins.
set_process_positionSet process insertion position.
set_rulerConfigure the buffer ruler.
set_tabDerive the buffer tab stops.
set_terminatorSet a buffers line terminator.
sort_bufferSort buffer content.
tabsSet buffer tab stops.
tagdb_closeTag database close.
tagdb_openTag database open.
tagdb_searchTag database search.
write_bufferWrite to buffer content.

Constants

Buffer Flags

Buffer attribute constants.

Description

Buffer flags are represented by bit-fields grouped in one of four sets.  The following section describes the possible values for theses flags:

First

First flag set, representing status and control primary buffer options.

Constant
Description
BF_CHANGED
Changed.
BF_BACKUP
Backup required on next write.
BF_RDONLY
Read-only.
BF_READ
Buffer content still to be read.
BF_EXEC
File is executable.
BF_PROCESS
Buffer has process attached.
BF_BINARY
Binary buffer.
BF_ANSI
If TRUE, ANSI-fication is done.
BF_TABS
Buffer inserts real-tabs.
BF_SYSBUF
Buffer is a system buffer.
BF_LOCK
File lock.
BF_NO_UNDO
Dont keep undo info.
BF_NEW_FILE
File is a new file, so write even if no changes.
BF_CR_MODE
Append <CR> to end of each line on output.
BF_SYNTAX
Enable syntax highlighting (unless ANSI).
BF_SYNTAX_MATCH
Hilite matching braces.
BF_MAN
If TRUE, man style \b is done.
BF_SPELL
Enable spell.
BF_FOLDING
Test folding/hiding.
BF_RULER
Display ruler.
BF_VOLATILE
Buffer is volatile.
BF_EOF_DISPLAY
Show <EOF> markers.
BF_HIDDEN
Hidden buffer, from buffer list
BF_AUTOREAD
Automatically re-read buffer, if underlying changes.
BF_AUTOWRITE
Automatically write buffer, if modified
BF_SCRAPBUF
Scrap buffer.
BF_DELAYED
Content load delayed until first reference.
Second

Second buffer set, controlling general UI formatting options.

Constant
Description
BF2_ATTRIBUTES
Character attributes, enables character cell coloring.
BF2_DIALOG
Dialog
BF2_CURSOR_ROW
Display cursor cross-hair.
BF2_CURSOR_COL
 
BF2_TILDE_DISPLAY
 
BF2_EOL_HILITE
Limit hilites to EOL.
BF2_LINE_NUMBERS
Line numbers
BF2_LINE_OLDNUMBERS
If has line numbers, display old lines
BF2_LINE_STATUS
Markup modified lines.
BF2_LINE_SYNTAX
Syntax preprocessor flags
BF2_TITLE_FULL
Label window using full path name
BF2_TITLE_SCROLL
Scroll title with window
BF2_TITLE_LEFT
Left justify title
BF2_TITLE_RIGHT
Right justify title
BF2_SUFFIX_RO
Read-only suffix on title
BF2_SUFFIX_MOD
Modified suffix on title
BF2_EOL_CURSOR
Limit cursor to EOL
BF2_EOF_CURSOR
Limit cursor to EOF
BF2_HILITERAL
Hilite literal characters
BF2_HIWHITESPACE
Hilite whitespace
BF2_HIMODIFIED
Hilite modified lines
BF2_HIADDITIONAL
Hilite added lines
BF2_HISTATUSLINE
Status line
Third

Third flag set, controlling indirect buffer functionality which are generally implemented at a macro level.

Constant
Description
BF3_AUTOSAVE
Auto-save
BF3_AUTOINDENT
Auto-indent
BF3_AUTOWRAP
Auto-wrap
BF3_PASTE_MODE
Paste mode, disables a number of auto functions.
Fourth

Fourth flag set, controlling file conversion options.

Constant
Description
BF4_OCVT_TRIMWHITE
Output conversion, trim trailing whitespace

See Also

inq_buffer_flags, set_buffer_flags

Macros

attach_buffer

void attach_buffer(int bufnum)

Attach a buffer to a window.

Description

The attach_buffer() primitive attaches the specified buffer to the current window, so that the window becomes a view port into the buffer content.

This interface is generally used in combination with set_buffer, set_window and/or buffer/window creation.  Care should be taken to always have both the current buffer attached to the current window at end of any macros returning control backup, otherwise results are undefined.

For example, create a buffer and window and then associate the two.

int buf = create_buffer("buffer);
int win = create_window(20, 10, 60, 2);
attach_buffer(buf);

When the specified buffer is attached to the current window, the top title of the window is changed to reflect the buffer or file-name associated with the buffer.

Parameters

bufnumBuffer identifier to be attached.

Notes

A few events automatically affect the attached buffer.

  • An explicit attach_buffer() is performed during create_tiled_window calls.
  • Deleting an attached buffer, results in all associated windows being reassigned the top buffer.

Returns

nothing

Portability

n/a

See Also

create_buffer, create_window, inq_buffer

create_buffer

int create_buffer(string bufname,
 [string filename],
  [int sysflag = FALSE],
 [int editflags = 0],
  [string encoding = ""])

Create and load a buffer.

Description

The create_buffer() primitive creates a buffer containing the content of an optional underlying file filename, with the filename being ae full or relative path name of a file which should be read into the buffer.  If this parameter is omitted, then an initially empty buffer will be created.

The buffer name bufname should be unique, and if the buffer already exists a unique name shall be derived by prefixing its name with “ [x]”; x being the next available unique sequence.

The optional arguments sysflag, editflags and encoding control a variety of the buffer features.

Callbacks

Upon buffer loads firstly the _extension callback is executed and either an extension specific callback of the form _ext or _default shall be executed.

In addition any related register_macro callbacks are executed.

Example

The following creates the buffer named “Read-Me” and populates it with the content of the file “readme.txt”.

int buf;

if ((buf = create_buffer("Read-Me", "readme.txt")) >= 0) {
attach_buffer(newbuf);
return buf;
}
message("error loading buffer ...");
return -1;

Parameters

bufnameString containing the unique buffer name.  The name is used as the buffer title, which is usually the same as the underlying filename yet it need not be; for example an abbreviated form.  The buffer names does not affect the file that shall be loaded into the buffer.
filenameOptional string containing the file that the buffer should contain, if omitted an empty buffer is created.
sysflagOptional integer boolean flag stating whether or not the buffer is a system buffer, FALSE for non-system otherwise TRUE for system; if omitted the buffer is assumed to be a non-system.  See inq_system is more details on system buffers.
editflagsOptional buffer creation flags.  These flags control the file mode, see the edit_file primitive for additional information describing this field.
encodingOptional buffer encoding hint.

Returns

The create_buffer() primitive returns the buffer identifier associated with the newly created buffer, otherwise -1 if the buffer was not created.

Note the buffer does not become the current buffer until the set_buffer primitive is used against the returned buffer identifier.

Portability

n/a

See Also

attach_buffer, delete_buffer, set_buffer, create_nested_buffer, set_buffer_title

create_nested_buffer

int create_nested_buffer(string bufname,
  [string filename],
 [int sysflag],
 [int editflags],
  [string encoding])

Create or reference a buffer.

Description

The create_nested_buffer() primitive is similar to the create_buffer primitive yet if the buffer already exists its reference counter is incremented.

For each nested buffer increment delete_buffer must be called, with the buffer only being removed upon the reference count being zero.

This primitive but is provided for convenience when temporary access to a buffer is required, see the ff macro for a working example.

Parameters

bufnameString containing the unique buffer name.  The name is used as the buffer title, which is usually the same as the underlying filename yet it need not be; for example an abbreviated form.  The buffer names does not affect the file that shall be loaded into the buffer.
filenameOptional string containing the file that the buffer should contain, if omitted an empty buffer is created.
sysflagOptional integer boolean flag stating whether or not the buffer is a system buffer, FALSE for non-system otherwise TRUE for system; if omitted the buffer is assumed to be a non-system.  See inq_system is more details on system buffers.
editflagsOptional buffer creation flags.  These flags control the file mode, see the edit_file primitive for additional information describing this field.
encodingOptional buffer encoding hint.

Returns

The create_nested_buffer() primitive returns the buffer identifier associated with the newly created buffer, otherwise -1 if the buffer was not created.

Portability

n/a

See Also

attach_buffer, delete_buffer, set_buffer, create_buffer, set_buffer_title

delete_buffer

void delete_buffer(int bufnum)

Delete a buffer.

Description

The delete_buffer() primitive deletes the specified buffer, the buffer contents and all associated resources are released.

Any changes made to the buffer since it was last written shall be lost, as such if required the content should be written using write_buffer.

In the case of a process buffer, the underlying sub-process is shutdown.

Once deleted, the associated buffer handle is invalid.

Parameters

bufnumNon-optional buffer number.

Returns

nothing

Portability

n/a

See Also

create_buffer, create_nested_buffer, set_buffer

delete_char

void delete_char([int num])

Delete character.

Description

The delete_char() primitive deletes one or more characters at the current cursor position.

This primitive is the default assignment for the <Delete> key on the keyboard.

Parameters

numOptional integer, if stated specifies the number of characters to be deleted, if omitted only a single character is removed.

Returns

nothing

Portability

n/a

See Also

backspace, delete_block, delete_line

delete_line

void delete_line()

Delete current line.

Description

The delete_line() primitive deletes the current line, placing the cursor at the same column on the following line.

Parameters

none

Returns

nothing

Portability

n/a

See Also

delete_char, delete_to_eol

delete_to_eol

void delete_to_eol()

Delete to end-of-line.

Description

The delete_to_eol() primitive deletes from the current cursor position to the end-of-line, not including the newline.  The cursor position remains unchanged.

Parameters

none

Returns

nothing

Portability

n/a

See Also

delete_char, delete_line

find_line_flags

int find_line_flags( [int bufnum],
 [int lineno],
 int mode,
int and_mask,
 [int or_value],
 [int value])

Locate next line with specific flags.

Description

The find_line_flag() primitive positions the cursor at the next line which matches the specified flag value.

bufnum and lineno allow explicit buffer and line number references to be stated, otherwise if omitted the current buffer and/or associated line number shall be used.

flags defines direction and type of equivalence test to be utilised.  and_mask and or_value parameterise the equivalence expression.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
linenoStarting line number.
modeSearch mode flags.
LF_FORWARDSForward search (default).
LF_BACKWARDSBackwards search.
LF_MATCH_EQAbsolute value match against the line flags AND’ed against and_mask and then OR’ed against or_value.
ie.  ((flags & and_mask) | or_value) == value)
LF_MATCH_ANYMatch line flags were any flags contained within the and_mask are set,
ie.  ((flags & and_masK) != 0).
and_maskAND mask.or_valueOR value during LF_MATCH_EQ operations.valueValue being matched during LF_MATCH_EQ operations.

Returns

The find_line_flag() primitive returns the matched line number, 0 if not suitable match was found, otherwise -1 on error, for example invalid parameters.

See Also

find_marker

find_marker

int find_marker([int marker = L_MARKED])

Locate next marker.

Description

The find_marker() primitive positions the cursor at the next line which has a user defined marker enabled.  On successful completion the marker is removed.

marker is the optional marker against which to search, by default L_MARKED.  Only L_MARKED or one of the L_USERx definitions maybe be specified, if other bits or more then one user bit is stated the search shall not succeed.

Returns

The find_marker() primitive returns 1 on success and 0 if no additional markers exist.

See Also

mark_line, find_line_flags

Compatibility

The marker parameter is a GriefEdit extension.

goto_bookmark

int goto_bookmark(int bookid =  NULL,
  [int &bufnum],  
 [int &line],  
 [int &column]  )

Seek a bookmark.

Description

The goto_bookmark() primitive changes the current buffer and cursor location to the values associated with the named bookmark.

bookid is the unique identifier or name associated with the bookmark; any valid integer may be used as the identifier.  If omitted the user shall be prompted for the bookmark identifier.

Go to bookmark:

If any of the arguments bufnum, line or column are specified, these are modified to contain the related bookmark values without effecting the current buffer or location.  If all are omitted the bookmark is applied, updating the buffer and/or cursor location as required.

Parameters

bookidBookmark identifier.
bufnumOptional integer reference, if specified shall be populated with the associate buffer number.
lineOptional integer reference, if specified shall be populated with the buffer line number.
columnOptional integer reference, if specified shall be populated with the buffer column number.

Returns

The goto_bookmark() primitive returns a non-zero value and populate any of the supplied arguments bufnum, line and col.  Otherwise on error returns zero and a related error shall be displayed.

No such bookmark
goto_bookmark: No such buffer

Examples

The following two examples deal with the bookmark labelled as 9.

Retrieves the bookmark definition and echos the details to the user.

int buf, line, column;

goto_bookmark(9, buf, line, column);
message("bookmark: buf=%d, %d/%d", buf, line, column);

Applies the bookmark definition.

goto_bookmark(9);

Portability

n/a

See Also

bookmark_list, delete_bookmark, drop_bookmark

inq_attribute

int inq_attribute(  [int &normal],
[int bufnum])

Retrieve the current attributes.

Description

The inq_attribute() primitive retrieves the text and optionally the normal attribute for the specified buffer bufnum.

Parameters

normalOptional integer reference, if stated is populated with the clear/normal attribute value.
bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

The inq_attribute() primitive returns the current text attribute, otherwise -1 on error.

Portability

A GriefEdit extension.

See Also

set_attribute

inq_buffer_flags

int inq_buffer_flags([int bufnum],
 [string flag|int set = 1],
[string ~flags])

Retrieve buffer flags.

Description

The inq_buffer_flags() primitive retrieves one of the set of flags associated with the specific buffers, see Buffer Flags.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
flag/setOptional internal set identifier, if omitted the primary set(1) shall be referenced.
...Optional string of comma separated flag names.
Flags

The following table summaries the existing flags, for additional on a specific flag consult the set_buffer_flags primitive.

Returns

The inq_buffer_flags() primitive returns the value associated with the selected set of flags.

Portability

The string flag parameter variant is a GRIEF extension.

Many of the flags are GRIEF specific; CRiSP ™ has a similar primitive yet as the two were developed independently features differ.

See Also

set_buffer_flags

inq_buffer_title

string inq_buffer_title([int bufnum])

Retrieve a buffer title.

Description

The inq_buffer_title() primitive retrieves the title associated with the specified buffer.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

String containing the current buffer title.

Portability

n/a

See Also

create_buffer, set_buffer_title

inq_buffer_type

int inq_buffer_type([int bufnum],
 [string &desc],
[string &encoding])

Retrieve buffer type.

Description

The inq_buffer_type() primitive retrieves the buffer type of the buffer bufnum.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
descOptional string variable reference to be populated with the buffer encoding description.
encodingOptional string variable reference to be populated with the buffers character encoding name.

Returns

The inq_buffer_type() primitive returns on the following manifest constants representing the base encoding of the referenced buffer.

Buffer Types

The following manifest constants define the available Buffer Types.

Constant
Description
BFTYP_UNKNOWN
Unknown buffer type.
BFTYP_UNIX
Unix, LF line termination.
BFTYP_DOS
DOS, CF/LF line termination.
BFTYP_MAC
Old style MAX, CR termination.
BFTYP_BINARY
Binary.
BFTYP_ANSI
ANSI.
BFTYP_EBCDIC
EBCDIC.
BFTYP_UTF8
UTF8.
BFTYP_UTF16
UTF16/USC2.
BFTYP_UTF32
UTF32/USC4.
BFTYP_UTFEBCDIC
UTF8/EBCDIC.
BFTYP_BOCU1
Binary Ordered Compression for Unicode.
BFTYP_SCSU
Standard Compression Scheme for Unicode.
BFTYP_UTF7
7-bit Unicode Transformation Format.
BFTYP_GB
GB.
BFTYP_BIG5
BIG5.
BFTYP_ISO2022
ISO-2022.
BFTYP_SBCS
Single Byte.
BFTYP_DBCS
Double Byte.
BFTYP_MBCS
Multi-Byte (Non Unicode).
BFTYP_OTHER
Other supported.
BFTYP_UNSUPPORTED
Known file-type, yet no internal support.

Portability

n/a

See Also

set_buffer_type

inq_byte_pos

int inq_byte_pos([int bufnum],
 [int line],
[int col],
[int flags])

Get current position in buffer stream.

Description

The inq_byte_pos() primitive is reserved for future compatibility.

The inq_byte_pos() primitive calculates and returns the byte offset from the start of the specified buffer with the first byte within the underlying buffer being at offset 0.

This primitive is similar the native library function tell.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
lineOptional line number.
colOptional column.
flagsOffset origin flag, omitted when 0x00.

Returns

The inq_byte_pos() primitive returns the current value of the file-position indicator for the associated buffer measured in bytes from the beginning of the file.  Otherwise, it returns -1 on error.

Portability

n/a

See Also

inq_terminator

inq_encoding

string inq_encoding([int bufnum])

Retrieve a buffers character encoding.

Description

The inq_encoding() primitive retrieves the character encoding associated with the referenced buffer.  See set_encoding for possible encodings.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

The inq_encoding() primitive returns the associated encoding.

Portability

A GriefEdit extension.

See Also

set_encoding

inq_file_change

int inq_file_change([int bufnum])

Determine state of underlying file.

Description

The inq_file_change() primitive determines the state of the file which underlies the specified buffer bufnum.  This primitive checks whether the associated file has been modified or deleted.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

The inq_file_change() primitive returns the reason code for the file state change.

0No change.
1File status detected; possible in-place changes.
2File modified, size differences detected.
3Underlying file does not exist (i.e. has been deleted).
-1Unknown error, the cause of the error condition can be derived from the system return code (See: errno).

Portability

A GriefEdit extension.

See Also

inq_modified, edit_file

inq_indent

int inq_indent([int bufnum])

Get current indentation settings.

Description

The inq_indent() primitive retrieves the current buffer indentation of the specified buffer bufnum.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

Returns the non-zero indentation value if indentation is active, otherwise 0.

Portability

A GriefEdit extension.

See Also

set_indent

inq_line_flags

int inq_line_flags([int bufnum],
[int lineno],
[int& iflags])

Retrieve a lines associated flags.

Description

The inq_line_flags() primitive retrieves the flags associated with the specified line.

The line flags was a set of 32 bit values, with the upper 16 bits being defined for GriefEdit usage and lower 16 bits for user/macro usage.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
linenoLine number within the selected buffer, otherwise if omitted the current line is referenced.
iflagsOptional storage for the associated internal flags.

Returns

Associated line flags.

Compatibility

Internal flags are an GriefEdit extension.

See Also

set_line_flags, find_line_flags

inq_line_length

int inq_line_length([int bufnum])

Determine the longest line length.

Description

The inq_line_length() primitive determines the length of the longest line within the specified buffer bufnum.

The calculate line length corresponds to the logical column position at the end of the line, taking into account any tabs and control characters.

If the designated buffer contains a marked region, then only the lines within the marked region are including within the result.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

The inq_line_length() primitive returns the longest line within the referenced buffer or region, otherwise -1 on error.

Portability

Unlike BRIEF the longest current line is returned.  BRIEF returned the upper global line length rounded up the the next multiple of 16, for example 202 would have been rounded to 208, not a buffer specific value.

See Also

inq_lines

inq_lines

int inq_lines([int bufnum])

Retrieve the line count.

Description

The inq_lines() primitive returns the current line number of the specified buffer bufnum.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

The inq_lines() primitive returns the line count within the referenced buffer, otherwise -1 on error.

Portability

n/a

See Also

inq_line_length

inq_margins

int inq_margins([int bufnum],
 [int &left],
[int &right],
[int &style],
[int &colorcolumn],
 [int global = TRUE])

Retrieve buffer formatting margins.

Description

The inq_margins() primitive retrieves one or more of the specified buffers bufnum current margins.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.  A negative bufnum (e.g.  -1) shall retrieve the global margin parameters, which are applied when no buffer specific margin has been set.
leftOptional left margin.
rightOptional right margin.
styleOptional justification style.
colorcolumnOptional colour column.
globalOptional integer flag, if given as FALSE when retrieving buffer margins the global settings shall not be applied when no buffer specific value is available.

Returns

The inq_margins() primitive returns 0 on success, otherwise -1 on error.

Portability

A GriefEdit extension.

See Also

set_margins

inq_modified

int inq_modified([int bufnum])

Determine a buffers modification status.

Description

The inq_modified() primitive determine whether the specified buffer bufnum has been modified.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Example

The following echos to the command prompt the current buffers modification status.

message("Buffer has %sbeen modified.",
inq_modified() ? "" : "not ");

Returns

The inq_modified() primitive returns the modification status, true when modified otherwise false if the buffer has no changes since loading or the last save.

Portability

n/a

See Also

inq_time, inq_system

inq_names

int inq_names([string fullname],
[string ext],
 [string bufname],
[int bufnum])

Retrieve associated buffer names.

Description

The inq_names() primitive retrieves the file and/or buffer names associated with the specified buffer bufnum.

Parameters

fullnameOptional string variable reference, if specified shall be populated with the full path name of the underlying file, that is used on write_buffer calls.
extOptional string variable reference, if specified shall be populated the file extension taken from the full path.
bufnameOptional string variable reference, if specified shall be populated with buffer name which is used as the buffer title, see set_buffer_title; which is usually the basename, i.e. full path without the path.
bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

The inq_names() primitive returns 0 on success, otherwise -1 on error.

Portability

n/a

See Also

create_buffer, set_buffer_title

inq_position

int inq_position([int &line],
[int &col])

Retrieve current buffer position.

Description

The inq_position() primitive retrieves the current cursor position in the current buffer.

Parameters

lineOptional integer variable when supplied shall be populated with the current buffer line.
colOptional integer variable when supplied shall be populated with the current buffer column.

Returns

The inq_position() primitive returns 0 if the current position is not past the end of the buffer.  Otherwise, the number of lines between the end of the buffer and the current position.

Portability

n/a

See Also

move_abs, move_rel

inq_process_position

int inq_process_position([int &line],
[int &column])

Get position of process buffer.

Description

The inq_process_position() primitive retrieves the current cursor position for the underlying process, this primitive is similar to inq_position.

The process position is used for output from the process; rather than inserting the output from the process where the users cursor is, a separate cursor is maintained instead.

This permits the user to move around the buffer whilst the process is generating output without the process output being sprinkled through the buffer.

Parameters

lineOptional integer variable to be populated with the cursor line.
columnOptional integer variable to be populated with the cursor row.

Returns

The inq_process_position() primitive returns 0 on sucess, otherwise -1 if the current buffer is not attached to a process.

Portability

n/a

See Also

set_process_position, connect

inq_ruler

string|list inq_ruler([int bufnum],
[int min_count],
[int aslist = FALSE])

Retrieves the ruler specification.

Description

The inq_ruler() primitive retrieves the effective indentation specification of the current buffer.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
min_countOptional integer, allows the specification of the minimum number of tab points which shall be presented within the returned specification.
aslistOptional integer boolean flags, if TRUE the tab specification is returned in the form of a list of integers, otherwise by default as a string specification.

Returns

The inq_ruler() primitive either returns a space separated string or an integer list containing the current indentation specification; both are suitable for use by set_ruler.

Portability

A GriefEdit extension.

See Also

set_ruler

inq_system

int inq_system([int bufnum])

Determine if buffer is a system buffer.

Description

The inq_system() primitive determines whether the specified buffer bufnum is marked as a system buffer.

System buffers do not appear in buffer lists, are not editable by users and are handled specially by many macros.  System buffer are generally utilised by macros for internal work pads.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

The inq_system() primitive returns non-zero if the associated buffer is a system buffer, otherwise 0 if the buffer is a normal buffer.

Portability

n/a

See Also

create_buffer, set_buffer_flags, inq_modified

inq_tab

int inq_tab([int bufnum])

Derive the tab increment.

Description

The inq_tab() primitive derives the tab increment in force at the current cursor position.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

Returns the current tab increment, otherwise the default of 8 if none is active.

Portability

An GriefEdit extension.

See Also

tabs, set_indent, set_ruler

inq_tabs

string|list inq_tabs([int bufnum],
[int min_count],
[int aslist = FALSE]))

Retrieves the buffer tab specification.

Description

The inq_tabs() primitive retrieves the effective tabs specification of the current buffer.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
min_countOptional integer, allows the specification of the minimum number of tab points which shall be presented within the returned specification.
aslistOptional integer boolean flags, if TRUE the tab specification is returned in the form of a list of integers, otherwise by default as a string specification.

Returns

The inq_tabs() primitive either returns a space separated string or an integer list containing the current tabs specification; both are suitable for use by tabs.

Portability

A GriefEdit extension.

See Also

tabs, set_indent, distance_to_tab, distance_to_indent

inq_terminator

int inq_terminator([int bufnum],
[string &term])

Retrieve a buffers line terminator.

Description

The inq_terminator() primitive retrieves the line terminator of the specified buffer bufnum.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
termOptional string variable reference, to be populated with the line terminator of referenced buffer.

Returns

The inq_termintor() primitive returns the line terminator type of the specified buffer (See: set_terminator), otherwise -1 on error.

Portability

A GriefEdit extension.

See Also

set_terminator

inq_time

int inq_time([int bufnum],
[int &ctime])

Retrieve the last modification time.

Description

The inq_time() primitive returns the time at which the last modification occurred of the specified buffer bufnum, represented by the number seconds since the beginning of the current edit session.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
ctimeOptional integer value reference, if specified shall be populated with the associated system time, being the number of second since 1970/01/01 UTC.

Returns

The inq_time() primitive returns the time in seconds of last modification, 0 if the buffer has not been modified during the current edit session, otherwise -1 if the buffer is invalid.

Portability

n/a

See Also

inq_modified

mark_line

int mark_line(int flag,
 [int toggleall],
  [int bufnum],
 [int lineno = 0],
 [int marker = L_MARKED])

Create a line marker.

Description

The mark_line primitive controls the value of the user defined line marker within the current buffer.  This mark maybe be utilised by macro developers to maintain a collection of lines on which can then can be queried using find_marker() for additional processing.

The flags parameter controls the mark value; if non-zero true then the marker is set otherwise it is cleared.  When toggleall is stated then the mark status of all lines is toggled, ignoring the flag specification.

bufnum and lineno allow explicit buffer and line number references to be stated, otherwise if omitted the current buffer and/or associated line number shall be used.

marker is the optional marker against which to search, by default L_MARKED.  Only L_MARKED or one of the L_USERx definitions maybe be specified.

Note:

Markers are only a temporary resource which maybe cleared when line are modified, deleted etc.

Returns

The mark_line primitives returns 1 if the marker was already set, 0 if the marker was not set, otherwise -1 when beyond the end of the buffer.

Compatibility

The options bufnum, lineno and marker are GriefEdit extensions.

See Also

find_marker

mode_string

string mode_string([int mode],
[int format = 0],
[string path])

Conversion stat mode to a string representation.

Description

The mode_string() primitive decodes the specified mode into a human readable form using a style similar to ls long listing format output detailing type and permissions, for example

drwxr-xr-x-

Mode String

The decoded mode string consists of a ten character string, using the following format ((see File Modes ))

<type> <owner> <group> <other> <sticky>
Type

The first character indicates the file type and is not related to permissions, when format is omitted or (0) shall be on of the following:

’d’Directory.
’c’Character-device.
’b’Block-device.
’l’Link.
’p’Fifo/pipe.
’s’Sockets.
’n’Name.
’D’Door.
’-’Normal.

The alternative format shall be used when format is given as a non-zero value.  In addition if specified source shall be utilised to verify the status of the link.

’/’Directories.
’-’Character devices.
’+’Block devices.
’~’Directory link.
’!’Broken link.
’@’Link.
’|’Fifo/pipe.
’=’Sockets.
’$’Name/door.
’*’Executable.
’ ‘Normal (space).
Permissions

Following are three permission sets defining the user, group and other access rights.

Each of the three characters represent the read, write, and execute permissions for each of the groups in the order (rwx).

’r’Read permission.
’w’Write permission.
’x’Execute permission
’-’No associated permission read, write or execute.
Sticky

The trailing character details the one of two special attributes.

’S’S_ISUID is set.
’T’S_ISVTX is set.

Parameters

modeOptional mode specification, otherwise the associate mode of current buffer is decoded.
formatOptional format, when stated and non-zero the <type> field is decoded using an alternative form.
pathOptional source of the mode, is supplied shall be utilised to verify the status of links.

Returns

Returns the decoded mode string.

Portability

A GriefEdit extension.

See Also

File Modes, stat, lstat

next_buffer

int next_buffer([int sysflag = 0],
 [int previous],
[int tab])

Identifier of the next buffer.

Description

The next_buffer() primitive retrieves the buffer identifier of the next buffer after the current buffer in the buffer list, optionally filtering system buffers.

The buffer list, which is maintained by the GRIEF kernel, is a circular list of all buffers.  Upon the end of list being reached, the first buffer on the list is returned as the next.

Note:

The next_buffer primitive does not alter the current buffer, the set_buffer can be used to select the returned buffer.

Parameters

sysflagOptional system buffer filter selection.  If either omitted or zero system buffers shall be filtered from the returned identifiers.  Otherwise all buffers including system shall be returned.
prevOptional boolean flag, if stated as non-zero then the previous buffer in the buffer list is retrieved.
tabReserved for future use; tab identifier.

Returns

The next_buffer() primitive returns the buffer identifier of the next or previous buffer.

Portability

n/a

See Also

previous_buffer, set_buffer, create_buffer, inq_buffer, inq_system

previous_buffer

int previous_buffer([int sysflag = 0],
[int tab])

Identifier of the previous buffer.

Description

The previous_buffer() primitive retrieves the buffer identifier of the previous buffer after the current buffer in the buffer list, optionally filtering system buffers.

The buffer list, which is maintained by the GRIEF kernel, is a circular list of all buffers.  Upon the beginning of list being reached, the last buffer on the list is returned as the previous.

Note:

The previous_buffer primitive does not alter the current buffer, the set_buffer can be used to select the returned buffer.

Parameters

sysflagOptional system buffer filter selection.  If either omitted or zero system buffers shall be filtered from the returned identifiers.  Otherwise all buffers including system shall be returned.
tabReserved for future use; tab identifier.

Returns

The previous_buffer() primitive returns the buffer identifier of the previous buffer.

Portability

n/a

See Also

next_buffer, set_buffer, create_buffer, inq_buffer, inq_system

print

int print()

Print formatted string to stdout.

Description

The print() primitive sends the contents of the currently marked area to the printer.

Parameters

none

Returns

0 for success, -1 for printer busy, less than -1 for other printer errors or no marked block.

Portability

n/a

See Also

error, message, dprintf

set_attribute

int set_attribute(  [int|string text],
[int|string normal],
 [int bufnum])

Set the color attributes.

Description

The set_attribute() primitive set the text and/or normal attributes for the specified buffer bufnum.

Parameters

textOptional text attribute either by value or name.
normalOptional clear/normal attribute either by value or name.
bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

The set_attribute() primitive returns the previous text attribute, otherwise -1 on error.

Portability

A GriefEdit extension.

See Also

inq_attribute

set_buffer

int set_buffer(int bufnum)

Set the current buffer.

Description

The set_buffer() primitive makes the buffer identifier specified by bufnum the current buffer, without effecting the current window.  The current is the one referenced by all buffer operations which are not given an explicit buffer identifier.

Generally set_buffer is utilised in one of two ways;

  • Temporarily changing the buffer so to perform specific buffer processing, for example searching for text, and on completion the previous is then restored to the current.
  • Changing the active buffer, which should also involve changing the current window using set_window or associating the new buffer with the current window using attach_buffer.

The set_buffer() primitive unlike edit_file does not cause any registered macros to be executed.

Warning:

The referenced buffer does not always need to be attached to a window nor the one currently associated with the current window set_window, yet upon macro exit the current buffer and current window should be attached otherwise the side-effects may be disastrous.

Parameters

bufnumBuffer identifier to be selected.

Returns

The set_buffer() primitive returns the identifier of the previous current buffer otherwise -1 if an invalid buffer identifier was stated.

On failure the following diagnostics message shall be echoed on the command prompt.

'set_buffer': no such buffer

Portability

n/a

See Also

inq_buffer, create_buffer, next_buffer, previous_buffer

set_buffer_flags

void set_buffer_flags([int bufnum],
 [string|int or_mask],
[string|int and_mask],
 [int set = 1])

Set buffer flags.

Description

The set_buffer_flags() primitive modifies the internal flags associated with the specified buffer, see Buffer Flags.

If specified one or more flags shall be cleared using the and_mask, in additional one or more flags are set using the or_mask.

Each buffer maintains several sets of integer flags which can be modified.  Against the selected flag set the optional and_mask (clear) and then the optional or_mask (set) is applied.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
set_maskOptional mask of flags to set.  May either be an integer of AND’ed together flag constants, or alternatively a string of comma separated flag names.
clear_maskOptional mask of flags to clear.  May either be an integer of AND’ed together flag constants, or alternatively a string of comma separated flag names.
setOptional integer stating the flag set to be modified, if omitted defaults to the primary set(1).

Returns

nothing

Portability

The string mask variants and set parameter are GRIEF extension.

Many of the flags are GRIEF specific; CRiSP ™ has a similar primitive yet as the two were developed independently features differ.

See Also

inq_buffer_flags

set_buffer_title

int set_buffer_title(  [int bufnum],
[string title])

Set a buffers title.

Description

The set_buffer_title() primitive sets the buffer title of the stated buffer otherwise the current buffer when omitted.  The specified title is displayed on the top edge of the buffers associated window.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
titleOptional string value of the title to associated.  If omitted specified, then the buffer title is remove with the buffers underlying filename being used.

Returns

The set_buffer_title() primitives return zero on success, otherwise -1 if the specified buffer does not exist.

Portability

n/a

See Also

inq_buffer_title, create_buffer

set_buffer_type

int set_buffer_type([int bufnum],
 [int type = NULL],
[string encoding = NULL])

Set the buffer storage type.

Description

The set_buffer_type() primitive optionally set the buffer type and/or the character encoding associated with the specified buffer.

Note that the specified encoding has priority over the buffer type, in that an incompatible encoding with the stated type or pre-existing buffer type shall imply the default buffer type associated with the encoding.  The inq_buffer_type() primitive should be used to determine the resulting buffer type on completion.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
typeOptional integer buffer type which states the basic buffer encoding include an implied line termination.
encodingOptional string which sets the specific buffer encoding beyond the buffer type, for example the page code utilized by a BFTYPE_DOS buffer.
Buffer Types

The following manifest constants define the available Buffer Types.

Constant
Description
BFTYP_UNKNOWN
Unknown buffer type.
BFTYP_UNIX
Unix, LF line termination.
BFTYP_DOS
DOS, CF/LF line termination.
BFTYP_MAC
Old style MAX, CR termination.
BFTYP_BINARY
Binary.
BFTYP_ANSI
ANSI.
BFTYP_EBCDIC
EBCDIC.
BFTYP_UTF8
UTF8.
BFTYP_UTF16
UTF16/USC2.
BFTYP_UTF32
UTF32/USC4.
BFTYP_UTFEBCDIC
UTF8/EBCDIC.
BFTYP_BOCU1
Binary Ordered Compression for Unicode.
BFTYP_SCSU
Standard Compression Scheme for Unicode.
BFTYP_UTF7
7-bit Unicode Transformation Format.
BFTYP_GB
GB.
BFTYP_BIG5
BIG5.
BFTYP_ISO2022
ISO-2022.
BFTYP_SBCS
Single Byte.
BFTYP_DBCS
Double Byte.
BFTYP_MBCS
Multi-Byte (Non Unicode).
BFTYP_OTHER
Other supported.
BFTYP_UNSUPPORTED
Known file-type, yet no internal support.

Returns

The set_buffer_type() primitive returns the 0 on success , otherwise -1 on error.

Portability

A GriefEdit extension.

See Also

inq_buffer_type

set_encoding

int set_encoding([string encoding = NULL],
 [int bufnum = NULL])

Set a buffers character encoding.

Description

The set_encoding() primitive sets or clears the character encoding associated with the referenced buffer.

The following table lists the character encodes which maybe available dependent on build options and system support.

Name
Buffer Type
Code Page
Description
US-ASCII
BFTYP_SBCS
646
ANSI/ASCII
ISO-8859-1
BFTYP_SBCS
28591
Western Europe
ISO-8859-2
BFTYP_SBCS
28592
Western and Central Europe
ISO-8859-3
BFTYP_SBCS
28593
Western Europe and South European (Turkish, Maltese plus Esperanto)
ISO-8859-4
BFTYP_SBCS
28594
Western Europe and Baltic countries (Lithuania, Estonia and Lapp)
ISO-8859-5
BFTYP_SBCS
28595
Cyrillic alphabet
ISO-8859-6
BFTYP_SBCS
28596
Arabic
ISO-8859-7
BFTYP_SBCS
28597
Greek
ISO-8859-8
BFTYP_SBCS
28598
Hebrew
ISO-8859-9
BFTYP_SBCS
28599
Western Europe with amended Turkish character set
ISO-8859-10
BFTYP_SBCS
  Western Europe with rationalised character set for Nordic languages
ISO-8859-13
BFTYP_SBCS
28603
Baltic languages plus Polish
ISO-8859-14
BFTYP_SBCS
  Celtic languages (Irish Gaelic, Scottish, Welsh
ISO-8859-15
BFTYP_SBCS
28605
Euro sign and other rationalisations to ISO 8859-1
ISO-8859-16
BFTYP_SBCS
  Central, Eastern and Southern European languages
CP037
BFTYP_EBCDIC
37
EBCDIC-US
CP038
BFTYP_EBCDIC
38
EBCDIC-INT
CP930
BFTYP_EBCDIC
930
 
CP1047
BFTYP_EBCDIC
1047
 
UTF-8
BFTYP_UTF8
65001
 
UTF-16
BFTYP_UTF16
   
UTF-16be
BFTYP_UTF16
1201
 
UTF-16le
BFTYP_UTF16
1200
 
UTF-32
BFTYP_UTF32
   
UTF-32be
BFTYP_UTF32
   
UTF-32le
BFTYP_UTF32
   
BOCU-1
BFTYP_BOCU1
   
SCSU
BFTYP_SCSU
   
UTF-7
BFTYP_UTF7
65002
 
UTF-2
BFTYP_UCS2
  BFTYP_UTF16 aliases
UTF-2be
BFTYP_UCS2
   
UTF-2le
BFTYP_UCS2
   
UTF-4
BFTYP_UCS4
  BFTYP_UTF32 aliases
UTF-4be
BFTYP_UCS4
   
UTF-4le
BFTYP_UCS4
   
cp437
BFTYP_SBCS
437
OEM/US, ASCII
cp737
BFTYP_SBCS
737
Greek, ISO-8859-7
cp775
BFTYP_SBCS
775
Baltic
cp850
BFTYP_SBCS
850
Like ISO-8859-4
cp852
BFTYP_SBCS
852
Like ISO-8859-1
cp855
BFTYP_SBCS
855
Like ISO-8859-2
cp857
BFTYP_SBCS
857
Like ISO-8859-5
cp860
BFTYP_SBCS
860
Like ISO-8859-9
cp861
BFTYP_SBCS
861
Like ISO-8859-1
cp862
BFTYP_SBCS
862
Like ISO-8859-1
cp863
BFTYP_SBCS
863
Like ISO-8859-8
cp865
BFTYP_SBCS
865
Like ISO-8859-1
cp866
BFTYP_SBCS
866
Like ISO-8859-5
cp869
BFTYP_SBCS
869
Greek, like ISO-8859-7
cp874
BFTYP_SBCS
874
Thai
cp1046
BFTYP_SBCS
1046
Arabic DOS code
windows-1250
BFTYP_SBCS
1250
Central European languages that use Latin script (Polish, Czech etc).
windows-1251
BFTYP_SBCS
1251
Cyrillic alphabets
windows-1252
BFTYP_SBCS
1252
Western languages
windows-1253
BFTYP_SBCS
1253
Greek
windows-1254
BFTYP_SBCS
1254
Turkish
windows-1255
BFTYP_SBCS
1255
Hebrew
windows-1256
BFTYP_SBCS
1256
Arabic
windows-1257
BFTYP_SBCS
1257
Baltic languages
windows-1258
BFTYP_SBCS
1258
Vietnamese
Mac-Arabic
BFTYP_SBCS
   
Mac-Celtic
BFTYP_SBCS
   
Mac-Centeuro
BFTYP_SBCS
   
Mac-Croatian
BFTYP_SBCS
   
Mac-Cyrillic
BFTYP_SBCS
   
Mac-Devanaga
BFTYP_SBCS
   
Mac-Dingbats
BFTYP_SBCS
   
Mac-Farsi
BFTYP_SBCS
   
Mac-Gaelic
BFTYP_SBCS
   
Mac-Greek
BFTYP_SBCS
   
Mac-Gujarati
BFTYP_SBCS
   
Mac-Gurmukhi
BFTYP_SBCS
   
Mac-Hebrew
BFTYP_SBCS
   
Mac-Iceland
BFTYP_SBCS
   
Mac-Inuit
BFTYP_SBCS
   
Mac-Roman
BFTYP_SBCS
   
Mac-Romanian
BFTYP_SBCS
   
Mac-Thai
BFTYP_SBCS
   
Mac-Turkish
BFTYP_SBCS
   
cp10000
BFTYP_SBCS
10000
MacRoman
cp10006
BFTYP_SBCS
10006
MacGreek
cp10007
BFTYP_SBCS
10007
MacCyrillic
cp10029
BFTYP_SBCS
10029
MacLatin2
cp10079
BFTYP_SBCS
10079
MacIcelandic
cp10081
BFTYP_SBCS
10081
MacTurkish
KOI8-R
BFTYP_SBCS
20866
Russian, using cynrillic alphabet.
KOI8-U
BFTYP_SBCS
21866
Ukrainian, using cynrillic alphabet.
KOI8-T
BFTYP_SBCS
  Ukrainian
PT154
BFTYP_SBCS
  Ukrainian
KOI7
BFTYP_SBCS
  Ukrainian
MIK
BFTYP_SBCS
0
Bulgarian
ISCII
BFTYP_SBCS
  Indian Script Code for Information Interchange.
TSCII
BFTYP_SBCS
  Tamil Script Code for Information Interchange.
VSCII
BFTYP_SBCS
  Vietnamese Standard Code for Information Interchange.
DEC-MCS
BFTYP_SBCS
-2
 
DEC-KANJI
BFTYP_SBCS
-2
 
DEC-HANYU
BFTYP_SBCS
-2
 
HP-Roman8
BFTYP_SBCS
-3
 
HP-Arabic8
BFTYP_SBCS
-3
 
HP-Greek8
BFTYP_SBCS
-3
 
HP-Hebrew8
BFTYP_SBCS
-3
 
HP-Turkish8
BFTYP_SBCS
-3
 
HP-Kana8
BFTYP_SBCS
-3
 
GB2312
BFTYP_GB
  Guojia Biaozhun/Simplified Chinese.
GBK
BFTYP_GB
936
Chinese/GB (CP936).
GB18030
BFTYP_GB
  Chinese National Standard/GB.
HZ
BFTYP_HZ
  RFC1843, Arbitrarily Mixed Chinese and ASCII.
Big5
BFTYP_BIG5
950
Chinese/Big-5 (CP950).
Big5-5E
BFTYP_BIG5
  Big-5.
Big5-2003
BFTYP_BIG5
  Big-5.
Big5-HKSCS
BFTYP_BIG5
  Big-5/Hong Kong Supplement.
Shift_JIS
BFTYP_MBCS
  Shift JIS.
EUC-JP
BFTYP_MBCS
  Japan/EUC.
CP932
BFTYP_MBCS
932
Windows-31J.
EUC-CN
BFTYP_MBCS
  Chinese/EUC.
EUC-TW
BFTYP_MBCS
  Tawian/EUC.
EUC-KR
BFTYP_MBCS
949
Korean/EUC (CP949).
ISO-2022-CN
BFTYP_ISO2022
   
ISO-2022-KK
BFTYP_ISO2022
   
ISO-2022-KP
BFTYP_ISO2022
   

Parameters

encodingOptional encoding name, if omitted the encoding is derived from the buffer type (See: set_buffer_type).
bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

nothing

Portability

A GriefEdit extension

See Also

inq_encoding, inq_buffer_type

set_indent

int set_indent([int indent],
[int bufnum])

Set the buffers default indentation.

Description

The set_indent() primitive configures the indentation value for the specified buffer, representing the buffers default ruler.  Indentation stops are set every indent stops after the last stop, with the first column within a line being column 1.

Indenting does not change the size represented by physical tabbing, it determines the buffers default indentation when a tab-character is self_inserted(), backfilling with either spaces and/or physical tabs dependent on whether or not hard=tabs are enabled (See: use_tab_char).

An indent value of 0, shall disable the buffers indentation setting defaulting to the current tab stop (See: tabs) unless a ruler is also in effect.  If omitted the user shall be prompted for a new value as follows:

Enter indent amount:

Note that any user specified ruler (See: set_ruler) shall have priority over both this setting and the tabs configuration.

Parameters

indentOptional buffer indentation, if omitted the user shall be prompted.
bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

The set_indent() primitive returns the applied indentation value, otherwise if the user was prompted and they aborted -1 is returned.

Portability

A GriefEdit extension.

See Also

inq_indent, set_ruler, tabs

set_line_flags

int set_line_flags([int bufnum],
[int start],
[int end],
 [int and_mask],
[int or_value])

Associate line flags.

Description

The set_line_flags primitive allows the flags of one or more line within a specific buffer to be modified.

The buffer flags was a set of 32 bit values separated into two namespaces, with the upper 8 bits being defined for user/macro usage and lower bits for system user/macro usage.  As such only the lower 16 bits maybe affected by this primitive.

The defines L_USER1 thru L_USER7 maybe used as manifest constants to access the user/macro area.

Parameters

bufnumBuffer number, if omitted the current buffer is referenced.
startStart line number of region within the selected buffer, otherwise if omitted the current line is referenced.
endEnd of the region within the selected buffer, otherwise if omitted the current line is referenced as such one line shall be affected.
and_maskValue AND’ed with the flags of matched lines.
or_valueValue OR’ed with the flags of matched lines.

Compatiblty

GriefEdit enforces two flag namespaces system and user each of 16 bits with only the lower user 16 bits being read-write, whereas CRiSP ™ allows read-write to all 32 bits.

Returns

The set_line_flags primitive returns the number at lines which were modified.

see Also

inq_line_flags, find_line_flags

set_margins

int set_margins([int bufnum],
 [int left = NULL],
[int right = NULL],
 [int style = NULL],
[int colorcolumn = NULL])

Set buffer formatting margins.

Description

The set_margins() primitive configures one or more of the specified buffers bufnum margins.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.  A negative bufnum (e.g.  -1) shall set the global margin parameters, which are applied when no buffer specific margin has been set.
leftOptional integer left margin.  A non-positive value shall clear the buffer specific margin.
rightOptional integer right margin.  A non-positive value shall clear the buffer speific margin.
styleOptional justification style.
colorcolumnOptional colour column.

Returns

The set_margins() primitive returns 0 on success otherwise -1 on error.

Portability

A GriefEdit extension.

See Also

inq_margins

set_process_position

int set_process_position([int line],
[int column])

Set process insertion position.

Description

The set_process_position() primitive sets the line and/or column associated with the input from a subprocess.

Processes maintain their own independent input in the buffer so that it is easier to write macros which manipulate subprocesses.

Parameters

lineOptional integer specifying the line number, if positive the cursor is set to the specified line.
columnOptional integer specifying the column number, if positive the cursor is set to the specified column.

Returns

The set_process_position() primitive returns 0 on success, otherwise -1 if the current buffer is not attached to a process.

Portability

n/a

See Also

inq_process_position, connect

set_ruler

int set_ruler([int bufnum],
[list|string|int ...])

Configure the buffer ruler.

Description

The set_ruler() primitive configures the indentation ruler of the current buffer to the positions specified within ruler.

The primitive supports a number of alternative specification forms being either a set of integer parameters, a single string parameter containing space/comma separated numbers or a single list of integers.  If omitted the ruler is cleared.

Regardless of the form each should be a sequence of columns in ascending order.  The indentations for the reminder of the line are set using the difference between the last two stated positions, starting at the last specified.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
rulerOptional ruler specification, being the sequence of columns in ascending order otherwise the ruler is cleared.

Returns

The set_ruler() primitive returns the number of applied ruler points, 0 is the ruler was cleared otherwise -1 on error.

Portability

A GriefEdit extension.

See Also

tabs, inq_ruler

set_tab

int set_tab([int increment],
[int bufnum])

Derive the buffer tab stops.

Description

The set_tab() primitive derives a tabs configuration from the specified tab increment increment.  If omitted the user shall be prompted for the tab increment.

Enter tab amount:

Parameters

incrementOptional positive integer, stating the tab increment if omitted the user shall be prompted.
bufnumOptional buffer number, if omitted the current buffer shall be referenced.

Returns

Returns the applied tab increment, otherwise -1 on error.

Portability

A GriefEdit extension.

See Also

tabs

set_terminator

int set_terminator( [int bufnum],
int|string term)

Set a buffers line terminator.

Description

The set_terminator() primitive retrieves the line terminator of the specified buffer bufnum.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
termEither the integer enumeration or string description of the line terminator to be assigned.
Enumerations
Constant
Description
LTERM_UNDEFINED
Unknown/default.
LTERM_NONE
<none> (i.e. binary)
LTERM_UNIX
CR/LF
LTERM_DOS
LF
LTERM_MAC
CR
LTERM_NEL
NEL
LTERM_UCSNL
Unicode next line
LTERM_USER
User defined

Returns

The set_terminator() primitive returns 1 is the line terminator was modified, 0 when no change occurred, otherwise -1 on error.

Portability

A GriefEdit extension.

See Also

inq_terminator

sort_buffer

int sort_buffer([int bufnum],
[string|int comparator = 0],
 [int start],
[int end],
[int type = 3])

Sort buffer content.

Description

The sort_buffer() primitive sorts the lines in the current buffer or the buffer specified by bufnum.  If the buffer specified has a region marked, then only those lines within the region are sorted.

By default lines are sorted alphabetically yet the sort can be modified using the user specified macro or using one of the predefined system sort macros.

Parameters

bufnumOptional buffer number, if omitted the current buffer shall be referenced.
comparatorOptional string comparison macro or integer direction.  A string value states the comparison macro to be executed.  Whereas an integer value states the direction, with zero selecting the built “sort_buffer::forward” comparator and a non-zero value selecting “sort_buffer::backwards”.  If omitted the comparator defaults to forward.
startOptional integer line number stating the start of the region to be sorted, if omitted the buffer top is used unless a marked region is active.
endOptional integer line number stating the end of the region to be sorted, if omitted the buffer end is used unless a marked region is active.
typeOptional integer stating the sort type, being
1quicksort.
2mergesort
3heapsort (default).

Returns

The sort_buffer() primitive returns the number of lines sorted, otherwise a negative value on error.

Portability

Second argument allowing either a sort-order or user specified callback plus type selection are GriefEdit extensions.

See Also

sort_list

tabs

int tabs([string tabs | list tabs | int tab, ...])

Set buffer tab stops.

Description

The tabs() primitive configures the tabs of the current buffer to the positions specified within tabs.

The primitive supports a number of alternative specification forms being a set of integer parameters, a single string parameter containing space/comma separated numbers or a single list of integers.  If omitted the user shall be prompted for each of the tab points, with an empty reply terminating the sequence as follows:

Enter tab stop (return terminates):

Regardless of the form each should be a sequence of columns in ascending order.  Tabs for the reminder of the line are set using the difference between the last two tabs stated, starting at the last specified.

Example

The following sets the first tab at four spaces and all sequence tabs to three resulting in the tabs at (5, 8, 11, 14 ...)

tabs(5, 8);

As the tab primitive allows a number of specification forms, all the following are equivalent;

tabs("5 8");
tabs("5,8");
list ttabs = {5, 8};
tabs(ttabs);

Parameters

’tabs’Optional tabs specification, being the sequence of columns in ascending order otherwise the user is prompted.

Returns

The tabs() primitive returns the number of applied tab points otherwise if the user was prompted and they aborted -1 is returned.

Portability

BRIEF limited the number of unique tab stops at 8, under GriefEdit this limit is 80.

See Also

inq_tabs, set_indent, distance_to_tab, distance_to_indent

tagdb_close

int tagdb_close(int handle)

Tag database close.

Description

The tagdb_close() primitive closes a tag database handle, so that it no longer refers to any resources and may be reused.

Parameters

handleTag database handle.

Returns

nothing

Portability

A GriefEdit extension.

See Also

tagdb_open, tagdb_search

tagdb_open

int tagdb_open(  string file,
 [int options],
 [int background])

Tag database open.

Description

The tagdb_open() primitive given a pathname for a ctags database, returns a handle being a non-negative integer for use in subsequent database search operations using tagdb_search.  The tag database handle shall remain open until <tagtb_close> is executed against the handle.

ctags is a tool which permit easy navigation thru a large set of source files. ctags supports many languages including c, c++ and Java just to name a few.

Note:

GriefEdit relies on an external tag file generator.  There are many versions of ctags; however, the recommended version is “Exuberant Ctags” available from

http://ctags.sourceforge.net/.

GriefEdit is generally bundled with a recent version within the bin installation folder as extags.  Therefore, you would not need to download/install a tag binary to use this feature.

Parameters

  • TAG_ETAGS
  • TAG_CTAGS
filetag database path.
optionsOptional integer flags, being one or more of the following constants OR’ed together forming open options.
backgroundOptional integer boolean value, if true the database loading shall be moved into the background.

Returns

The tagdb_open() primitive returns the new database descriptor, otherwise -1 if an error occurred.

Portability

A GriefEdit extension.

See Also

tagdb_search, tagdb_close

tagdb_search

int tagdb_search(  int handle,
string word,
 [int flags])

Tag database search.

Description

The tagdb_search() primitive searches the tag database for symbols matching pattern.

Note:

Consult the tags macro source for an example.

Parameters

handleTag database handle.
patternString containing the search pattern.
flagsOptional integer flags.

Returns

The tagdb_search returns a list containing the search results, otherwise a NULL list on error or no match was found.

Portability

A GriefEdit extension.

See Also

tagdb_open, tagdb_close

write_buffer

int write_buffer(  [string filename],
[int flags],
[string encoding])

Write to buffer content.

Description

The write_buffer() primitive writes the content of the current buffer to its associated file.

Parameters

filenameOptions string containing the name of the output filename.  If omitted then the file is written to the name associated with the current buffer during creation using <<create_buffer>.
flagsOptional integer flags, one or more of the following flags OR’ed together control the functions of the write operation.
encodingOptional string containing the character encoding to be utilised within the output file.
Flags
Constant
Description
WRITE_APPEND
Append, otherwise overwrite.
WRITE_NOTRIGGER
Do not generate buffer triggers.
WRITE_NOREGION
Ignore any selected region.
WRITE_FORCE
Force write, even if no change.
WRITE_BACKUP
Generate a backup image regardless whether already performed for this edit session.

Returns

  • Returns greater than zero on success.
  • Returns zero if file was not saved, eg. because the file has already been saved.
  • Returns less than zero if an error occurs.
Value
Description
-1
Disk space occurred.
-2
Output file could not be created.
-3
The output file was created with a different temporary name but could not be renamed to the target file due to permission errors.
-4
User aborted the attempt to save the file from one of the callback triggers.
-5
The output buffer does not have a valid filename.
-6
The originally loaded file has changed its permissions, size or status on disk.  This option avoids potentially losing work when someone else has written to the file whilst we were editing it.
-7
The file is read-only, either due to file writes having been disabled by the command line switch (-R) or the current file permissions.

In many cases the underlying cause of the error condition can be derived from the system return code (See: errno), for example out of disk space.

Portability

Flags are incompatible with CrispEdit™

write_buffer([string filename], [int and_flags], [or_flags])

See Also

edit_file

$Id: $

To send feedback on this topic email: grie.nosp@m.fedit@gmai.nosp@m.l.com

Copyright © Adam Young All Rights Reserved.

void attach_buffer(int bufnum)
Attach a buffer to a window.
int create_buffer(string bufname,
 [string filename],
  [int sysflag = FALSE],
 [int editflags = 0],
  [string encoding = ""])
Create and load a buffer.
int create_nested_buffer(string bufname,
  [string filename],
 [int sysflag],
 [int editflags],
  [string encoding])
Create or reference a buffer.
void delete_buffer(int bufnum)
Delete a buffer.
void delete_char([int num])
Delete character.
void delete_line()
Delete current line.
void delete_to_eol()
Delete to end-of-line.
int find_line_flags( [int bufnum],
 [int lineno],
 int mode,
int and_mask,
 [int or_value],
 [int value])
Locate next line with specific flags.
int find_marker([int marker = L_MARKED])
Locate next marker.
int goto_bookmark(int bookid =  NULL,
  [int &bufnum],  
 [int &line],  
 [int &column]  )
Seek a bookmark.
int inq_attribute(  [int &normal],
[int bufnum])
Retrieve the current attributes.
int inq_buffer_flags([int bufnum],
 [string flag|int set = 1],
[string ~flags])
Retrieve buffer flags.
string inq_buffer_title([int bufnum])
Retrieve a buffer title.
int inq_buffer_type([int bufnum],
 [string &desc],
[string &encoding])
Retrieve buffer type.
int inq_byte_pos([int bufnum],
 [int line],
[int col],
[int flags])
Get current position in buffer stream.
string inq_encoding([int bufnum])
Retrieve a buffers character encoding.
int inq_file_change([int bufnum])
Determine state of underlying file.
int inq_indent([int bufnum])
Get current indentation settings.
int inq_line_flags([int bufnum],
[int lineno],
[int& iflags])
Retrieve a lines associated flags.
int inq_line_length([int bufnum])
Determine the longest line length.
int inq_lines([int bufnum])
Retrieve the line count.
int inq_margins([int bufnum],
 [int &left],
[int &right],
[int &style],
[int &colorcolumn],
 [int global = TRUE])
Retrieve buffer formatting margins.
int inq_modified([int bufnum])
Determine a buffers modification status.
int inq_names([string fullname],
[string ext],
 [string bufname],
[int bufnum])
Retrieve associated buffer names.
int inq_position([int &line],
[int &col])
Retrieve current buffer position.
int inq_process_position([int &line],
[int &column])
Get position of process buffer.
string|list inq_ruler([int bufnum],
[int min_count],
[int aslist = FALSE])
Retrieves the ruler specification.
int inq_system([int bufnum])
Determine if buffer is a system buffer.
int inq_tab([int bufnum])
Derive the tab increment.
string|list inq_tabs([int bufnum],
[int min_count],
[int aslist = FALSE]))
Retrieves the buffer tab specification.
int inq_terminator([int bufnum],
[string &term])
Retrieve a buffers line terminator.
int inq_time([int bufnum],
[int &ctime])
Retrieve the last modification time.
int mark_line(int flag,
 [int toggleall],
  [int bufnum],
 [int lineno = 0],
 [int marker = L_MARKED])
Create a line marker.
string mode_string([int mode],
[int format = 0],
[string path])
Conversion stat mode to a string representation.
int next_buffer([int sysflag = 0],
 [int previous],
[int tab])
Identifier of the next buffer.
int previous_buffer([int sysflag = 0],
[int tab])
Identifier of the previous buffer.
int print()
Print formatted string to stdout.
int set_attribute(  [int|string text],
[int|string normal],
 [int bufnum])
Set the color attributes.
int set_buffer(int bufnum)
Set the current buffer.
void set_buffer_flags([int bufnum],
 [string|int or_mask],
[string|int and_mask],
 [int set = 1])
Set buffer flags.
int set_buffer_title(  [int bufnum],
[string title])
Set a buffers title.
int set_buffer_type([int bufnum],
 [int type = NULL],
[string encoding = NULL])
Set the buffer storage type.
int set_encoding([string encoding = NULL],
 [int bufnum = NULL])
Set a buffers character encoding.
int set_indent([int indent],
[int bufnum])
Set the buffers default indentation.
int set_line_flags([int bufnum],
[int start],
[int end],
 [int and_mask],
[int or_value])
Associate line flags.
int set_margins([int bufnum],
 [int left = NULL],
[int right = NULL],
 [int style = NULL],
[int colorcolumn = NULL])
Set buffer formatting margins.
int set_process_position([int line],
[int column])
Set process insertion position.
int set_ruler([int bufnum],
[list|string|int ...])
Configure the buffer ruler.
int set_tab([int increment],
[int bufnum])
Derive the buffer tab stops.
int set_terminator( [int bufnum],
int|string term)
Set a buffers line terminator.
int sort_buffer([int bufnum],
[string|int comparator = 0],
 [int start],
[int end],
[int type = 3])
Sort buffer content.
int tabs([string tabs | list tabs | int tab, ...])
Set buffer tab stops.
int tagdb_close(int handle)
Tag database close.
int tagdb_open(  string file,
 [int options],
 [int background])
Tag database open.
int tagdb_search(  int handle,
string word,
 [int flags])
Tag database search.
int write_buffer(  [string filename],
[int flags],
[string encoding])
Write to buffer content.
int set_window(int winnum)
Set the active window.
int create_tiled_window(int lx,
int by,
int rx,
int ty,
 [int bufnum])
Creates a tiled window.
int create_window(int lx,
int by,
 int rx,
int ty,
 [string message])
Create a popup window.
int inq_buffer([string filename])
Retrieve a buffer identifier.
void _extension(string ext)
Buffer load handler.
void _default(string ext)
Default extension handler.
int register_macro(int type,
 string macro,
 [int local = FALSE])
Register a callback procedure.
int edit_file(...)
Edit a file.
void backspace([int num = 1])
Delete character to the left of the cursor.
int delete_block()
Deleted selected region.
list bookmark_list()
Retrieve existing bookmark list.
void delete_bookmark(int bookid)
Delete a bookmark.
int drop_bookmark([int bookid],
[string yesno],
 [int bufnum],
[int line],
[int column],
[int local = FALSE])
Create or update a bookmark.
Buffer attribute constants.
extern int errno;
Last system errno number.
int move_abs([int line = -1],
[int column = -1],
 [int bufnum],
[int clip = FALSE])
Move to an absolute location in the buffer.
int move_rel([int lines = 1],
[int cols = 1])
Move to a relative location in the buffer.
int connect(int mode,  
string shell =  NULL,
string cwd =  NULL)
Attach a process to a process.
int distance_to_tab([int column])
Calculate distance to next tab.
int distance_to_indent([int column])
Calculate distance to next indent.
Traditional Unix file mode consist of a number of components including type, permissions including special bits.
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])
Obtain file information.
int lstat(string path,
 [int size],
  [int mtime],
 [int ctime],
 [int atime],
 [int mode],
  [int uid],
 [string uid2name],
  [int gid],
 [string gid2name],
  [int nlink],
 [int inode])
Get symbolic link status.
int error(string format,
 ...)
Issue an error message on the command line.
int message(string format,
 ...)
Display a message on the command line.
int dprintf(string format,
 ...)
Formatted diagnostics output.
int use_tab_char([int|string yesno],
[int global = FALSE])
Configure use of hard/soft tabs.
list sort_list(list lst,
  [string|int comparator = 0],
 [int type = 3])
Sort list.