Format strings

Format strings are used for dynamic texts, such as prompts

Format strings are used for prompts, but can also be used directly using the control-format control on any handle that supports output. No tailing new line is added, so it needs to be added manually if required.

Example
  538 (* 0) "cat" ~> control %stdout sni:73 "The current tag is: $*\n"
The current tag is:   538 (* 0) "cat"
  538 (* 0) "cat" ~>
                

All formats can be prefixed with <>- and []-sections. Those sections alter the rendering of the value. They apply to what is right of them. Not all variables support all sections and/or modifiers.

<>-sections provide rendering information. They are similar to printf format string flags and modifiers.

[]-sections provide a way to access sub-elements. They are parsed as per context-control-parse-value. Their value is applied to the value using get-value. Note that if multiple values are given, they are understood right to left (opposite order of subindexing works in most languages). If <p> given the first (right-most) value will replace the parameter to the format variable.

Examples
  538 (* 0) "cat" ~> control %stdout sni:73 "$<p>[blue]X$<#>*$R\n"
  538 (* 0) "cat"
  538 (* 0) "cat" ~> control %stdout sni:73 "Terminal is $[sni:39]:x$[sni:38]: charaters big\n"
Terminal is 235x60 charaters big
  538 (* 0) "cat" ~>
                

Currently, the following variables are supported in prompts:

Variable Meaning Example output
$A
Ampersand
&
$B
Pipe
|
$C
Opening bracket
(
$E
US-ASCII Escape (0x1B) N/A
$F
Closing bracket
)
$G
Greater than
>
$H
Backspace N/A
$L
Less than
<
$P

or

$.
Alias for
$*
  538 (* 0) "cat"
$Q
Equal
=
$R
Clear (reset) terminal attributes N/A
$S
Space
 
$U
Prints the Unicode character given by param
$V
Version number
SIRTX 1.2.3
$W
Prints a parma wide fill pattern (by default spaces)
     
$X
Set the foreground colour to arg N/A
$Y
Set the background colour to arg N/A
$Z
Set the attribute arg N/A
$$
Dollar sign
$
$_
New line N/A
$*
Current tag
  538 (* 0) "cat"
$:
Output handle
<none> 
$%
The handle passed as arg
  538 (* 0) "cat"
$D
Reserved for current date N/A
$T
Reserved for current time N/A
$N
Reserved for DOS compatibility (current drive) N/A
$+
Reserved for DOS compatibility (pushd-level) N/A
$M
Reserved for DOS compatibility (remote name of current drive) N/A
All others Reserved for future use N/A
3982 (* 0) "Format strings" ~>

Function numbers

Function numbers are used to access functions both quickly and easier on limited keyboards.

7
show
17
dir
27
spread
37
shell
8
transfer
18
seek
28
set
38
swap
9
debug
19
hexdump
29
context
39
history
4
back
14
read
24
lci
34
into
5
render
15
control
25
echo
35
more
6
forward
16
write
26
run
36
outro
1
quit
11
new_relation
21
poolinfo
31
2
12
new_metadata
22
32
go
3
search
13
23
terminfo
33
termtest
0
hello_world
10
cls
20
ver
30
pause
2382 (* 0) "Function numbers" ~>

Plus escape

Plus escape is used to enter characters hard to enter, specifically on limited keyboards.

A plus escape code begins with a plus character (+) and two or more characters giving the character to insert. A plus escape can be cancelled by entering three plus. If the plus is followed by a single number and a comma or full stop the number is understood as the Unicode code point which is to be inserted. For example +214, can be used to insert an Ö or +128049, for 🐱. Below is a list of other supported combinations.

Plus escapes are part of the read line functionality. They are available on interactive sessions whenever read line is used and plus escape support is compiled in.

++/
'
++*
+
++-
^
++7
(
++8
&
++9
)
+++
Cancel sequence
++4
<
++5
@
++6
>
++1
[
++2
:
++3
]
++,
or
++.
 
(space)
8392 (* 0) "Plus escape" ~>

Common registers

The following lists the common register specification. Please note that this specifictaion is highly experimental.

Number Name Type Default VM v0: on call Info
0-2 user0 .. user2 user undef saved General user registers
3-7 user3 .. user7 user undef unchanged General user registers
8-31 user8 .. user31 user undef unchanged Additional user registers, not generally available
32 arg system undef saved, reset Used in control calls for the arg value
33 ns system sni saved, reset -
34 error system undef reset Last error code, is set by most opcodes
35 context system call context saved, updated Holds the current call context
36 in system filter input data updated -
37 out system undef reset -
38 deep system undef unchanged, fill saved Used for deep storage (heap). The fill (see control-get-list-fill, and control-set-list-fill) is saved and restored if the register holds the same handle as on call entry.
39-60 - system - - Unassigned
61 io system TBD TBD -
62 rodata system undef unchanged read only data (not executable)
63 program_text system N/A saved, updated program text

