Environment Primitives | |
Macros | |
cd | Change directory. |
create_char_map | Create a display character-map. |
get_term_characters | Retrieve terminal special characters. |
get_term_feature | Get value of a terminal feature. |
get_term_features | Retrieve terminate features. |
get_term_keyboard | Retrieve the terminal keyboard definitions. |
getenv | Retrieve an environment variable. |
geteuid | Retrieve the effective user identifier. |
getpid | Retrieve the process identifier. |
getuid | Retrieve the user identifier. |
getwd | Get current working directory. |
inq_backup | Get the backup creation mode. |
inq_backup_option | Get backup options. |
inq_brief_level | Retrieve the editor nesting level. |
inq_char_timeout | Get the escape delay. |
inq_environment | Retrieve an environment variable. |
inq_feature | Retrieve an editor feature. |
inq_hostname | Retrieve the local host name. |
inq_idle_default | Retrieve idle interval. |
inq_idle_time | Retrieve keyboard idle time. |
inq_profile | Retrieve profile directory. |
inq_username | Retrieve the user name. |
putenv | Set an environment variable. |
set_backup | Set backup creation mode. |
set_backup_option | Set backup options. |
set_char_timeout | Set the escape delay. |
set_idle_default | Set idle interval. |
set_term_characters | Set terminal special characters. |
set_term_feature | Set a terminal attribute. |
set_term_features | Define terminal attributes. |
set_term_keyboard | Define terminal keyboard definitions. |
uname | Retrieve system information. |
int cd( [string dir] )
Change directory.
The cd() primitive changes the current directory on the specified drive to the specified path. Unlike chdir shell expansion shall occur when the path contains special characters, expanding home references ~, wild cards and environment variables.
cd(newdir);
Under DOS/WIN32, if no drive is specified in path then the current drive is assumed. The path can be either relative to the current directory on the specified drive or it can be an absolute path name
If dir is omitted, the current directory shall be echoed on the command prompt without effecting any change.
cd();
The cd() primitive returns 1 if successful otherwise zero on error. When an error has occurred, the global errno contains a value indicating the type of error that has been detected.
int create_char_map( [int mapid|string name], [int start = 0], [list chars], [list flags], [string name] )
Create a display character-map.
The create_char_map() primitive either creates or updates an existing character-map. Character-map’s determine the mapping between the buffer encoding, special purpose characters and their display representation.
A map represents each of the 256 possible byte values which may be contained within any given 8-byte encoded buffer. In addition to the 256 base characters a number of special markers for End-Of-Line, Tabs and End-Of-File may also be defined.
The identifier mapid or the alias name either references an existing map or if omitted a new map shall be generated. On creation a character-map is derived from the system “normal” map.
Upon the existing or created map the specified chars list is then applied starting at the character start, updating each character in sequence until the end of the list is encountered. Optionally the pairs of integer values contained within the flags list are then applied in the same manor. If specified, the character-maps alias is changed to name.
Character-map Names
By default two system predefined character-map’s are available known by the names “normal” and “binary”, these are in addition to the number managed by the view’s package; care should be taken not to overwrite these resources prior to understanding the impact.
Special Characters
The follow special character indexes have importance when displaying buffer content and can be controlled using create_char_map for example.
create_char_map("literal", CMAP_EOF, quote_list("[EOF]"));
Constant |
Value |
Description |
---|---|---|
CMAP_TABSTART |
- |
Beginning of a Tab |
CMAP_TABVIRTUAL |
- |
Tab body |
CMAP_TABEND |
- |
Tab end |
CMAP_EOL |
- |
End-of-line marker |
CMAP_EOF |
- |
End-of-file marker |
By default, all specials are simple spaces as such invisible.
Note, for CRiSP ™ compatibility the char list may reference 257 characters with the 257th entry being equivalent to CMAP_EOL.
Character Flags
The flags argument should be given as a set of one or more integer pairs:
{ <character>, <flag> }
The character flags available include, with one
Constant |
Value |
Description |
---|---|---|
CMAP_DEFAULT |
0 |
Default |
CMAP_TAB |
1 |
Horizontal tab |
CMAP_BACKSPACE |
2 |
Backspace |
CMAP_ESCAPE |
3 |
ESCAPE character |
Normal Character Map
The “normal” or default character-map is built using the rules below.
mapid, name | Character-map reference, being either an integer map identifier or the associated map name as a string. If omitted a unique identifier shall be allocated. |
start | Optional integer, stating the first character index. |
chars | Character definition list, being a list of integer and/or string values for each character in the sequence starting at the offset start. |
flags | Character flag list, being one or more pairs of integer values. Within each pair, The first element is the integer character position, and the second is the integer flag value from the set “Character Flags”. |
name | Optional string, being the unique name by which the character-map may be referenced. |
The create_char_map() primitive returns the identifier of the resolved or created character-map otherwise -1 if the specified character map does not exist.
The following enables an ASCII representation for control characters 0 to 31.
int map =
create_char_map(0, NULL,
quote_list(
"<NUL>", "<SOH>", "<STX>", "<ETX>",
"<EOT>", "<ENQ>", "<ACK>", "<BEL>",
"<BS>", "<HT>", "<NL>", "<VT>",
"<FF>", "<CR>", "<SO>", "<SI>",
"<DLE>", "<DC1>", "<DC2>", "<DC3>",
"<DC4>", "<NAK>", "<SYN>", "<ETB>",
"<CAN>", "<EM>", "<SUB>", "<ESC>",
"<FS>", "<GS>", "<RS>", "<US>"),
quote_list('\t', CMAP_TAB));
set_buffer_cmap(map);
n/a
list get_term_characters( [top_left], [top_right], [bottom_left], [bottom_right], [vertical], [horizontal], [top_join], [bottom_join], [cross], [left_join], [right_join], [scrol], [thumb] )
Retrieve terminal special characters.
The set_term_characters() primitive retrieves the set of characters which are utilised by the tty console driver to represent window borders.
set_term_characters() operators in one of two modes. Without arguments a list of strings, one for each character is retrieved. Alternatively each parameter is either an integer or string variable to be populated with the associated character value. Values can be omitted by supplying a NULL parameter against the associated character index.
Refer to set_term_characters for the order and meaning of each of these characters.
... | Integer character value or string escape sequence, one for each character within the set. |
Without any arguments the get_term_characters primitive returns a list of strings, one for each terminal character, in the form name=value. Otherwise a NULL list is returned.
n/a
int get_term_feature( string | int ident, declare value )
Get value of a terminal feature.
The get_term_feature() primitive retrieves the value associated with the specified attribute ident.
ident | Either the integer identifier or the a string containing the name of the terminal attribute to be retrieved. |
value | Variable to populated with the referenced attribute. |
The set_term_feature() primitive returns 0 on success, otherwise 1 on error.
A GriefEdit extension.
list get_term_features( ... )
Retrieve terminate features.
The get_term_features() primitive retrieves a list of string pairs one for each terminal attribute.
none
Without any arguments the get_term_features() primitive returns a list of strings, one for each terminal attribute, in the form name=value. Otherwise a NULL list is returned.
Many of the return values are only meaningful on systems that use a tty based console interface.
The CRiSPEdit™ version is similar to get_term_feature.
list get_term_keyboard()
Retrieve the terminal keyboard definitions.
The get_term_keyboard() primitive retrieves the current terminal keyboard definition.
Under Unix™ console attributes are derived from the system termcap or terminfo databases or similar interfaces under non-unix systems.
See get_term_keyboard for further details.
none
The get_term_keyboard() primitive returns a list of key binding pairs, each pair consisting of an integer key-code plus a string containing the associated escape sequence.
On systems not utilising a tty based console interface, the list shall be empty.
string getenv( string name )
Retrieve an environment variable.
The getenv() primitive searches the environment of the calling process for the environment variable name if it exists and returns the value of that environment variable. If the specified environment variable cannot be found, an empty string shall be returned.
name | String containing the name of the environment variable. |
The getenv() primitive returns the value of the corresponding environment variable, otherwise an empty string.
n/a
int getwd( int ignored, string dir )
Get current working directory.
The getwd() primitive primitive retrieves the name of the current working directory.
The ignored parameter exists for compatibility with BRIEF.
The getwd() primitive returns 1 if successful otherwise zero on error. When an error has occurred, the global errno contains a value indicating the type of error that has been detected.
int inq_backup( [int bufnum] )
Get the backup creation mode.
The inq_backup() primitive retrieves the value of the associated objects backup mode. If bufnum is specified, then the value of the stated buffer is returned, otherwise upon being omitted the global (default) backup mode shall be returned.
The inq_backup() primitive returns the current value of the backup flag.
A GriefEdit extension.
declare inq_backup_option( int what, [int bufnum] )
Get backup options.
The inq_backup_option() primitive retrieves the value of the backup option what for the associated object. If bufnum is specified, then the value of the stated buffer is returned, otherwise upon being omitted the global (default) backup option shall be modified.
The inq_backup_option() primitive returns the current value associated with the attribute what, as follows
A GriefEdit extension.
int inq_brief_level()
Retrieve the editor nesting level.
The inq_brief_level() primitive retrieves the number of copies of GRIEF running within the current session.
The original implementation returned the total number of instances in memory, whereas this emulation only reports the number of instances visible with the associated terminal.
This function is provided for compatibility using the getenv interface; see the getenv primitive and the brief macro module for details.
none
The current number of active editor sessions.
Provided for BRIEF compatibility, retrieving the current GRLEVEL environment variable level.
string inq_environment( string name )
Retrieve an environment variable.
The inq_environment() primitive shall search the environment of the calling process for the environment variable name if it exists and return the value of the environment variable. If the specified environment variable cannot be found, an empty string shall be returned.
This function is provided for compatibility using the getenv interface; see the getenv primitive and the brief macro module for details.
name | String containing the name of the environment variable. |
The inq_environment() primitive returns the value of the corresponding environment variable, otherwise an empty string.
n/a
int|list inq_feature( [int|string feature], [string value] )
Retrieve an editor feature.
The inq_feature() primitive tsets the status of the specific feature feature, returning its current configuration value.
The inq_feature() primitive is an experimental interface and may change without notice.
feature | Name of the feature. |
value | Configuration value. |
The inq_feature() primitive returns non-zero on success, otherwise zero on error.
Macro Portability; A GriefEdit extension.
set_feature, inq_display_mode, <set>
int inq_idle_default()
Retrieve idle interval.
The inq_idle_default() primitives retrieves the current keyboard idle interval, see set_idle_default.
none
The inq_idle_default() primitives returns the current value of the interval timer.
n/a
int inq_idle_time()
Retrieve keyboard idle time.
The inq_idle_time() primitives retrieves the number of seconds since the user last pressed a key, representing the time keyboard input has been idle.
none
The inq_idle_time() primitive returns the idle timer in seconds.
n/a
string inq_profile()
Retrieve profile directory.
The inq_profile() primitive retrieves the directory within which user specific profile information can be stored, examples include the restore state and personal dictionary.
This directory shall be system specific.
~/.grief
C:\Documents and Settings\<user>\Application Data\.grief.
none
The inq_profile() primitive returns a string containing system dependent profile directory.
A GriefEdit extension.
void putenv( string name, [string value] )
Set an environment variable.
The putenv() primitive shall use the string arguments to set the value of an environment variable.
The arguments must construct a string of the form
"name=value"
This construction may be stated by one or two means. Firstly by the explicit string arguments name and value, or alternatively a single argument name already correctly formed containing both components separated by an embedded = within the string.
name | String containing the name of the environment variable and if value is omitted should also contain the associated value separated by an equals =. |
value | Optional value to be assigned. |
Upon successful completion, putenv shall return one on success, otherwise zero and set errno to indicate the error.
A GriefEdit extension.
int set_backup( int mode, [int bufnum] )
Set backup creation mode.
The set_backup() primitive either toggles, set or retrieves the current backup flag of the associated object. If bufnum is specified, then the stated buffer is effected, otherwise upon being omitted the global (default) backup mode shall be effected.
The backup flag is tested each time a buffer is written to its underlying storage (See: write_buffer). The flag maybe one of two states, either off or on; when on, then a backup files shall be created.
If mode is not specified, then the value of the associated backup flag is toggled from on to off or off to no. If given as zero backups shall be disabled, with a positive non-zero value enabling backups.
The set_backup() primitive may also be used to inquire the value of the associated backup flag. If the specified mode is -1 then the current flag value of the associated object shall be returned without any other effects.
When invoked from the command, one of the following messages shall be echoed
"Backups will be created".
or "Backups will not be created."
"Backups will be created for the buffer".
or "Backups will not be created for the buffer."
The set_backup() primitive returns the previous value of the backup flag.
n/a
int set_backup_option( int what, [int bufnum], parameter )
Set backup options.
The set_backup_option() primitive sets the value of the backup option what for the associated object. backup mode. If bufnum is specified, then the value of the stated buffer is modified, otherwise upon being omitted the global (default) backup mode shall be modified.
parameter shall be what specific, with the following options available;
The set_backup_option() on success returns zero, otherwise -1 on error.
A GriefEdit extension.
void set_char_timeout( [int timeout] )
Set the escape delay.
The set_char_timeout() primitive sets the length of time to wait before timing out and treating the ESC keystroke as the ESC character rather than combining it with other characters in the buffer to create a key sequence.
The most common instance where you may wish to change this value is to work with slow hosts, e.g., running on a network. If the host cannot read characters rapidly enough, it will have the same effect as if the terminal did not send characters rapidly enough. The library will still see a timeout.
The escape-delay value defaults to 750 milliseconds, but this shall be overridden by the ESCDELAY environment variable or the --escdelay command line option.
The ESCDELAY environment is defined specifies the default timeout interval, which is generally measured in millisecond. If ESCDELAY is 0, the system immediately composes the ESCAPE response without waiting for more information from the buffer. The user may choose any value between 0 and 9999, inclusive.
The ESCDELAY value is generally measured in milliseconds under most unix environments, but under AIX this value is measured in fifths of a milliseconds (200 microseconds) to be compatible with libcursor implementations; the default value is 500, or 0.1 second
timeout | Optional character timeout is milliseconds, otherwise the current ESCDELAY shall be reapplied. |
The set_char_timeout() primitive returns the previous character timeout.
n/a
int set_idle_default( int internal = 0 )
Set idle interval.
The set_idle_default() primitives set the keyboard idle interval as a measure of seconds betwen the last keystroke and when the REG_IDLE event is generated, see register_macro for details.
interval | Integer idle interval in seconds, if omitted the system default shall be utilised. |
The set_idle_default() primitives returns the previous value of the interval timer.
n/a
int set_term_characters( int value0, .... )
Set terminal special characters.
The set_term_characters() primitive is one of a set of functions which value add to the console interface specification. Under Unix™ console attributes are derived from the system termcap or terminfo databases or similar interfaces under non-console and non-unix systems.
The set_term_characters() primitive configures the set of characters which are utilised by the tty console driver to represent window borders.
Each of the character parameters listed below may be either an integer or string expression representing the character value. An integer value (including character constants) are treated as a single character whilst running within graphics-mode, whereas a string shall be interpreted as an escape sequence. Values can be omitted by supplying a NULL parameter against the associated character index.
This function should generally be invoked prior to the display being enabled (See: display_windows), otherwise a redraw is required.
Index |
Name |
Description |
---|---|---|
0 |
top_left |
Top left of a window. |
1 |
top_right |
Right right of a window. |
2 |
bottom_left |
Bottom left of a window. |
3 |
bottom_right |
Bottom right of a window. |
4 |
vertical |
Vertical window sides. |
5 |
horizontal |
Horizontal window sides. |
5 |
top_join |
Top intersection of window corners. |
6 |
bottom_join |
Bottom intersection of window corners. |
7 |
cross |
Intersection of window corners. |
8 |
left_join |
Left Window intersection. |
9 |
right_join |
Right window intersection. |
10 |
scroll |
Scroll bar arena. |
11 |
thumb |
Scroll bar thumb. |
... | Integer character value or string escape sequence, one for each character within the set. |
The following configures a terminal to use simple non-graphical characters to represent window borders.
set_term_characters(
'+', // 0. Top left of window.
'+', // 1. Top right of window.
'+', // 2. Bottom left of window.
'+', // 3. Bottom right of window.
'|', // 4. Vertical bar for window sides.
'-', // 5. Top and bottom horizontal bar for window.
'+', // 6. Top join.
'+', // 7. Bottom join.
'+', // 8. Window 4-way intersection.
'+', // 9. Left hand join.
'+', // 10. Right hand join.
'*' // 11. Thumb wheel.
);
For further examples refer to the tty macros, which setup the terminal interface for many well known environments.
nothing
n/a
int set_term_feature( int|string ident, [string|int value] )
Set a terminal attribute.
The set_term_feature() primitive is one of a set of functions which value add to the console interface specification. Under Unix™ console attributes are derived from the system termcap or terminfo databases or similar interfaces under non-console and non-unix systems.
The set_term_feature() primitive allows certain attributes about the current display to be modified; for example features which are not adequately handled by termcap or terminfo. The attribute identified by ident shall be set to value.
ident | Either the integer identifier or a string containing the name of the terminal attribute to be modified. |
value | Value to be applied against the attribute, if omitted or NULL the current value is cleared. The type of the value is specific to the attribute being modified, either in string or integer form. |
Each of the attributes are defined using one of four data types.
Escape | Terminal specific escape sequence being a series of characters that shall be written to the attached terminal. Controls supporting parameters should use printf style %d as the place holders for parameters; allowing terminfo/termcap independent macro development. Most of the sequence attributes are no longer required since the current generation of curses/ncurses terminfo or terminfo databases are complete. Supplied values shall only be utilised in the event these are missing from the current terminal description. |
Boolean | Boolean flag, which can be stated as either a numeric zero/non-zero value or a string value yes/no. |
Integer | Numeric value, either stated as an integer value or string containing a decimal value. |
String | String value. |
The following terminal attributes are exposed
Constant |
Name |
Type |
Description |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TF_PRINT_SPACE |
repeat_space |
Escape |
Control sequence to print a space n times. |
||||||||||
TF_PRINT_BITEIGHT |
print_character |
Escape |
Control sequence to print eight bit characters. |
||||||||||
TF_INSERT_CURSOR |
insert_cursor |
Escape |
Control sequence which modifies the cursor looks, utilised when GriefEdit has insert-mode enabled. |
||||||||||
TF_OVERWRITE_CURSOR |
overwrite_cursor |
Escape |
Control sequence which modifies the cursor looks, utilised when GriefEdit has overwrite-mode enabled. |
||||||||||
TF_VINSERT_CURSOR |
virt_insert_cursor |
Escape |
Control sequence which modifies the cursor looks, utilised when GriefEdit has insert-mode enabled and is positioned over a virtual-space. |
||||||||||
TF_VOVERWRITE_CURSOR |
virt_overwrite_cursor |
Escape |
Control sequence which modifies the cursor looks, utilised when GriefEdit has overwrite-mode enabled an is positioned over a virtual-space. |
||||||||||
TF_PRINT_ESCAPE |
print_escape |
Escape |
Control sequence which prints an ESC character graphically. |
||||||||||
TF_REPEAT_LAST |
repeat_last |
Escape |
Control sequence for repeating the previous character printed n times. |
||||||||||
TF_0M_RESETS_COLOR |
0m_resets_color |
Boolean |
When non-zero, then whenever an ESC[0m is printed, it is assumed that the background and foreground colours are reset (defunct). |
||||||||||
TF_COLOR |
color |
Boolean |
When non-zero, the terminal is assumed to support color. |
||||||||||
TF_CURSOR_RIGHT |
parm_cursor_right |
Escape |
Control sequence for move the cursor n characters within on the same line. |
||||||||||
TF_CLEAR_IS_BLACK |
clear_is_black |
Boolean |
When true states that area erase commands set the background of the erased line to black, otherwise the current background is assumed. |
||||||||||
TF_DISABLE_INSDEL |
noinsdel |
Boolean |
When true disables the use of window scrolling when attempting to optimise output; on several displays its faster to rewrite the window. |
||||||||||
TF_GRAPHIC_MODE |
graphics_mode |
Escape |
Control sequence to send when sending graphics (line drawing) characters. |
||||||||||
TF_TEXT_MODE |
text_mode |
Escape |
Control sequence to send when exiting graphics mode and going back to normal character set. |
||||||||||
TF_RESET |
reset |
Escape |
Control sequence to be executed during terminal initialisation operations. |
||||||||||
TF_INIT |
init |
Escape |
Control sequence to be executed during terminal reset operations. |
||||||||||
TF_COLORSETFGBG |
colorset_fgbg |
Escape |
Control sequence when executed sets both the foreground and backgrounds colours. |
||||||||||
TF_COLORSET_FG |
colorset_fg |
Escape |
Control sequence when executed sets the foreground colour. |
||||||||||
TF_COLORSET_BG |
colorset_bg |
Escape |
Control sequence when executed sets the background colour. |
||||||||||
TF_COLORDEPTH |
color_depth |
Integer |
Colour depth. |
||||||||||
TF_DEFAULT_FG |
default_fg_color |
Integer |
Terminals default foreground color. |
||||||||||
TF_DEFAULT_BG |
default_bg_color |
Integer |
Terminals default background color. |
||||||||||
TF_SCHEMEDARK |
scheme_dark |
Boolean |
When true the dark colour scheme variant shall be select over the light; if available. |
||||||||||
TF_COLORMAP |
color_map |
String |
Xterm colour map specification; a comma separated list of colours defining the colour palette. |
||||||||||
TF_COLORPALETTE |
color_palette |
String |
User defined palette. |
||||||||||
TF_EIGHT_BIT |
eight_bit |
Boolean |
When true the console supports the display of eight bit characters. |
||||||||||
TF_MOUSE |
mouse |
String |
Mouse device. |
||||||||||
TF_MOUSECLKMS |
mouse_clickms |
Integer |
Mouse click time in milliseconds. |
||||||||||
TF_WINDOW_SETSIZE |
winsetsize |
Escape |
Control sequence to set the window size to x by y. |
||||||||||
TF_WINDOW_SETPOS |
winsetpost |
Escape |
Control sequence to set the window position at x by y. |
||||||||||
TF_CODEPAGE |
codepage |
Integer |
Character code page. |
||||||||||
TF_DISABLE_SCROLL |
scroll_disable |
Boolean |
When true disables use of scroll region commands. |
||||||||||
TF_SCROLL_MAX |
scroll_max |
Integer |
Upper size of window to be scrolled permitting use of scroll region commands. |
||||||||||
TF_NOALTSCREEN |
noaltscreen |
Boolean |
When true denotes no alternative screen selection is available. |
||||||||||
TF_LAZYUPDATE |
lazy_update |
Integer |
When set to a positive value, indicates lazy screen updates are enabled. Screen updates are delayed until the keyboard becomes idle upto the stated number of lines. |
||||||||||
TF_ATTRIBUTES |
attributes |
Integer |
Terminal attribute bitmap; see the table below. |
||||||||||
TF_NAME |
name |
String |
Name of the terminal. |
||||||||||
TF_TTY_FAST |
tty_fast |
Integer |
When true disables use of pad characters. |
||||||||||
TF_TTY_GRAPHICSBOX |
tty_graphicsbox |
Integer |
When true enables use of graphic box characters. |
||||||||||
TF_KBPROTOCOL |
kbprotocol |
String |
Active kb-protocol. |
||||||||||
TF_SCREEN_ROWS |
screen_rows |
Integer |
Number of screen rows. |
||||||||||
TF_SCREEN_COLS |
screen_cols |
Integer |
Number of screen columns. |
||||||||||
TF_LINENO_COLUMNS |
lineno_columns |
Integer |
Terminal specific number of columns allocated for the display of buffer number lines. |
||||||||||
TF_WINDOW_MINROWS |
window_minrows |
Integer |
Minimum vertical size of a window. |
||||||||||
TF_WINDOW_MINCOLS |
window_mincols |
Integer |
Minimum horizontal size of a window. |
||||||||||
TF_XTERM_COMPAT |
xterm_compat |
Integer |
When true terminal to treated like an xterm. |
||||||||||
TF_XTERM_CURSOR |
xterm_cursor |
Integer |
When true terminal supports xterm cursor control commands. |
||||||||||
TF_XTERM_TITLE |
xterm_title |
Integer |
Control sequence when executed set the console title. |
||||||||||
TF_XTERM_PALETTE |
xterm_palette |
Integer |
Xterm palette selector. |
||||||||||
TF_VT_DATYPE |
vt_datype |
Integer |
Terminal type; xterm device attribute, known values are.
|
||||||||||
TF_VT_DAVERSION |
vt_daversion |
Integer |
Terminal version. |
||||||||||
TF_VT_DAOPTIONS |
vt_daoptions |
Integer |
Terminal options. |
||||||||||
TF_ENCODING |
encoding |
String |
Terminal character encoding. |
||||||||||
TF_UNICODE_VERSION |
unicode_version |
String |
UNICODE interface version, for example “6.0.1”. |
The reported TF_ATTRIBUTE attribute represents special terminal features mined during terminal initialisation. The flag argument can contain none or more of the following symbols bitwise OR’ed together.
Constant |
Description |
---|---|
TF_AGRAPHICCHARACTERS |
Graphic characters (ACS defined) |
TF_AFUNCTIONKEYS |
F1-F10 function keys. |
TF_ACYGWIN |
Cygwin native console. |
TF_AUTF8ENCODING |
UTF8 character encoding, Unicode implied. |
TF_AUNICODEENCODING |
Unicode character encoding. |
TF_AMETAKEY |
Meta keys. |
TF_AXTERMKEYS |
XTerm modifyOtherKeys available. |
TF_AKITTYKEYS |
Kitty extended keycodes available. |
Many of the exposed attributes are specific to the underlying terminal, a well known is the Xterm Control Sequences available on http://invisible-island.net.
The set_term_feature() primitive returns 0 on success, otherwise 1 on error.
A GriefEdit extension.
int set_term_features( list features )
Define terminal attributes.
The set_term_features() primitive is one of a set of functions which value add to the console interface specification. Under Unix™ console attributes are derived from the system termcap or terminfo databases or similar interfaces under non-console and non-unix systems.
Similar to the set_term_feature, set_term_features allows attributes about the current display to be modifed; for example features which are not adequately handled by termcap or terminfo.
set_term_features utilises a list interface with elements within the list implied by the TF_XXXX enumeration. This permits bulk attribute initialisation at the expense of visibility. See set_term_feature for further details on the exposed attributes.
list | Terminal attributes one or each attribute in the order implied by the TF_XXXX enumeration. Each parameter may be either an integer or string expression representing the character value. An integer value (including character constants) are treated as a single character whilst within graphics-mode, whereas a string shall be interpreted as an escape sequence. Values can be omitted by supplying a NULL parameter against the associated character index. |
nothing
set_term_features(
NULL, // TF_PRINT_SPACE
NULL, // TF_PRINT_BITEIGHT
NULL, // TF_INSERT_CURSOR
NULL, // TF_OVERWRITE_CURSOR
NULL, // TF_VINSERT_CURSOR
NULL, // TF_VOVERWRITE_CURSOR
NULL, // TF_PRINT_ESCAPE
NULL, // TF_REPEAT_LAST
FALSE, // TF_0M_RESETS_COLOR
FALSE, // TF_COLOR
"\x1B[%dC", // TF_CURSOR_RIGHT
TRUE, // TF_CLEAR_IS_BLACK
FALSE, // TF_DISABLE_INSDEL
"\x1B(0", // TF_GRAPHIC_MODE
"\x1B(B" // TF_TEXT_MODE
);
Many of the return values are only meaningful on systems that use a tty based console interface.
int set_term_keyboard( list kbd )
Define terminal keyboard definitions.
The set_term_keyboard() primitive is one of a set of functions which value add to the console interface specification. Under Unix™ console attributes are derived from the system termcap or terminfo databases or similar interfaces under non-unix systems.
The set_term_keyboard function manages the keyboard scan-code (terminal escape sequence) to key-code mapping table. For each key definition set_term_keyboard expects a pair of arguments, the first being Griefs internal key-code (See: key_to_int) with the second stating the associated escape sequence.
The mapped escape sequence shall be treated as unique; in what only the last instance shall be retained. Whereas key-codes can be associated with multiple escape sequences. For example, a generic Xterm mapping could support alternative function key reports.
The second argument may takes one of two forms. The first being a single string containing the escape sequence, the second being a key-list permitting a range of keys to be bound.
Example simple key associates including non-unique key codes.
set_term_keyboard(
:
KEY_PAGEUP, "\x1b[5~", // vt220 mode
KEY_PAGEDOWN, "\x1b[6~",
KEY_INS, "\x1b[2~",
KEY_DEL, "\x7f",
KEY_PAGEUP, "\x1b[5z", // sunFunctionKeys mode
KEY_PAGEDOWN, "\x1b[6z",
KEY_INS, "\x1b[2z",
:
);
Character Ranges
The key-lists are simply a list of strings describing each consecutive key within a set or range of keys. A constant set of keys can be simply quoted using the quote_list function, alternatively the list can be constructed with the other list primitives.
The following character definitions are generally defined using a consecutive set of keys.
Example of a consecutive definition against a constant set of sequences.
set_term_keyboard(
F1_F12, quote_list(
"\x1bOP", "\x1bOQ", "\x1bOR", "\x1bOS",
"\x1b[15~", "\x1b[17~", "\x1b[18~", "\x1b[19~",
"\x1b[20~", "\x1b[21~", "\x1b[23~", "\x1b[24~" )
);
Ambiguous
Due to the complex nature of terminal escape sequences, many key definitions result in ambiguous mappings; for example two or more mappings starting with the same sequence of characters. The mapping of ambiguous sequences to their associated key-code utilise a scan delay mechanism. When an ambiguous sequence is detected the driver waits several milliseconds before selecting the longest matching sequence, see set_char_timeout for details.
Many of the reported escapes are specific to the underlying terminal, a well known is the Xterm Control Sequences available on http ://invisible-island.net.
none
nothing
The following is an example from the Linux terminal definition.
set_term_keyboard(
:
F1_F12, quote_list(
"\x1bOP", "\x1bOQ", "\x1bOR", "\x1bOS",
"\x1b[15~", "\x1b[17~", "\x1b[18~", "\x1b[19~",
"\x1b[20~", "\x1b[21~", "\x1b[23~", "\x1b[24~" ),
SHIFT_F1_F12, quote_list(
NULL, NULL, "\x1b[25~", "\x1b[26~",
"\x1b[28~", "\x1b[29~", "\x1b[31~", "\x1b[32~",
"\x1b[33~", "\x1b[34~", "\x1b[23;2~", "\x1b[24;2~" ),
CTRL_F1_F12, quote_list(
"\x1bO5P", "\x1bO5Q", "\x1bO5R", "\x1bO5S",
"\x1b[15;5~", "\x1b[17;5~", "\x1b[18;5~", "\x1b[19;5~",
"\x1b[20;5~", "\x1b[21;5~", "\x1b[23;5~", "\x1b[24;5~" ),
:
);
For further examples refer to the tty macros, which setup the terminal interface for many well known environments.
n/a
int uname( [string &sysname], [string &nodename], [string &version], [string &release], [string &machine] )
Retrieve system information.
The uname() primitive retrieves the strings corresponding to the result of a uname system call. On non-POSIX systems, these strings maybe blank unless there is an equilvent value available.
sysname | System name. |
nodename | Network node name. |
version | Kernel version |
release | Kernel release. |
machine | Machine type. |
The uname() primitive returns on 0 otherwise, -1 on error.
A GriefEdit extension.
$Id: $
To send feedback on this topic email: grie@gmai l.com fedit
Copyright © Adam Young All Rights Reserved.
Change directory.
int cd( [string dir] )
Create a display character-map.
int create_char_map( [int mapid|string name], [int start = 0], [list chars], [list flags], [string name] )
Retrieve terminal special characters.
list get_term_characters( [top_left], [top_right], [bottom_left], [bottom_right], [vertical], [horizontal], [top_join], [bottom_join], [cross], [left_join], [right_join], [scrol], [thumb] )
Get value of a terminal feature.
int get_term_feature( string | int ident, declare value )
Retrieve terminate features.
list get_term_features( ... )
Retrieve the terminal keyboard definitions.
list get_term_keyboard()
Retrieve an environment variable.
string getenv( string name )
Retrieve the effective user identifier.
int geteuid()
Retrieve the process identifier.
int getpid()
Retrieve the user identifier.
int getuid()
Get current working directory.
int getwd( int ignored, string dir )
Get the backup creation mode.
int inq_backup( [int bufnum] )
Get backup options.
declare inq_backup_option( int what, [int bufnum] )
Retrieve the editor nesting level.
int inq_brief_level()
Get the escape delay.
int inq_char_timeout()
Retrieve an environment variable.
string inq_environment( string name )
Retrieve an editor feature.
int|list inq_feature( [int|string feature], [string value] )
Retrieve the local host name.
string inq_hostname()
Retrieve idle interval.
int inq_idle_default()
Retrieve keyboard idle time.
int inq_idle_time()
Retrieve profile directory.
string inq_profile()
Retrieve the user name.
string inq_username()
Set an environment variable.
void putenv( string name, [string value] )
Set backup creation mode.
int set_backup( int mode, [int bufnum] )
Set backup options.
int set_backup_option( int what, [int bufnum], parameter )
Set the escape delay.
void set_char_timeout( [int timeout] )
Set idle interval.
int set_idle_default( int internal = 0 )
Set terminal special characters.
int set_term_characters( int value0, .... )
Set a terminal attribute.
int set_term_feature( int|string ident, [string|int value] )
Define terminal attributes.
int set_term_features( list features )
Define terminal keyboard definitions.
int set_term_keyboard( list kbd )
Retrieve system information.
int uname( [string &sysname], [string &nodename], [string &version], [string &release], [string &machine] )
Change directory.
int chdir( string path )
Last system errno number.
extern int errno;
Create a directory.
int mkdir( string pathname, int mode = 0755 )
Remove directory.
int rmdir( string path )
Retrieve the character-map.
int inq_char_map( [int winnum], [string &name] )
Peek at the keyboard.
int inq_kbd_char()
Read next key from the keyboard.
void read_char( [int timeout = 0], [int mode = 0] )
Config an editor feature.
int set_feature( [int|string feature], [string value] )
Inquire display control flags.
int inq_display_mode( [string flagname], [string ~flags] )
Write to buffer content.
int write_buffer( [string filename], [int flags], [string encoding] )
Set and get the file mode creation mask.
int umask( int cmask = NULL )
Register a callback procedure.
int register_macro( int type, string macro, [int local = FALSE] )
Control window display.
int display_windows( [int mode] )
Redraw screen.
void redraw( [int winch] )
Convert key name to a code.
int key_to_int( string key, int raw )
Build an unevaluated list.
list quote_list( ... )
Version information.
int version( [int major | string machtype], [int min], [int edit], [int release], [string machtype], [string compile], [int cmversion], [string features], [string build] )