Note: For saved only includes the handle itself, not it's current position or other attributes. The caller is responsible for saving them if needed.

3298 (* 0) "Common registers" ~>

SIRTX ANSI escape code support requirements

The following outlines the requirements for any terminal to confirm to the SIRTX ANSI escape code support. Any terminal that does not adhere may be supported but must not be marked with the corresponding flag.

Note that the default VT-NNN style terminal driver (term) supports a wide range of additional controls. This list merely outlines one of many possible common subsets.

Code Requirement Description
ESC "c"
Implemented Resets terminal
CSI "1J"
Implemented Erase screen
CSI "H"
Implemented Move cursor to home
BEL
Implemented or ignored Rings bell
CSI "0m"
Implemented or ignored if no attributes are supported Resets all attributes
CSI "1m"
Implemented or ignored Sets bold attribute
CSI "2m"
Implemented or ignored Sets dim attribute
CSI "4m"
Implemented or ignored Sets underline attribute
CSI "?5" {"h" | "l"}
Implemented Sets screen mode
CSI "?6" {"h" | "l"}
Implemented Sets origin mode
CSI "?25" {"h" | "l"}
Implemented or ignored Sets cursor display
CSI n {"A" | "B" | "C" | "D"}
Implemented Moves cursor by a relative amount
CSI n ";" n "H"
Implemented Moves cursor to an absolute position
CSI n ";" n "r"
Implemented Set top bottom margin (scroll window)
7839 (* 0) "SIRTX ANSI escape code support requirements" ~>

VT-NNN colours

The following lists the colours SIRTX uses on VT-NNN compatible terminals depending on the selected colour mode.

Colour 3 Bit 3 Bit and Bold 4 Bit 8 Bit 24 Bit
black   Yes Yes Yes Yes Yes
red   Yes Yes Yes Yes Yes
green   Yes Yes Yes Yes Yes
blue   Yes Yes Yes Yes Yes
megenta   Yes Yes Yes Yes Yes
cyan   Yes Yes Yes Yes Yes
grey   Yes Yes Yes Yes Yes
yellow   No No Yes Yes Yes
white   No No Yes Yes Yes
orage   No No No No Yes
savannah   No No No No Yes
Custom colours   No No No No Yes

Please note that while some modes have more colour values than listed here. Those extra values are however generally not portable and therefore ignored by SIRTX. Modern terminals most likely support 24 bit mode rendering this problem void for them.

2372 (* 0) "VT-NNN colours" ~>

SIRTX characters

The following listing contains the characters SIRTX provides on legacy terminals missing important characters but support DLLCS.

  • U+20AC
    "\xE2\x82\xAC"
    EURO SIGN
  • U+2191
    "\xE2\x86\x91"
    UPWARDS ARROW
  • U+2193
    "\xE2\x86\x93"
    DOWNWARDS ARROW
  • U+2190
    "\xE2\x86\x90"
    LEFTWARDS ARROW
  • U+2192
    "\xE2\x86\x92"
    RIGHTWARDS ARROW
  • U+221E
    "\xE2\x88\x9E"
    INFINITY
  • U+2261
    "\xE2\x89\xA1"
    IDENTICAL TO
  • U+25C4
    "\xE2\x97\x84"
    BLACK LEFT-POINTING POINTER
  • U+25BA
    "\xE2\x96\xBA"
    BLACK RIGHT-POINTING POINTER
  • U+2642
    "\xE2\x99\x82"
    MALE SIGN
  • U+2640
    "\xE2\x99\x80"
    FEMALE SIGN
  • U+263A
    "\xE2\x98\xBA"
    WHITE SMILING FACE
  • U+263B
    "\xE2\x98\xBB"
    BLACK SMILING FACE
  • U+2665
    "\xE2\x99\xA5"
    BLACK HEART SUIT
  • U+2660
    "\xE2\x99\xA0"
    BLACK SPADE SUIT
  • U+2663
    "\xE2\x99\xA3"
    BLACK CLUB SUIT
  • U+266A
    "\xE2\x99\xAA"
    EIGHTH NOTE
  • U+23A1
    "\xE2\x8E\xA1"
    LEFT SQUARE BRACKET UPPER CORNER
  • U+23A6
    "\xE2\x8E\xA6"
    RIGHT SQUARE BRACKET LOWER CORNER
  • 🐱
    U+1F431
    "\xF0\x9F\x90\xB1"
    CAT FACE
  • 🮰
    U+1FBB0
    "\xF0\x9F\xAE\xB0"
    ARROWHEAD-SHAPED POINTER
  • U+2026
    "\xE2\x80\xA6"
    HORIZONTAL ELLIPSIS
  • Ω
    U+03A9
    "\xCE\xA9"
    GREEK CAPITAL LETTER OMEGA
  • U+231B
    "\xE2\x8C\x9B"
    HOURGLASS
  • ¤
    U+00A4
    "\xC2\xA4"
    CURRENCY SIGN
9928 (* 0) "SIRTX characters" ~>