Initial commit

master
Levi Pearson 2018-06-28 20:01:07 -06:00
commit 46dd8507c9
18 changed files with 4954 additions and 0 deletions

1087
ansi.c Normal file

File diff suppressed because it is too large Load Diff

57
ansi.h Normal file
View File

@ -0,0 +1,57 @@
#ifndef ANSI_H
#define ANSI_H
#include "sm.h"
#include "ansi_codes.h"
#include "ansi_table.h"
struct ansi_context;
typedef void (*put_handler)(void *user_ctx, unsigned char ch);
typedef void (*osc_handler)(void *user_ctx, unsigned char ch);
struct function_id {
unsigned char i_count_priv;
unsigned char intermediates[2];
unsigned char final;
};
struct str_hook {
put_handler handler_fn;
void *user_ctx;
};
struct osc_hook {
osc_handler handler_fn;
void *user_ctx;
};
typedef void (*graphic_char)(unsigned char ch);
typedef void (*control_char)(unsigned char ch);
typedef void (*esc_sequence)(struct function_id esc_id);
typedef void (*control_seq)(struct function_id csi_id,
int paramc, unsigned int *paramv);
typedef void (*str_hook)(struct str_hook *hook,
struct function_id str_id,
int paramc, unsigned int *paramv);
typedef void (*osc_hook)(struct osc_hook *hook);
struct ansi_actions {
graphic_char graphic_cb;
control_char control_cb;
esc_sequence esc_cb;
control_seq csi_cb;
str_hook str_cb;
osc_hook osc_cb;
};
struct ansi_context *new_ansi_context(struct ansi_actions *actions);
void ansi_context_put(struct ansi_context *ctx, unsigned char code);
#endif

155
ansi.org Normal file
View File

@ -0,0 +1,155 @@
C0, C1, and GL characters
: C0 : GL : C1 :
CSI : I : P (0-B) : F ' priv :
ESC : I : F : ESC Fe controls :
: nF : Fp : Fe : Fs :
| row | 00 (0x0.) | 01 (0x1.) | 02 (0x2.) | 03 (0x3.) | 04 (0x4.) | 05 (0x5.) | 06 (0x6.) | 07 (0x7.) | 08 (0x8.) | 09 (0x9.) |
|-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
| 00 (0x.0) | 0x00 NUL | 0x10 DLE | 0x20 SP | 0x30 0 | 0x40 @ | 0x50 P | 0x60 ` | 0x70 p | 0x80 -- | 0x90 DCS |
| 01 (0x.1) | 0x01 SOH | 0x11 DC1 | 0x21 ! | 0x31 1 | 0x41 A | 0x51 Q | 0x61 a | 0x71 q | 0x81 -- | 0x91 PU1 |
| 02 (0x.2) | 0x02 STX | 0x12 DC2 | 0x22 " | 0x32 2 | 0x42 B | 0x52 R | 0x62 b | 0x72 r | 0x82 BPH | 0x92 PU2 |
| 03 (0x.3) | 0x03 ETX | 0x13 DC3 | 0x23 # | 0x33 3 | 0x43 C | 0x53 S | 0x63 c | 0x73 s | 0x83 NBH | 0x93 STS |
| 04 (0x.4) | 0x04 EOT | 0x14 DC4 | 0x24 $ | 0x34 4 | 0x44 D | 0x54 T | 0x64 d | 0x74 t | 0x84 -- | 0x94 CCH |
| 05 (0x.5) | 0x05 ENQ | 0x15 NAK | 0x25 % | 0x35 5 | 0x45 E | 0x55 U | 0x65 e | 0x75 u | 0x85 NEL | 0x95 MW |
| 06 (0x.6) | 0x06 ACK | 0x16 SYN | 0x26 & | 0x36 6 | 0x46 F | 0x56 V | 0x66 f | 0x76 v | 0x86 SSA | 0x96 SPA |
| 07 (0x.7) | 0x07 BEL | 0x17 ETB | 0x27 ' | 0x37 7 | 0x47 G | 0x57 W | 0x67 g | 0x77 w | 0x87 ESA | 0x97 EPA |
| 08 (0x.8) | 0x08 BS | 0x18 CAN | 0x28 ( | 0x38 8 | 0x48 H | 0x58 X | 0x68 h | 0x78 x | 0x88 HTS | 0x98 SOS |
| 09 (0x.9) | 0x09 HT | 0x19 EM | 0x29 ) | 0x39 9 | 0x49 I | 0x59 Y | 0x69 i | 0x79 y | 0x89 HTJ | 0x99 -- |
| 10 (0x.A) | 0x0A LF | 0x1A SUB | 0x2A * | 0x3A : | 0x4A J | 0x5A Z | 0x6A j | 0x7A z | 0x8A VTS | 0x9A SCI |
| 11 (0x.B) | 0x0B VT | 0x1B ESC | 0x2B + | 0x3B ; | 0x4B K | 0x5B [ | 0x6B k | 0x7B { | 0x8B PLD | 0x9B CSI |
| 12 (0x.C) | 0x0C FF | 0x1C IS4 | 0x2C , | 0x3C < | 0x4C L | 0x5C \ | 0x6C l | 0x7C VLIN | 0x8C PLU | 0x9C ST |
| 13 (0x.D) | 0x0D CR | 0x1D IS3 | 0x2D - | 0x3D = | 0x4D M | 0x5D ] | 0x6D m | 0x7D } | 0x8D RI | 0x9D OSC |
| 14 (0x.E) | 0x0E SO | 0x1E IS2 | 0x2E . | 0x3E > | 0x4E N | 0x5E ^ | 0x6E n | 0x7E ~ | 0x8E SS2 | 0x9E PM |
| 15 (0x.F) | 0x0F SI | 0x1F IS1 | 0x2F / | 0x3F ? | 0x4F O | 0x5F _ | 0x6F o | 0x7F DEL | 0x8F SS3 | 0x9F APC |
1-char ESC sequence control functions
| row | 06 (0x6.) Fs | 07 (0x7.) Fs |
|-----------+--------------+-----------------|
| 00 (0x.0) | DMI - ESC ` | |
| 01 (0x.1) | INT - ESC a | |
| 02 (0x.2) | EMI - ESC b | |
| 03 (0x.3) | RIS - ESC c | |
| 04 (0x.4) | CMD - ESC d | |
| 05 (0x.5) | | |
| 06 (0x.6) | | |
| 07 (0x.7) | | |
| 08 (0x.8) | | |
| 09 (0x.9) | | |
| 10 (0x.A) | | |
| 11 (0x.B) | | |
| 12 (0x.C) | | LS3R - ESC VLIN |
| 13 (0x.D) | | LS2R - ESC } |
| 14 (0x.E) | LS2 - ESC n | LS1R - ESC ~ |
| 15 (0x.F) | LS3 - ESC o | |
Defined Control Sequences, no I bytes
| row | 04 (0x4.) | 05 (0x5.) | 06 (0x6.) |
|-----------+---------------------+---------------------+---------------------|
| 00 (0x.0) | ICH - CSI Pn @ | DCH - CSI Pn P | HPA - CSI Pn ` |
| 01 (0x.1) | CUU - CSI Pn A | SEE - CSI Ps Q | HPR - CSI Pn a |
| 02 (0x.2) | CUD - CSI Pn B | CPR - CSI Pn1;Pn2 R | REP - CSI Pn b |
| 03 (0x.3) | CUF - CSI Pn C | SU - CSI Pn S | DA - CSI Ps c |
| 04 (0x.4) | CUB - CSI Pn D | SD - CSI Pn T | VPA - CSI Pn d |
| 05 (0x.5) | CNL - CSI Pn E | NP - CSI Pn U | VPR - CSI Pn e |
| 06 (0x.6) | CPL - CSI Pn F | PP - CSI Pn V | HVP - CSI Pn1;Pn2 f |
| 07 (0x.7) | CHA - CSI Pn G | CTC - CSI Ps... W | TBC - CSI Ps g |
| 08 (0x.8) | CUP - CSI Pn1;Pn2 H | ECH - CSI Pn X | SM - CSI Ps... h |
| 09 (0x.9) | CHT - CSI Pn I | CVT - CSI Pn Y | MC - CSI Ps i |
| 10 (0x.A) | ED - CSI Ps J | CBT - CSI Pn Z | HPB - CSI Pn j |
| 11 (0x.B) | EL - CSI Ps K | CRS - CSI Ps [ | VPB - CSI Pn k |
| 12 (0x.C) | IL - CSI Pn L | PTX - CSI Ps \ | RM - CSI Ps... l |
| 13 (0x.D) | DL - CSI Pn M | SDS - CSI Ps ] | SGR - CSI Ps... m |
| 14 (0x.E) | EF - CSI Ps N | SIMD- CSI Ps ^ | DSR - CSI Ps n |
| 15 (0x.F) | EA - CSI Ps O | | DAQ - CSI Ps... o |
Defined Control Sequences, I = 0x20 (SP)
| row | 04 (0x4.) | 05 (0x5.) | 06 (0x6.) |
|-----------+------------------------+------------------------+------------------------|
| 00 (0x.0) | SL - CSI Pn SP @ | PPA - CSI Pn SP P | TATE- CSI Pn SP ` |
| 01 (0x.1) | SR - CSI Pn SP A | PPR - CSI Ps SP Q | TALE- CSI Pn SP a |
| 02 (0x.2) | GSM - CSI Pn1;Pn2 SP B | PPB - CSI Pn SP R | TAC - CSI Pn SP b |
| 03 (0x.3) | GSS - CSI Pn SP C | SPD - CSI Ps1;Ps2 SP S | TCC - CSI Pn1;Pn2 SP c |
| 04 (0x.4) | FNT - CSI Ps1;Ps2 SP D | DTA - CSI Pn1;Pn2 SP T | TSR - CSI Pn SP d |
| 05 (0x.5) | TSS - CSI Pn SP E | SLH - CSI Pn SP U | SCO - CSI Ps SP e |
| 06 (0x.6) | JFY - CSI Ps... SP F | SLL - CSI Pn SP V | SRCS- CSI Pn SP f |
| 07 (0x.7) | SPI - CSI Pn1;Pn2 SP G | FNK - CSI Pn SP W | SCS - CSI Pn SP g |
| 08 (0x.8) | QUAD- CSI Ps... SP H | SPQR- CSI Ps SP X | SLS - CSI Pn SP h |
| 09 (0x.9) | SSU - CSI Ps SP I | SEF - CSI Ps1;Ps2 SP Y | SPH - CSI Pn SP i |
| 10 (0x.A) | PFS - CSI Ps SP J | PEC - CSI Ps SP Z | SPL - CSI Pn SP j |
| 11 (0x.B) | SHS - CSI Ps SP K | SSW - CSI Ps SP [ | SCP - CSI Ps1;Ps2 SP k |
| 12 (0x.C) | SVS - CSI Ps SP L | SACS- CSI Pn SP \ | |
| 13 (0x.D) | IGS - CSI Ps SP M | SAPV- CSI Ps... SP ] | |
| 14 (0x.E) | HTSA- CSI Pn... SP N | STAB- CSI Ps SP ^ | |
| 15 (0x.F) | IDCS- CSI Ps SP O | GCC - CSI Ps SP _ | |
DEC Private Control Sequences
| row | 07 No I | 07 I=SP | 07 I=! | 07 I=" | 07 I=$ | 07 I=& | 07 I=' | 07 I=) | 07 I=* | 07 I=+ | 07 I=, | 07 I=- |
|-----------+-------------+----------+--------+---------+----------+-----------+---------+----------+----------+-----------+---------+----------|
| 00 (0x.0) | DECSSL | DECSSCLS | DECSTR | DECSCL | DECRQM | | | DECSPDT | DECSPPCS | DECSR | DECLTOD | DECARR |
| 01 (0x.1) | DECLL | DECSCUSR | | DECSCA | DECSDDT | | | | DECSRC | DECELF | DECTID | DECCRTST |
| 02 (0x.2) | DECSTBM | DECSKCV | | | DECCARA | | | | DECSCS | DECSMKR | | DECSEST |
| 03 (0x.3) | DECSLRM | | | | DECSPRTT | | DECTLTC | | DECSFC | | | |
| 04 (0x.4) | DECSLPP | DECSWDV | | DECSRFR | DECRARA | | | | | | | |
| 05 (0x.5) | | DECSMBV | | DECSTRL | DECRQTSR | DECRQUPSS | | | DECSCP | | DECRQKT | |
| 06 (0x.6) | | DECSLCK | | DECRQDE | DECCRA | | | | | | DECRPKT | |
| 07 (0x.7) | | | | DECRPDE | DECRQPSR | DECLRP | DECEFR | | | DECSPP | DECRQKD | |
| 08 (0x.8) | DECREQTPARM | | | | DECFRA | DECES | | | DECSACE | DECRQPKFM | DECSPMA | |
| 09 (0x.9) | DECTST | | | | DECRPM | | | | DECRQCRA | DECPKFMR | DECUS | |
| 10 (0x.A) | | | | | DECERA | | DECELR | | DECINVM | DECPKA | DECDLDA | |
| 11 (0x.B) | | | | | DECSERA | | DECSLE | | DECMSR | | DECSZS | |
| 12 (0x.C) | DECTTC | | | | DECSCPP | | DECRQLP | | DECSNLS | | DECAC | |
| 13 (0x.D) | DECPRO | DECKBD | | | DECSASD | | DECIC | DECSTGLT | DECLFKC | | DECATC | |
| 14 (0x.E) | DECFNK | DECTME | | | DECSSDT | | DECDC | | | | DECPS | |
DEC Private Device Control Strings
| row | 07 (0x7.) | 07 (0x7.) I = ! | 07 (0x7.) I = " | 07 (0x7.) I = $ |
|-----------+-----------+-----------------+-----------------+-------------------|
| 00 (0x.0) | decREGIS | | | DECRSTS |
| 01 (0x.1) | decSIXEL | | | DECRQSS |
| 02 (0x.2) | DECLBAN | | | DECRPSS |
| 03 (0x.3) | decVKPK | | | DECTSR / DECCTR |
| 04 (0x.4) | decVT105G | | | DECRSPS |
| 05 (0x.5) | | DECAUPSS | | DECCIR / DECTABSR |
| 06 (0x.6) | DECLANS | | | |
| 07 (0x.7) | | | | DECLBD |
| 08 (0x.8) | | | DECPFK | |
| 09 (0x.9) | DECLFF | | DECPAK | |
| 10 (0x.A) | | DECDMAC | DECCKD | |
| 11 (0x.B) | DECDLD | DECSTUI | | |
| 12 (0x.C) | DECUDK | DECRPTUI | | |
| 13 (0x.D) | | | DECRPFK | |
| 14 (0x.E) | | DECCKSR | DECRPAK | |
DEC Fp and nFp ESC sequence control functions
| row | 03 (0x3.) Fp | # 03 (0x3.) 3Fp |
|-----------+-----------------+------------------|
| 00 (0x.0) | | |
| 01 (0x.1) | DECGON - ESC 1 | |
| 02 (0x.2) | DECGOFF - ESC 2 | |
| 03 (0x.3) | | DECDHL - ESC # 3 |
| 04 (0x.4) | | DECDHL - ESC # 4 |
| 05 (0x.5) | DECXMIT - ESC 5 | DECSWL - ESC # 5 |
| 06 (0x.6) | DECBI - ESC 6 | DECDWL - ESC # 6 |
| 07 (0x.7) | DECSC - ESC 7 | DECHCP - ESC # 7 |
| 08 (0x.8) | DECRC - ESC 8 | DECALN - ESC # 8 |
| 09 (0x.9) | DECFI - ESC 9 | |
| 10 (0x.A) | | |
| 11 (0x.B) | | |
| 12 (0x.C) | | |
| 13 (0x.D) | DECKPAM - ESC = | |
| 14 (0x.E) | DECKPNM - ESC > | |
| 15 (0x.F) | | |
DEC extensions to standard control functions via private parameter marker 0x3F (?)
DECSM - extends SM - CSI ? Ps... h
DECSED - extends ED - CSI ? Ps J
DECXCPR - extends CPR - CSI ? Pn1;Pn2 R

108
ansi_codes.c Normal file
View File

@ -0,0 +1,108 @@
#include <stdlib.h>
#include "ansi_codes.h"
const char *ansi_c0_names[] = {
"NULL",
"START OF HEADING",
"START OF TEXT",
"END OF TEXT",
"END OF TRANSMISSION",
"ENQUIRY",
"ACKNOWLEDGE",
"BELL",
"BACKSPACE",
"HORIZONTAL TABULATION",
"LINE FEED",
"VERTICAL TABULATION",
"FORM FEED",
"CARRIAGE RETURN",
"SHIFT OUT / LOCKING SHIFT 1",
"SHIFT IN / LOCKING SHIFT 0",
"DATA LINK ESCAPE",
"DEVICE CONTROL 1 (XON)",
"DEVICE CONTROL 2",
"DEVICE CONTROL 3 (XOFF)",
"DEVICE CONTROL 4",
"NEGATIVE ACKNOWLEDGE",
"SYNCHRONOUS IDLE",
"END OF TRANSMISSION BLOCK",
"CANCEL",
"END OF MEDIUM",
"SUBSTITUTE",
"ESCAPE",
"INFORMATION SEPARATOR 4",
"INFORMATION SEPARATOR 3",
"INFORMATION SEPARATOR 2",
"INFORMATION SEPARATOR 1"
};
const char *ansi_c0_abbrevs[] = {
"NUL",
"SOH",
"STX",
"ETX",
"EOT",
"ENQ",
"ACK",
"BEL",
"BS",
"HT",
"LF",
"VT",
"FF",
"CR",
"SO/LS1",
"SI/LS0",
"DLE",
"DC1/XON",
"DC2",
"DC3/XOFF",
"DC4",
"NAK",
"SYN",
"ETB",
"CAN",
"EOM",
"SUB",
"ESC",
"IS4",
"IS3",
"IS2",
"IS1"
};
const char *ansi_c1_names[] = {
NULL,
NULL,
"BREAK PERMITTED HERE",
"NO BREAK HERE",
NULL,
"NEXT LINE",
"START OF SELECTED AREA",
"END OF SELECTED AREA",
"HORIZONTAL TABULATION SET",
"HORIZONTAL TABULATION WITH JUSTIFICATION",
"VERTICAL TABULATION SET",
"PARTIAL LINE DOWN",
"PARTIAL LINE UP",
"REVERSE LINE FEED",
"SINGLE-SHIFT TWO",
"SINGLE-SHIFT THREE",
"DEVICE CONTROL STRING",
"PRIVATE USE ONE",
"PRIVATE USE TWO",
"SET TRANSMIT STATE",
"CANCEL CHARACTER",
"MESSAGE WAITING",
"START OF GUARDED AREA",
"END OF GUARDED AREA",
"START OF STRING",
NULL,
"SINGLE CHARACTER INTRODUCER",
"CONTROL SEQUENCE INTRODUCER",
"STRING TERMINATOR",
"OPERATING SYSTEM COMMAND",
"PRIVACY MESSAGE",
"APPLICATION PROGRAM COMMAND"
};

528
ansi_codes.h Normal file
View File

@ -0,0 +1,528 @@
#ifndef ANSI_CODES_H
#define ANSI_CODES_H
/*
The standards deal with both 7-bit and 8-bit code sets. The code sets are
divided into rows and columns to form tables; the least-significant nybble
(4-bits) determines the row, while the remaining bits determine the column. A
7-bit set therefore has columns 0-7, while an 8-bit set has columns 0-15.
Codes are either control codes or graphic codes, and their meaning is either
fixed or coded according to a changeable set.
Control codes are always found in two-column sets, called C0 or primary, and C1
or supplementary. C0 is in columns 00 and 01, while C1 is found in columns 08
and 09. C0 always contains a special code ESCAPE at 01/11. C1 is only available
in 8-bit code sets. The controls coded by C1 can also be invoked in a 7-bit code
set via Escape Sequence; these use the Fe columns 04 and 05 to represent the
same controls as those in C1.
Graphic codes are in 6-column sets, called G0-G3. They are either 96-character
sets or 94-character sets. The 94-character variety don't have a code in the
first row of the first column or the last row of the last column. Those
positions correspond to SPACE and DELETE, which are fixed graphic codes, when
mapped to the left graphic set. G0 always contains a 94-character set and always
maps to columns 02-07, while G1-G3 can map either to that location (in which
case they must also contain 94-character sets) or to columns 10-15, in which
case they may be either 94-character or 96-character sets.
Control and graphic code tables are mapped into the code space into two control
code tables, CL and CR; and two graphics code tables, GL and GR.
For 8-bit codes:
CL corresponds to columns 00-01
GL corresponds to columns 02-07
CR corresponds to columns 08-09
GR corresponds to columns 10-15
CL is a C0 set and CR may contain a C1 set or be unused. GL is either a
combination of SPACE, DELETE, and a 94-character graphic set; or a 96-character
graphics set. GR is either a 94-character graphic set or a 96-character graphic
set. If more than two of G0-G3 are included, shift controls are provided to
select the ones not mapped to GL or GR. If more than two control tables or four
graphics tables are required, designation functions will be included in the code
set to re-map C0-C1, G0-G3.
For 7-bit codes:
CL corresponds to columns 00-01
GL corresponds to columns 02-07
CL contains a C0 set and GL contains either a combination of SPACE, DELETE, and
a 94-character set; or a 96-character set. It will define at least a C0 and G0
element, and may use some or all of C1 and G1-3. If more than one of G0-G3 are
included, shift functions will be included to select between them. If more than
two control tables and/or more than four graphic tables are needed, designation
functions will be included in the code set to map them to C0-C1, G0-G3.
Escape Sequences:
Escape sequences are the coded representation of code-identification functions.
Their structure is as follows:
ESCAPE <Intermediate Byte>* <Final Byte>
That is, they start with the ESCAPE byte, followed by 0 or more Intermediate
Bytes, and end with a Final Byte.
Intermediate Byte values are drawn from column 02 of the code table; they are
denoted by I.
Final Byte values are drawn from columns 03-07 excluding 07/15; they are denoted
by F.
The type of escape sequence is determined by the column number of the first byte
following ESCAPE:
02 - Type nF - Various; n is row number, see nF table
03 - Type Fp - Private Control Functions
04 & 05 - Type Fe - Control Function in C1
06 & 07 - Type Fs - Standardized Single Control Function
nF varieties:
0F : N : ANNOUNCE CODE STRUCTURE
1F : O(R) : C0-DESIGNATE
2F : O(R) : C1-DESIGNATE
3F : O(R) : Single Control Functions
4F : Y(S) : Designation of multi-byte graphic character sets
5F : O(R,S) : DESIGNATE OTHER CODING SYSTEM
6F : N : IDENTIFY REVISED REGISTRATION
7F : N : Reserved for future standardization
8F : O(R,S) : G0-DESIGNATE 94-SET
9F : O(R,S) : G1-DESIGNATE 94-SET
10F: O(R,S) : G2-DESIGNATE 94-SET
11F: O(R,S) : G3-DESIGNATE 94-SET
12F: N : Reserved for future standardization
13F: O(R,S) : G1-DESIGNATE 96-SET
14F: O(R,S) : G2-DESIGNATE 96-SET
15F: O(R,S) : G3-DESIGNATE 96-SET
N = No additional bytes
O = Optional 2nd and further bytes
Y = 2nd I byte must be present
R = Registration procedures may use 02/01-02/3 I byte to supplement the bit
combinations available to F. Additional 02-column bytes may be used as well.
S = Standardized meanings are assigned
4F 2nd-I Byte Functions:
02/08 : G0-DESIGNATE MULTIBYTE 94-SET
02/09 : G0-DESIGNATE MULTIBYTE 94-SET
02/10 : G0-DESIGNATE MULTIBYTE 94-SET
02/11 : G0-DESIGNATE MULTIBYTE 94-SET
02/12 : G0-DESIGNATE MULTIBYTE 94-SET
02/13 : G0-DESIGNATE MULTIBYTE 94-SET
02/14 : G0-DESIGNATE MULTIBYTE 94-SET
Meaning of F byte column in nF sequences:
00-02 : : Not used
03 : Fp : Reserved for Private Use
04-07 : Ft : Standardized Purposes
I.e. 3Fp indicates a private single control function, ESC 02/03 I? 03/xx
*/
enum ansi_c0 {
NUL,
SOH,
STX,
ETX,
EOT,
ENQ,
ACK,
BEL,
BS,
HT,
LF,
VT,
FF,
CR,
LS1,
LS0,
DLE,
DC1,
DC2,
DC3,
DC4,
NAK,
SYN,
ETB,
CAN,
EM,
SUB,
ESC,
IS4,
IS3,
IS2,
IS1
};
enum ansi_c1 {
//--
//--
BPH = 0x82,
NBH,
IND,
NEL,
SSA,
ESA,
HTS,
HTJ,
VTS,
PLD,
PLU,
RI,
SS2,
SS3,
DCS,
PU1,
PU2,
STS,
CCH,
MW,
SPA,
EPA,
SOS,
//--
SCI = 0x9A,
CSI,
ST,
OSC,
PM,
APC
};
/* ECMA-48 Code
C0 and C1 Functions
===================
C0 element codes C1 element codes
Column Column
Row 00 01 Row 04/08 05/09
----------------- -----------------
00 NUL DLE 00 -- DCS
01 SOH DC1 01 -- PU1
02 STX DC2 02 BPH PU2
03 ETX DC3 03 NBH STS
04 EOT DC4 04 -- CCH
05 ENQ NAK 05 NEL MW
06 ACK SYN 06 SSA SPA
07 BEL ETB 07 ESA EPA
08 BS CAN 08 HTS SOS
09 HT EM 09 HTJ --
10 LF SUB 10 VTS SCI
11 VT ESC 11 PLD CSI
12 FF IS4 12 PLU ST
13 CR IS3 13 RI OSC
14 SO/LS1 IS2 14 SS2 PM
15 SI/LS0 IS1 15 SS3 APC
Control sequences
=================
Control Sequence interpretation:
<P> = Parameter byte, drawn from col 03
<I> = Intermediate byte, drawn from col 02
<F> = Final byte, drawn from cols 04-07, col 07 is private
CSI <P>* <I>* <F>
Control sequences by F:
Column (No I) Column (I=02/00)
Row 04 05 06 04 05 06
-------------------------------------------------
00 ICH DCH HPA SL PPA TATE
01 CUU SEE HPR SR PPR TALE
02 CUD CPR REP GSM PPB TAC
03 CUF SU DA GSS SPD TCC
04 CUB SD VPA FNT DTA TSR
05 CNL NP VPR TSS SHL SCO
06 CPL PP HVP JFY SLL SRCS
07 CHA CTC TBC SPI FNK SCS
08 CUP ECH SM QUAD SPQR SLS
09 CHT CVT MC SSU SEF --
10 ED CBT HPB PFS PEC --
11 EL SRS VPB SHS SSW SCP
12 IL PTX RM SVS SACS --
13 DL SDS SGR IGS SAPV --
14 EF SIMD DSR -- STAB --
15 EA -- DAQ IDCS GCC --
Parameter interpretation:
First byte of <P>* is in 03/00-03/11:
<Param String> = <Substring List>
<Substring List> = <Substring> | <Substring> SEP <Substring List>
<Substring> = (<Digit>|DIGIT_SEP)+ | <EMPTY>
<Digit> = ZERO | ONE | TWO | THREE | FOUR | FIVE | SIX | SEVEN | EIGHT | NINE
SEP = byte 03/11
DIGIT_SEP = byte 03/10
ZERO - NINE = bytes 03/00 - 03/09
First byte of <P>* is in 03/12-03/15:
Format and meaning are privately-defined
*/
enum ansi_csi_noI {
ICH = 0x40,
CUU,
CUD,
CUF,
CUB,
CNL,
CPL,
CHA,
CUP,
CHT,
ED,
EL,
IL,
DL,
EF,
EA,
DCH,
SEE,
CPR,
SU,
SD,
NP,
PP,
CTC,
ECH,
CVT,
CBT,
SRS,
PTX,
SDS,
SIMD,
//
HPA = 0x60,
HPR,
REP,
DA,
VPA,
VPR,
HVP,
TBC,
SM,
MC,
HPB,
VPB,
RM,
SGR,
DSR,
DAQ
};
/*
Independent Control Functions
=============================
Represented by escape sequences of the form ESC Fs
Independent Control Functions by Fs
Column
Row 06 07
-----------------
00 DMI --
01 INT --
02 EMI --
03 RIS --
04 CMD --
05 -- --
06 -- --
07 -- --
08 -- --
09 -- --
10 -- --
11 -- --
12 -- LS3R
13 -- LS2R
14 LS2 LS1R
15 LS3 --
Control Strings
===============
Control string format:
<Control String> = <Opening Delim> (<Command String> | <Character String>) ST
<Opening Delim> = APC | DCS | OSC | PM | SOS
<Command String> = ((byte range 00/08 - 00/13) | (byte range 02/00 - 07/14))+
<Character String> = (any byte but SOS or ST)+
Interpretation is up to the sender/recipient of the data.
Modes
=====
Private modes can be used, but the following are standardized:
BDSM : BI-DIRECTIONAL SUPPORT MODE
EXPLICIT - Control functions performed in data or presentation component depending
on the the setting of DEVICE COMPONENT SELECT MODE
IMPLICIT - Control functions are performed in the data component.
CRM : CONTROL REPRESENTATION MODE
CONTROL - Control functions performed as defined; formator functions processed as
determined by FORMAT EFFECTOR ACTION MODE.
GRAPHIC - Control functions (except for RESET MODE) are treated as graphic
characters; device may also perform some control functions.
DCSM : DEVICE COMPONENT SELECT MODE
PRESENTATION - Control functions sensitive to this are performed in the presentation
component.
DATA - Control functions senstive to this are performed in the data component.
ERM : ERASURE MODE
PROTECT - Only contents of unprotected areas are affected by an erasure function.
ALL - All content areas are affected by an erasure function.
FEAM : FORMAT EFFECTOR ACTION MODE
EXECUTE - Format functions are performed immediately; may also be stored
STORE - Format functions are stored but not performed
FETM : FORMAT EFFECTOR TRANSFER MODE
INSERT - Format functions may be inserted into data stream to be transmitted
EXCLUDE - No format functions other than those while FEAM is set to STORE are
transmitted
GATM : GUARDED AREA TRANSFER MODE
GUARD - Only the contents of unguarded areas in an eligible area are transmitted
ALL - All contents of eligible areas are transmitted regardless of guard status
GRCM : GRAPHIC RENDITION COMBINATION MODE
REPLACING - each SELECT GRAPHICS RENDITION cancels effects of previous invocations
CUMULATIVE - each SGR changes only those effects specified, others remain
HEM : CHARACTER EDITING MODE
FOLLOWING - Insertion shifts following characters
PRECEDING - Insertion shifts preceding characters
IRM : INSERTION REPLACEMENT MODE
REPLACE - Graphic symbol replaces the one at the current display position
INSERT - Graphic symbol is inserted at the current display position
KAM : KEYBOARD ACTION MODE
ENABLED - All or part of manual input facilities are enabled
DISABLED - All or part of manual input facilities are disabled
MATM : MULTIPLE AREA TRANSFER MODE
SINGLE - Only the contents of the selected area that contains the active position
MULTIPLE - All selected areas are eliglble
PUM : POSITIONING UNIT MODE (Deprecated)
CHARACTER - The positioning unit for parameters is one character
SIZE - The positioning unit for parameters is set by SELECT SIZE UNIT
SATM : SELECTED AREA TRANSFER MODE
SELECT - Only selected areas are eligible for transfer
ALL - All areas are eligible for transfer
SRM : SEND/RECEIVE MODE
MONITOR - Data locally-entered are immediately imaged (local echo on)
SIMULTANEOUS - Only data sent to device are imaged (local echo off)
SRTM : STATUS REPORT TRANSFER MODE
NORMAL - Status reports in DEVICE CONTROL STRINGs not generated automatically
DIAGNOSTIC - Status reports in DEVICE CONTROL STRINGs included in every data stream
TSM : TABULATION STOP MODE
MULTIPLE - Tab stops are set/cleared in all lines at the same time
SINGLE - Tab stops are set/cleared only in active line
TTM : TRANSFER TERMINATION MODE
CURSOR - Contents only up to cursor are eligible for transfer
ALL - Contents before, at, and after the cursor are eligible for transfer
VEM : LINE EDITING MODE
FOLLOWING - Inserting/Deleting lines shifts following lines
PRECEDING - Inserting/Deleting lines shifts preceding lines
ZDM : ZERO DEFAULT MODE (Deprecated)
ZERO - A zero parameter to a control string means zero
DEFAULT - A zero parameter to a control string means default value
Control Functions
=================
Delimiters:
Acronym Notation Name
-----------------------------------------------
APC C1 APPLICATION PROGRAM COMMAND
CMD Fs CODING METHOD DELIMITER
DCS C1 DEVICE CONTROL STRING
OSC C1 OPERATING SYSTEM COMMAND
PM C1 PRIVACY MESSAGE
SOS C1 START OF STRING
ST C1 STRING TERMINATOR
Introducers:
Acronym Notation Name
-----------------------------------------------
CSI C1 CONTROL SEQUENCE INTRODUCER
ESC C0 ESCAPE
SCI C1 SINGLE CHARACTER INTRODUCER
Shift Functions:
Acronym Notation Name
-----------------------------------------------
LS0 C0 LOCKING-SHIFT ZERO
LS1 C0 LOCKING-SHIFT ONE
LS1R Fs LOCKING-SHIFT ONE RIGHT
LS2 Fs LOCKING-SHIFT TWO
LS2R Fs LOCKING-SHIFT TWO RIGHT
LS3 Fs LOCKING-SHIFT THREE
LS3R Fs LOCKING-SHIFT THREE RIGHT
SI C0 SHIFT-IN
SO C0 SHIFT-OUT
SS2 C1 SINGLE-SHIFT TWO
SS3 C1 SINGLE-SHIFT THREE
Format Effectors:
Acronym Notation Name
-----------------------------------------------
BS C0 BACKSPACE
CR C0 CARRIAGE RETURN
FF C0 FORM FEED
HPA Pn CHARACTER POSITION ABSOLUTE
HPB Pn CHARACTER POSITION BACKWARD
HPR Pn CHARACTER POSITION FORWARD
HT C0 CHARACTER TABULATION
HTJ C1 CHARACTER TABULATION WITH JUSTIFICATION
HTS C1 CHARACTER TABULATION SET
HVP Pn1;Pn2 CHARACTER AND LINE POSITION
LF C0 LINE FEED
NEL C1 NEXT LINE
PLD C1 PARTIAL LINE FORWARD
PLU C1 PARTIAL LINE BACKWARD
PPA Pn PAGE POSITION ABSOLUTE
PPB Pn PAGE POSITION BACKWARD
PPR Pn PAGE POSITION FORWARD
RI C1 REVERSE LINE FEED
TBC Ps TABULATION CLEAR
TSR Pn TABULATION STOP REMOVE
VPA Pn LINE POSITION ABSOLUTE
*/
#endif

525
ansi_cs_funcs_dec.c Normal file
View File

@ -0,0 +1,525 @@
#include "ansi_cs_table_defs.h"
#include "terminal.h"
// Select Set-Up Language
void cs_fn_DECSSL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Load LEDs
void cs_fn_DECLL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Top & Bottom Margins
void cs_fn_DECSTBM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Left & Right Margins
void cs_fn_DECSLRM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Lines per Physical Page
void cs_fn_DECSLPP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Request Terminal Parameters
void cs_fn_DECREQTPARM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Invoke Confidence Test
void cs_fn_DECTST(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Transmit Termination Character
void cs_fn_DECTTC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Protected Field Attributes
void cs_fn_DECPRO(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Function Key
void cs_fn_DECFNK(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Scroll Speed
void cs_fn_DECSSCLS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Cursor Style
void cs_fn_DECSCUSR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Keyclick Volume
void cs_fn_DECSKCV(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Warning Bell Volume
void cs_fn_DECSWBV(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Margin Bell Volume
void cs_fn_DECSMBV(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Lock Key Style
void cs_fn_DECSLCK(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Keyboard Language Selection
void cs_fn_DECKBD(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Terminal Mode Emulation
void cs_fn_DECTME(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Soft Terminal Reset
void cs_fn_DECSTR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Conformance Level
void cs_fn_DECSCL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Character Attributes
void cs_fn_DECSCA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Refresh Rate
void cs_fn_DECSRFR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Transmit Rate Limit
void cs_fn_DECSTRL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Request Device Extent
void cs_fn_DECRQDE(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Report Device Extent
void cs_fn_DECRPDE(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Request Mode Settings
void cs_fn_DECRQM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Disconnect Delay Time
void cs_fn_DECSDDT(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Change Attributes in Rectangular Area
void cs_fn_DECCARA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Printer Type
void cs_fn_DECSPRTT(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Reverse Attributes in Rectangular Area
void cs_fn_DECRARA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Request Terminal State Report
void cs_fn_DECRQTSR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Copy Rectangular Area
void cs_fn_DECCRA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Request Presentation State Report
void cs_fn_DECRQPSR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Fill Rectangular Area
void cs_fn_DECFRA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Report Mode Settings
void cs_fn_DECRPM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Erase Rectangular Area
void cs_fn_DECERA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Selective Erase Rectangular Area
void cs_fn_DECSERA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Columns Per Page
void cs_fn_DECSCPP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Active Status Display
void cs_fn_DECSASD(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Status Display Type
void cs_fn_DECSSDT(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Request User-Preferred Supplemental Set
void cs_fn_DECRQUPSS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Locator Report
void cs_fn_DECLRP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Enable Session
void cs_fn_DECES(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Transmit Line Termination Characters
void cs_fn_DECTLTC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Enable Filter Rectangle
void cs_fn_DECEFR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Enable Locator Reports
void cs_fn_DECELR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Locator Events
void cs_fn_DECSLE(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Request Locator Position
void cs_fn_DECRQLP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Insert Column
void cs_fn_DECIC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Delete Column
void cs_fn_DECDC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Digital Printed Data Type
void cs_fn_DECSPDT(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Text/Graphics Look-Up Table
void cs_fn_DECSTGLT(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select ProPrinter Character Set
void cs_fn_DECSPPCS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Secure Reset Confirmation
void cs_fn_DECSRC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Communication Speed
void cs_fn_DECSCS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Flow Control
void cs_fn_DECSFC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Communication Port
void cs_fn_DECSCP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Attribute Change Extent
void cs_fn_DECSACE(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Request Checksum of Rectangular Area
void cs_fn_DECRQCRA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Invoke Macro
void cs_fn_DECINVM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Macro Space Report
void cs_fn_DECMSR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Number of Lines per Screen
void cs_fn_DECSNLS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Local Function Key Control
void cs_fn_DECLFKC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Secure Reset
void cs_fn_DECSR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Enable Local Functions
void cs_fn_DECELF(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Modifier Key Reporting
void cs_fn_DECSMKR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Port Parameter
void cs_fn_DECSPP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Program Key Free Memory Inquiry
void cs_fn_DECRQPKFM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Program Key Free Memory Report
void cs_fn_DECPKFMR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Program Key Action
void cs_fn_DECPKA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Load Time of Day
void cs_fn_DECLTOD(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Terminal ID
void cs_fn_DECTID(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Key Type Inquiry
void cs_fn_DECRQKT(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Report Key Type
void cs_fn_DECRPKT(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Request Key Definition
void cs_fn_DECRQKD(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Session Page Memory Allocation
void cs_fn_DECSPMA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Update Session
void cs_fn_DECUS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Down Line Load Allocation
void cs_fn_DECDLDA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Zero Symbol
void cs_fn_DECSZS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Assign Color
void cs_fn_DECAC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Alternate Text Color
void cs_fn_DECATC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Play Sound
void cs_fn_DECPS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Auto Repeat Rate
void cs_fn_DECARR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// CRT Saver Timing
void cs_fn_DECCRTST(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Energy Saver Timing
void cs_fn_DECSEST(void *ctx, int paramc, unsigned int *paramv)
{
return;
}

559
ansi_cs_funcs_std.c Normal file
View File

@ -0,0 +1,559 @@
#include "ansi_cs_table_defs.h"
#include "terminal.h"
// Insert Character
void cs_fn_ICH(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_insertGraphic(ctx, ' ', paramv[0]);
}
// Cursor Up
void cs_fn_CUU(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_cursorRel(ctx, DIR_UP, paramv[0], 0);
}
// Cursor Down / Vertical Position Relative
void cs_fn_CUD_VPR(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_cursorRel(ctx, DIR_DOWN, paramv[0], 0);
}
// Cursor Forward / Horizontal Position Relative
void cs_fn_CUF_HPR(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_cursorRel(ctx, DIR_FORWARD, paramv[0], 0);
}
// Cursor Back
void cs_fn_CUB(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_cursorRel(ctx, DIR_BACK, paramv[0], 0);
}
// Cursor Next Line
void cs_fn_CNL(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_cursorRel(ctx, DIR_DOWN, paramv[0], 0);
Terminal_carriageReturn(ctx);
}
// Cursor Previous Line
void cs_fn_CPL(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_cursorRel(ctx, DIR_UP, paramv[0], 0);
Terminal_carriageReturn(ctx);
}
// Cursor Horizontal Absolute
void cs_fn_CHA(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_cursorAbsH(ctx, paramv[0]);
}
// Cursor Position / Horizontal & Vertical Position
void cs_fn_CUP_HVP(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
paramv[0] -= 1; paramv[1] -= 1; // switch to 0-based addressing
Terminal_cursorAbs(ctx, paramv[1], paramv[0]);
}
// Cursor Horizontal Forward Tab
void cs_fn_CHT(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_horizontalTab(ctx, paramv[0]);
}
// Erase in Display
void cs_fn_ED(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Erase in Line
void cs_fn_EL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Insert Line
void cs_fn_IL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Delete Line
void cs_fn_DL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Erase in Field
void cs_fn_EF(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Erase in Area
void cs_fn_EA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Delete Character
void cs_fn_DCH(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Editing Extent
void cs_fn_SEE(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Cursor Position Report
void cs_fn_CPR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Scroll Up (DEC Pan Down)
void cs_fn_SU(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Scroll Down (DEC Pan Up)
void cs_fn_SD(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Next Page
void cs_fn_NP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Previous Page
void cs_fn_PP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Cursor Tabulation Control
void cs_fn_CTC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Erase Character
void cs_fn_ECH(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Cursor Vertical (Line) Tabulation
void cs_fn_CVT(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Cursor Backward Tabulation
void cs_fn_CBT(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_backTab(ctx, paramv[0]);
}
// Start Reversed String
void cs_fn_SRS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Parallel Texts
void cs_fn_PTX(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Start Directed String
void cs_fn_SDS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Implicit Movement Direction
void cs_fn_SIMD(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Horizontal Position Absolute
void cs_fn_HPA(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_cursorAbsH(ctx, paramv[0]);
}
// Repeat
void cs_fn_REP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Device Attributes
void cs_fn_DA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Vertical Position Absolute
void cs_fn_VPA(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
Terminal_cursorAbsV(ctx, paramv[0]);
}
// Tabulation Clear
void cs_fn_TBC(void *ctx, int paramc, unsigned int *paramv)
{
(void)paramc;
switch (paramv[0]) {
case 0: // Clear tab only at cursor
Terminal_clearTab(ctx);
break;
case 3: // Clear all tabs
Terminal_clearTabs(ctx);
break;
}
}
// Set Mode
void cs_fn_SM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Media Copy
void cs_fn_MC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Horizontal (Character) Position Backward
void cs_fn_HPB(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Vertical (Line) Position Backward
void cs_fn_VPB(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Reset Mode
void cs_fn_RM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Graphic Rendition
void cs_fn_SGR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Device Status Report
void cs_fn_DSR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Define Area Qualification
void cs_fn_DAQ(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Scroll Left
void cs_fn_SL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Scroll Right
void cs_fn_SR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Graphic Size Modification
void cs_fn_GSM(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Graphic Size Selection
void cs_fn_GSS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Font Selection
void cs_fn_FNT(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Thin Space Specification
void cs_fn_TSS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Justify
void cs_fn_JFY(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Spacing Increment
void cs_fn_SPI(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Quad
void cs_fn_QUAD(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Size Unit
void cs_fn_SSU(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Page Format Selection
void cs_fn_PFS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Horizontal Spacing
void cs_fn_SHS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Vertical Spacing
void cs_fn_SVS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Identify Graphics Subrepertoire
void cs_fn_IGS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Horizontal Tabulation Set Absolute
void cs_fn_HTSA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Identify Device Control String
void cs_fn_IDCS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Page Position Absolute
void cs_fn_PPA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Page Position Relative
void cs_fn_PPR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Page Position Backward
void cs_fn_PPB(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Presentation Directions
void cs_fn_SPD(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Dimension Text Area
void cs_fn_DTA(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Line Home
void cs_fn_SLH(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Line Limit
void cs_fn_SLL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Function Key
void cs_fn_FNK(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Print Quality & Rapidity
void cs_fn_SPQR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Sheet Eject & Feed
void cs_fn_SEF(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Presentation Expand or Contract
void cs_fn_PEC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Space Width
void cs_fn_SSW(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Additional Character Separation
void cs_fn_SACS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Alternative Presentation Variants
void cs_fn_SAPV(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Selective Tabulation
void cs_fn_STAB(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Graphic Character Combination
void cs_fn_GCC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Tabulation Aligned Trailing Edge
void cs_fn_TATE(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Tabulation Aligned Leading Edge
void cs_fn_TALE(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Tabulation Aligned Centered
void cs_fn_TAC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Tabulation Centered on Character
void cs_fn_TCC(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Tabulation Stop Remove
void cs_fn_TSR(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Character Orientation
void cs_fn_SCO(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Reduced Character Separation
void cs_fn_SRCS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Character Spacing
void cs_fn_SCS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Line Spacing
void cs_fn_SLS(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Page Home
void cs_fn_SPH(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Set Page Limit
void cs_fn_SPL(void *ctx, int paramc, unsigned int *paramv)
{
return;
}
// Select Character Path
void cs_fn_SCP(void *ctx, int paramc, unsigned int *paramv)
{
return;
}

534
ansi_cs_table_defs.c Normal file
View File

@ -0,0 +1,534 @@
#include "ansi_cs_table_defs.h"
/*
* No Intermediate Character, Final Character Cols 4 - 7
*/
/* Final Character Col 4 */
CE cs_ICH = {{"Insert Character", ENTRY_CS}, "ICH", 1, {1}, cs_fn_ICH};
CE cs_CUU = {{"Cursor Up", ENTRY_CS}, "CUU", 1, {1}, cs_fn_CUU};
CE cs_CUD = {{"Cursor Down", ENTRY_CS}, "CUD", 1, {1}, cs_fn_CUD_VPR};
CE cs_CUF = {{"Cursor Forward", ENTRY_CS}, "CUF", 1, {1}, cs_fn_CUF_HPR};
CE cs_CUB = {{"Cursor Back", ENTRY_CS}, "CUB", 1, {1}, cs_fn_CUB};
CE cs_CNL = {{"Cursor Next Line", ENTRY_CS}, "CNL", 1, {1}, cs_fn_CNL};
CE cs_CPL = {{"Cursor Previous Line", ENTRY_CS}, "CNL", 1, {1}, cs_fn_CPL};
CE cs_CHA = {{"Cursor Horizontal Absolute", ENTRY_CS}, "CHA", 1, {1}, cs_fn_CHA};
CE cs_CUP = {{"Cursor Position", ENTRY_CS}, "CUP", 2, {1, 1}, cs_fn_CUP_HVP};
CE cs_CHT = {{"Cursor Horizontal Forward Tab", ENTRY_CS}, "CHT", 1, {1}, cs_fn_CHT};
CE cs_ED = {{"Erase in Display", ENTRY_CS}, "ED", 1, {1}, cs_fn_ED};
CE cs_EL = {{"Erase in Line", ENTRY_CS}, "ED", 1, {1}, cs_fn_EL};
CE cs_IL = {{"Insert Line", ENTRY_CS}, "IL", 1, {1}, cs_fn_IL};
CE cs_DL = {{"Delete Line", ENTRY_CS}, "DL", 1, {1}, cs_fn_DL};
CE cs_EF = {{"Erase in Field", ENTRY_CS}, "EF", 1, {1}, cs_fn_EF};
CE cs_EA = {{"Erase in Area", ENTRY_CS}, "EA", 1, {1}, cs_fn_EA};
struct table_col CS_NoI_4 = {{
&cs_ICH.head, &cs_CUU.head, &cs_CUD.head, &cs_CUF.head,
&cs_CUB.head, &cs_CNL.head, &cs_CPL.head, &cs_CHA.head,
&cs_CUP.head, &cs_CHT.head, &cs_ED.head, &cs_EL.head,
&cs_IL.head, &cs_DL.head, &cs_EF.head, &cs_EA.head
}};
/* Final Character Col 5 */
CE cs_DCH = {{"Delete Character", ENTRY_CS}, "DCH", 1, {1}, cs_fn_DCH};
CE cs_SEE = {{"Select Editing Extent", ENTRY_CS}, "SEE", 1, {1}, cs_fn_SEE};
CE cs_CPR = {{"Cursor Position Report", ENTRY_CS}, "CPR", 1, {1}, cs_fn_CPR};
CE cs_SU = {{"Scroll Up (DEC Pan Down)", ENTRY_CS}, "SU", 1, {1}, cs_fn_SU};
CE cs_SD = {{"Scroll Down (DEC Pan Up)", ENTRY_CS}, "SD", 1, {1}, cs_fn_SD};
CE cs_NP = {{"Next Page", ENTRY_CS}, "NP", 1, {1}, cs_fn_NP};
CE cs_PP = {{"Previous Page", ENTRY_CS}, "PP", 1, {1}, cs_fn_PP};
CE cs_CTC = {{"Cursor Tabulation Control", ENTRY_CS}, "CTC", 1, {1}, cs_fn_CTC};
CE cs_ECH = {{"Erase Character", ENTRY_CS}, "ECH", 1, {1}, cs_fn_ECH};
CE cs_CVT = {{"Cursor Vertical Tabulation", ENTRY_CS}, "CVT", 1, {1}, cs_fn_CVT};
CE cs_CBT = {{"Cursor Backward Tabulation", ENTRY_CS}, "CBT", 1, {1}, cs_fn_CBT};
CE cs_SRS = {{"Start Reversed String", ENTRY_CS}, "SRS", 1, {1}, cs_fn_SRS};
CE cs_PTX = {{"Parallel Texts", ENTRY_CS}, "PTX", 1, {1}, cs_fn_PTX};
CE cs_SDS = {{"Start Directed String", ENTRY_CS}, "SDS", 1, {1}, cs_fn_SDS};
CE cs_SIMD= {{"Select Implicit Movement Dir", ENTRY_CS}, "SIMD",1, {1}, cs_fn_SIMD};
// Blank
struct table_col CS_NoI_5 = {{
&cs_DCH.head, &cs_SEE.head, &cs_CPR.head, &cs_SU.head,
&cs_SD.head, &cs_NP.head, &cs_PP.head, &cs_CTC.head,
&cs_ECH.head, &cs_CVT.head, &cs_CBT.head, &cs_SRS.head,
&cs_PTX.head, &cs_SDS.head, &cs_SIMD.head, 0
}};
/* Final Character Col 6 */
CE cs_HPA = {{"Horizontal Position Absolute", ENTRY_CS}, "HPA", 1, {1}, cs_fn_HPA};
CE cs_HPR = {{"Horizontal Position Relative", ENTRY_CS}, "HPR", 1, {1}, cs_fn_CUF_HPR};
CE cs_REP = {{"Repeat", ENTRY_CS}, "REP", 1, {1}, cs_fn_REP};
CE cs_DA = {{"Device Attributes", ENTRY_CS}, "DA", 1, {1}, cs_fn_DA};
CE cs_VPA = {{"Vertical Position Absolute", ENTRY_CS}, "VPA", 1, {1}, cs_fn_VPA};
CE cs_VPR = {{"Vertical Position Relative", ENTRY_CS}, "VPR", 1, {1}, cs_fn_CUD_VPR};
CE cs_HVP = {{"Horizontal & Vertical Position",ENTRY_CS}, "HVP", 2, {1, 1}, cs_fn_CUP_HVP};
CE cs_TBC = {{"Tabulation Clear", ENTRY_CS}, "TBC", 1, {1}, cs_fn_TBC};
CE cs_SM = {{"Set Mode", ENTRY_CS}, "SM", 1, {1}, cs_fn_SM};
CE cs_MC = {{"Media Copy", ENTRY_CS}, "MC", 1, {1}, cs_fn_MC};
CE cs_HPB = {{"Horizontal Position Backward", ENTRY_CS}, "HPB", 1, {1}, cs_fn_HPB};
CE cs_VPB = {{"Vertical Position Backward", ENTRY_CS}, "VPB", 1, {1}, cs_fn_VPB};
CE cs_RM = {{"Reset Mode", ENTRY_CS}, "RM", 1, {1}, cs_fn_RM};
CE cs_SGR = {{"Set Graphic Rendition", ENTRY_CS}, "SGR", 1, {1}, cs_fn_SGR};
CE cs_DSR = {{"Device Status Report", ENTRY_CS}, "DSR", 1, {1}, cs_fn_DSR};
CE cs_DAQ = {{"Define Area Qualification", ENTRY_CS}, "DAQ", 1, {1}, cs_fn_DAQ};
struct table_col CS_NoI_6 = {{
&cs_HPA.head, &cs_HPR.head, &cs_REP.head, &cs_DA.head,
&cs_VPA.head, &cs_VPR.head, &cs_HVP.head, &cs_TBC.head,
&cs_SM.head, &cs_MC.head, &cs_HPB.head, &cs_VPB.head,
&cs_RM.head, &cs_SGR.head, &cs_DSR.head, &cs_DAQ.head
}};
/* Final Character Col 7 (DEC Private) */
CE cs_DECSSL = {{"Select Set-Up Language", ENTRY_CS}, "DECSSL", 1, {1}, cs_fn_DECSSL};
CE cs_DECLL = {{"Load LEDs", ENTRY_CS}, "DECLL", 1, {1}, cs_fn_DECLL};
CE cs_DECSTBM = {{"Set Top & Bottom Margins", ENTRY_CS}, "DECSTBM", 1, {1}, cs_fn_DECSTBM};
CE cs_DECSLRM = {{"Set Left & Right Margins", ENTRY_CS}, "DECSLRM", 1, {1}, cs_fn_DECSLRM};
CE cs_DECSLPP = {{"Set Lines per Physical Page",ENTRY_CS}, "DECSLPP", 1, {1}, cs_fn_DECSLPP};
// Blank
// Blank
// Blank
CE cs_DECREQTPARM = {{"Request Terminal Parameters", ENTRY_CS}, "DECREQTPARM", 1, {1},cs_fn_DECREQTPARM};
CE cs_DECTST = {{"Invoke Confidence Test", ENTRY_CS}, "DECTST", 1, {1}, cs_fn_DECTST};
// Blank
// Blank
CE cs_DECTTC = {{"Select Transmit Termination Character", ENTRY_CS}, "DECTTC", 1, {1}, cs_fn_DECTTC};
CE cs_DECPRO = {{"Set Protected Field Attributes", ENTRY_CS}, "DECPRO", 1, {1}, cs_fn_DECPRO};
CE cs_DECFNK = {{"Function Key", ENTRY_CS}, "DECFNK", 1, {1}, cs_fn_DECFNK};
struct table_col CS_NoI_7_DEC = {{
&cs_DECSSL.head, &cs_DECLL.head, &cs_DECSTBM.head, &cs_DECSLRM.head,
&cs_DECSLPP.head,0 , 0, 0,
&cs_DECREQTPARM.head, &cs_DECTST.head, 0, 0,
&cs_DECTTC.head, &cs_DECPRO.head,&cs_DECFNK.head, 0
}};
struct control_seq_final_table CS_NoI = {{ &CS_NoI_4, &CS_NoI_5, &CS_NoI_6, &CS_NoI_7_DEC }};
/*
* Intermediate Character 0, Final Character Cols 4 - 7
*/
/* Final Character Col 4 */
CE cs_SL = {{"Scroll Left", ENTRY_CS}, "SL", 1, {1}, cs_fn_SL};
CE cs_SR = {{"Scroll Right", ENTRY_CS}, "SR", 1, {1}, cs_fn_SR};
CE cs_GSM = {{"Graphic Size Modification", ENTRY_CS}, "GSM", 1, {1}, cs_fn_GSM};
CE cs_GSS = {{"Graphic Size Selection", ENTRY_CS}, "GSS", 1, {1}, cs_fn_GSS};
CE cs_FNT = {{"Font Selection", ENTRY_CS}, "FNT", 1, {1}, cs_fn_FNT};
CE cs_TSS = {{"Thin Space Specification", ENTRY_CS}, "TSS", 1, {1}, cs_fn_TSS};
CE cs_JFY = {{"Justify", ENTRY_CS}, "JFY", 1, {1}, cs_fn_JFY};
CE cs_SPI = {{"Spacing Increment", ENTRY_CS}, "SPI", 1, {1}, cs_fn_SPI};
CE cs_QUAD= {{"Quad", ENTRY_CS}, "QUAD",1, {1}, cs_fn_QUAD};
CE cs_SSU = {{"Select Size Unit", ENTRY_CS}, "SSU", 1, {1}, cs_fn_SSU};
CE cs_PFS = {{"Page Format Selection", ENTRY_CS}, "PFS", 1, {1}, cs_fn_PFS};
CE cs_SHS = {{"Select Horizontal Spacing", ENTRY_CS}, "SHS", 1, {1}, cs_fn_SHS};
CE cs_SVS = {{"Select Vertical Spacing", ENTRY_CS}, "SVS", 1, {1}, cs_fn_SVS};
CE cs_IGS = {{"Identify Graphics Subrep.", ENTRY_CS}, "IGS", 1, {1}, cs_fn_IGS};
CE cs_HTSA= {{"Horizontal Tabulation Set Abs", ENTRY_CS}, "HTSA",1, {1}, cs_fn_HTSA};
CE cs_IDCS= {{"Identify Device Control String",ENTRY_CS}, "IDCS",1, {1}, cs_fn_IDCS};
struct table_col CS_I0_4 = {{
&cs_SL.head, &cs_SR.head, &cs_GSM.head, &cs_GSS.head,
&cs_FNT.head, &cs_TSS.head, &cs_JFY.head, &cs_SPI.head,
&cs_QUAD.head,&cs_SSU.head, &cs_PFS.head, &cs_SHS.head,
&cs_SVS.head, &cs_IGS.head, &cs_HTSA.head,&cs_IDCS.head
}};
/* Final Character Col 5 */
CE cs_PPA = {{"Page Position Absolute", ENTRY_CS}, "PPA", 1, {1}, cs_fn_PPA};
CE cs_PPR = {{"Page Position Relative", ENTRY_CS}, "PPR", 1, {1}, cs_fn_PPR};
CE cs_PPB = {{"Page Position Backward", ENTRY_CS}, "PPB", 1, {1}, cs_fn_PPB};
CE cs_SPD = {{"Select Presentation Directions",ENTRY_CS}, "SPD", 1, {1}, cs_fn_SPD};
CE cs_DTA = {{"Dimension Text Area", ENTRY_CS}, "DTA", 1, {1}, cs_fn_DTA};
CE cs_SLH = {{"Set Line Home", ENTRY_CS}, "SLH", 1, {1}, cs_fn_SLH};
CE cs_SLL = {{"Set Line Limit", ENTRY_CS}, "SLL", 1, {1}, cs_fn_SLL};
CE cs_FNK = {{"Function Key", ENTRY_CS}, "FNK", 1, {1}, cs_fn_FNK};
CE cs_SPQR= {{"Select Print Quality&Rapidity", ENTRY_CS}, "SPQR",1, {1}, cs_fn_SPQR};
CE cs_SEF = {{"Sheet Eject & Feed", ENTRY_CS}, "SEF", 1, {1}, cs_fn_SEF};
CE cs_PEC = {{"Pres Expand or Contract", ENTRY_CS}, "PEC", 1, {1}, cs_fn_PEC};
CE cs_SSW = {{"Set Space Width", ENTRY_CS}, "SSW", 1, {1}, cs_fn_SSW};
CE cs_SACS= {{"Set Addl Character Separation", ENTRY_CS}, "SACS",1, {1}, cs_fn_SACS};
CE cs_SAPV= {{"Select Alt Pres Variants", ENTRY_CS}, "SAPV",1, {1}, cs_fn_SAPV};
CE cs_STAB= {{"Selective Tabulation", ENTRY_CS}, "STAB",1, {1}, cs_fn_STAB};
CE cs_GCC = {{"Graphic Character Combination", ENTRY_CS}, "GCC", 1, {1}, cs_fn_GCC};
struct table_col CS_I0_5 = {{
&cs_PPA.head, &cs_PPR.head, &cs_PPB.head, &cs_SPD.head,
&cs_DTA.head, &cs_SLH.head, &cs_SLL.head, &cs_FNK.head,
&cs_SPQR.head,&cs_SEF.head, &cs_PEC.head, &cs_SSW.head,
&cs_SACS.head,&cs_SAPV.head,&cs_STAB.head,&cs_GCC.head
}};
/* Final Character Col 6 */
CE cs_TATE= {{"Tab Aligned Trailing Edge", ENTRY_CS}, "TATE",1, {1}, cs_fn_TATE};
CE cs_TALE= {{"Tab Aligned Leading Edge", ENTRY_CS}, "TALE",1, {1}, cs_fn_TALE};
CE cs_TAC = {{"Tab Aligned Centered", ENTRY_CS}, "TAC", 1, {1}, cs_fn_TAC};
CE cs_TCC = {{"Tab Centered on Character", ENTRY_CS}, "TCC", 1, {1}, cs_fn_TCC};
CE cs_TSR = {{"Tab Stop Remove", ENTRY_CS}, "TSR", 1, {1}, cs_fn_TSR};
CE cs_SCO = {{"Set Character Orientation", ENTRY_CS}, "SCO", 1, {1}, cs_fn_SCO};
CE cs_SRCS= {{"Set Reduced Char Separation", ENTRY_CS}, "SRCS",1, {1}, cs_fn_SRCS};
CE cs_SCS = {{"Set Character Spacing", ENTRY_CS}, "SCS", 1, {1}, cs_fn_SCS};
CE cs_SLS = {{"Set Line Spacing", ENTRY_CS}, "SLS", 1, {1}, cs_fn_SLS};
CE cs_SPH = {{"Set Page Home", ENTRY_CS}, "SPH", 1, {1}, cs_fn_SPH};
CE cs_SPL = {{"Set Page Limit", ENTRY_CS}, "SPL", 1, {1}, cs_fn_SPL};
CE cs_SCP = {{"Select Character Path", ENTRY_CS}, "SCP", 1, {1}, cs_fn_SCP};
struct table_col CS_I0_6 = {{
&cs_TATE.head,&cs_TALE.head,&cs_TAC.head, &cs_TCC.head,
&cs_TSR.head, &cs_SCO.head, &cs_SRCS.head,&cs_SCS.head,
&cs_SLS.head, &cs_SPH.head, &cs_SPL.head, &cs_SCP.head,
0, 0, 0, 0
}};
/* Final Character Col 7 (DEC Private) */
CE cs_DECSSCLS= {{"Set Scroll Speed", ENTRY_CS}, "DECSSCLS", 1, {1}, cs_fn_DECSSCLS};
CE cs_DECSCUSR= {{"Set Cursor Style", ENTRY_CS}, "DECSCUSR", 1, {1}, cs_fn_DECSCUSR};
CE cs_DECSKCV = {{"Set Keyclick Volume", ENTRY_CS}, "DECSKCV", 1, {1}, cs_fn_DECSKCV};
// Blank
CE cs_DECSWBV = {{"Set Warning Bell Volume", ENTRY_CS}, "DECSWBV", 1, {1}, cs_fn_DECSWBV};
CE cs_DECSMBV = {{"Set Margin Bell Volume", ENTRY_CS}, "DECSMBV", 1, {1}, cs_fn_DECSMBV};
CE cs_DECSLCK = {{"Set Lock Key Style", ENTRY_CS}, "DECSLCK", 1, {1}, cs_fn_DECSLCK};
// Blank
// Blank
// Blank
// Blank
// Blank
// Blank
CE cs_DECKBD = {{"Keyboard Language Selection", ENTRY_CS}, "DECKBD", 1, {1}, cs_fn_DECKBD};
CE cs_DECTME = {{"Terminal Mode Emulation", ENTRY_CS}, "DECTME", 1, {1}, cs_fn_DECTME};
struct table_col CS_I0_7_DEC = {{
&cs_DECSSCLS.head, &cs_DECSCUSR.head, &cs_DECSKCV.head, 0,
&cs_DECSWBV.head, &cs_DECSMBV.head, &cs_DECSLCK.head, 0,
0, 0, 0, 0,
0, &cs_DECKBD.head, &cs_DECTME.head, 0
}};
struct control_seq_final_table CS_I0 = {{ &CS_I0_4, &CS_I0_5, &CS_I0_6, &CS_I0_7_DEC }};
/*
* Intermediate Character 1, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
CE cs_DECSTR = {{"Soft Terminal Reset", ENTRY_CS}, "DECSTR", 1, {1}, cs_fn_DECSTR};
struct table_col CS_I1_7_DEC = {{
&cs_DECSTR.head, 0, 0, 0,
0 , 0, 0, 0,
0 , 0, 0, 0,
0 , 0, 0, 0
}};
struct control_seq_final_table CS_I1 = {{ 0, 0, 0, &CS_I1_7_DEC }};
/*
* Intermediate Character 2, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
CE cs_DECSCL = {{"Set Conformance Level", ENTRY_CS}, "DECSCL", 1, {1}, cs_fn_DECSCL};
CE cs_DECSCA = {{"Select Character Attributes", ENTRY_CS}, "DECSCA", 1, {1}, cs_fn_DECSCA};
// Blank
// Blank
CE cs_DECSRFR = {{"Select Refresh Rate", ENTRY_CS}, "DECSRFR", 1, {1}, cs_fn_DECSRFR};
CE cs_DECSTRL = {{"Set Transmit Rate Limit", ENTRY_CS}, "DECSTRL", 1, {1},cs_fn_DECSTRL};
CE cs_DECRQDE = {{"Request Device Extent", ENTRY_CS}, "DECRQDE", 1, {1}, cs_fn_DECRQDE};
CE cs_DECRPDE = {{"Report Device Extent", ENTRY_CS}, "DECRPDE", 1, {1}, cs_fn_DECRPDE};
struct table_col CS_I2_7_DEC = {{
&cs_DECSCL.head, &cs_DECSCA.head, 0, 0,
&cs_DECSRFR.head, &cs_DECSTRL.head, &cs_DECRQDE.head, &cs_DECRPDE.head,
0, 0, 0, 0,
0, 0, 0, 0
}};
struct control_seq_final_table CS_I2 = {{ 0, 0, 0, &CS_I2_7_DEC }};
/*
* No Intermediate Character 3 functions
*/
// struct control_seq_final_table CS_I3 = {{ 0, 0, 0, 0 }};
/*
* Intermediate Character 4, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
CE cs_DECRQM = {{"Request Mode Settings", ENTRY_CS}, "DECRQM", 1, {1}, cs_fn_DECRQM};
CE cs_DECSDDT = {{"Select Disconnect Delay Time", ENTRY_CS}, "DECSDDT", 1, {1}, cs_fn_DECSDDT};
CE cs_DECCARA = {{"Change Attributes in Rectangular Area", ENTRY_CS}, "DECCARA", 1, {1}, cs_fn_DECCARA};
CE cs_DECSPRTT= {{"Select Printer Type", ENTRY_CS}, "DECSPRTT", 1, {1}, cs_fn_DECSPRTT};
CE cs_DECRARA = {{"Reverse Attributes in Rectangular Area", ENTRY_CS}, "DECRARA", 1, {1}, cs_fn_DECRARA};
CE cs_DECRQTSR= {{"Request Terminal State Report", ENTRY_CS}, "DECRQTSR", 1, {1}, cs_fn_DECRQTSR};
CE cs_DECCRA = {{"Copy Rectangular Area", ENTRY_CS}, "DECCRA", 1, {1}, cs_fn_DECCRA};
CE cs_DECRQPSR= {{"Request Presentation State Report", ENTRY_CS}, "DECRQPSR", 1, {1}, cs_fn_DECRQPSR};
CE cs_DECFRA = {{"Fill Rectangular Area", ENTRY_CS}, "DECFRA", 1, {1}, cs_fn_DECFRA};
CE cs_DECRPM = {{"Report Mode Settings", ENTRY_CS}, "DECRPM", 1, {1}, cs_fn_DECRPM};
CE cs_DECERA = {{"Erase Rectangular Area", ENTRY_CS}, "DECERA", 1, {1}, cs_fn_DECERA};
CE cs_DECSERA = {{"Selective Erase Rectangular Area", ENTRY_CS}, "DECSERA", 1, {1}, cs_fn_DECSERA};
CE cs_DECSCPP = {{"Set Columns Per Page", ENTRY_CS}, "DECSCPP", 1, {1}, cs_fn_DECSCPP};
CE cs_DECSASD = {{"Select Active Status Display", ENTRY_CS}, "DECSASD", 1, {1}, cs_fn_DECSASD};
CE cs_DECSSDT = {{"Select Status Display Type", ENTRY_CS}, "DECSSDT", 1, {1}, cs_fn_DECSSDT};
struct table_col CS_I4_7_DEC = {{
&cs_DECRQM.head, &cs_DECSDDT.head, &cs_DECCARA.head, &cs_DECSPRTT.head,
&cs_DECRARA.head, &cs_DECRQTSR.head, &cs_DECCRA.head, &cs_DECRQPSR.head,
&cs_DECFRA.head, &cs_DECRPM.head, &cs_DECERA.head, &cs_DECSERA.head,
&cs_DECSCPP.head, &cs_DECSASD.head, &cs_DECSSDT.head, 0
}};
struct control_seq_final_table CS_I4 = {{ 0, 0, 0, &CS_I4_7_DEC }};
/*
* No Intermediate Character 5 functions
*/
// struct control_seq_final_table CS_I5 = {{ 0, 0, 0, 0 }};
/*
* Intermediate Character 6, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
// Blank
// Blank
// Blank
// Blank
// Blank
CE cs_DECRQUPSS= {{"Request User-Preferred Supplemental Set", ENTRY_CS}, "DECRQUPSS", 1, {1},cs_fn_DECRQUPSS};
// Blank
CE cs_DECLRP = {{"Locator Report", ENTRY_CS}, "DECLRP", 1, {1}, cs_fn_DECLRP};
CE cs_DECES = {{"Enable Session", ENTRY_CS}, "DECES", 1, {1}, cs_fn_DECES};
struct table_col CS_I6_7_DEC = {{
0, 0, 0, 0,
0, &cs_DECRQUPSS.head, 0, &cs_DECLRP.head,
&cs_DECES.head,0, 0, 0,
0, 0, 0, 0
}};
struct control_seq_final_table CS_I6 = {{ 0, 0, 0, &CS_I6_7_DEC }};
/*
* Intermediate Character 7, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
//blank
//blank
//blank
CE cs_DECTLTC= {{"Transmit Line Termination Characters", ENTRY_CS}, "DECTLTC", 1, {1},cs_fn_DECTLTC};
//blank
//blank
//blank
CE cs_DECEFR = {{"Enable Filter Rectangle", ENTRY_CS}, "DECEFR", 1, {1}, cs_fn_DECEFR};
//blank
//blank
CE cs_DECELR = {{"Enable Locator Reports", ENTRY_CS}, "DECELR", 1, {1}, cs_fn_DECELR};
CE cs_DECSLE = {{"Select Locator Events", ENTRY_CS}, "DECSLE", 1, {1}, cs_fn_DECSLE};
CE cs_DECRQLP= {{"Request Locator Position", ENTRY_CS}, "DECRQLP", 1, {1},cs_fn_DECRQLP};
CE cs_DECIC = {{"Insert Column", ENTRY_CS}, "DECIC", 1, {1}, cs_fn_DECIC};
CE cs_DECDC = {{"Delete Column", ENTRY_CS}, "DECDC", 1, {1}, cs_fn_DECDC};
struct table_col CS_I7_7_DEC = {{
0, 0, 0, &cs_DECTLTC.head,
0, 0, 0, &cs_DECEFR.head,
0, 0, &cs_DECELR.head, &cs_DECSLE.head,
&cs_DECRQLP.head, &cs_DECIC.head, &cs_DECDC.head, 0
}};
struct control_seq_final_table CS_I7 = {{ 0, 0, 0, &CS_I7_7_DEC }};
/*
* No Intermediate Character 8 functions
*/
// struct control_seq_final_table CS_I8 = {{ 0, 0, 0, 0 }};
/*
* Intermediate Character 9, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
CE cs_DECSPDT = {{"Select Digital Printed Data Type", ENTRY_CS}, "DECSPDT", 1, {1}, cs_fn_DECSPDT};
//blank
//blank
//blank
//blank
//blank
//blank
//blank
//blank
//blank
//blank
//blank
//blank
CE cs_DECSTGLT= {{"Select Text/Graphics Look-Up Table", ENTRY_CS}, "DECSTGLT", 1, {1},cs_fn_DECSTGLT};
struct table_col CS_I9_7_DEC = {{
&cs_DECSPDT.head, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, &cs_DECSTGLT.head, 0, 0
}};
struct control_seq_final_table CS_I9 = {{ 0, 0, 0, &CS_I9_7_DEC }};
/*
* Intermediate Character 10, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
CE cs_DECSPPCS= {{"Select ProPrinter Character Set",ENTRY_CS}, "DECSPPCS", 1, {1},cs_fn_DECSPPCS};
CE cs_DECSRC = {{"Secure Reset Confirmation", ENTRY_CS}, "DECSRC", 1, {1}, cs_fn_DECSRC};
CE cs_DECSCS = {{"Select Communication Speed", ENTRY_CS}, "DECSCS", 1, {1}, cs_fn_DECSCS};
CE cs_DECSFC = {{"Select Flow Control", ENTRY_CS}, "DECSFC", 1, {1}, cs_fn_DECSFC};
//blank
CE cs_DECSCP = {{"Select Communication Port", ENTRY_CS}, "DECSCP", 1, {1}, cs_fn_DECSCP};
//blank
//blank
CE cs_DECSACE = {{"Select Attribute Change Extent", ENTRY_CS}, "DECSACE", 1, {1},cs_fn_DECSACE};
CE cs_DECRQCRA= {{"Request Checksum of Rectangular Area", ENTRY_CS}, "DECRQCRA", 1, {1},cs_fn_DECRQCRA};
CE cs_DECINVM = {{"Invoke Macro", ENTRY_CS}, "DECINVM", 1, {1},cs_fn_DECINVM};
CE cs_DECMSR = {{"Macro Space Report", ENTRY_CS}, "DECMSR", 1, {1}, cs_fn_DECMSR};
CE cs_DECSNLS = {{"Select Number of Lines per Screen", ENTRY_CS}, "DECSNLS", 1, {1},cs_fn_DECSNLS};
CE cs_DECLFKC = {{"Local Function Key Control", ENTRY_CS}, "DECLFKC", 1, {1},cs_fn_DECLFKC};
struct table_col CS_I10_7_DEC = {{
&cs_DECSPPCS.head, &cs_DECSRC.head, &cs_DECSCS.head, &cs_DECSFC.head,
0, &cs_DECSCP.head, 0, 0,
&cs_DECSACE.head, &cs_DECRQCRA.head, &cs_DECINVM.head, &cs_DECMSR.head,
&cs_DECSNLS.head, &cs_DECLFKC.head, 0, 0
}};
struct control_seq_final_table CS_I10 = {{ 0, 0, 0, &CS_I10_7_DEC }};
/*
* Intermediate Character 11, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
CE cs_DECSR = {{"Secure Reset", ENTRY_CS}, "DECSR", 1, {1}, cs_fn_DECSR};
CE cs_DECELF = {{"Enable Local Functions", ENTRY_CS}, "DECELF", 1, {1}, cs_fn_DECELF};
CE cs_DECSMKR = {{"Select Modifier Key Reporting", ENTRY_CS}, "DECSMKR", 1, {1},cs_fn_DECSMKR};
//blank
//blank
//blank
//blank
CE cs_DECSPP = {{"Select Port Parameter", ENTRY_CS}, "DECSPP", 1, {1}, cs_fn_DECSPP};
CE cs_DECRQPKFM= {{"Program Key Free Memory Inquiry", ENTRY_CS}, "DECRQPKFM", 1, {1},cs_fn_DECRQPKFM};
CE cs_DECPKFMR = {{"Program Key Free Memory Report", ENTRY_CS}, "DECPKFMR", 1, {1}, cs_fn_DECPKFMR};
CE cs_DECPKA = {{"Program Key Action", ENTRY_CS}, "DECPKA", 1, {1}, cs_fn_DECPKA};
struct table_col CS_I11_7_DEC = {{
&cs_DECSR.head, &cs_DECELF.head, &cs_DECSMKR.head, 0,
0, 0, 0, &cs_DECSPP.head,
&cs_DECRQPKFM.head, &cs_DECPKFMR.head, &cs_DECPKA.head, 0,
0, 0, 0, 0
}};
struct control_seq_final_table CS_I11 = {{ 0, 0, 0, &CS_I11_7_DEC }};
/*
* Intermediate Character 12, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
CE cs_DECLTOD= {{"Load Time of Day", ENTRY_CS}, "DECLTOD", 1, {1}, cs_fn_DECLTOD};
CE cs_DECTID = {{"Select Terminal ID", ENTRY_CS}, "DECTID", 1, {1}, cs_fn_DECTID};
//blank
//blank
//blank
CE cs_DECRQKT= {{"Key Type Inquiry", ENTRY_CS}, "DECRQKT", 1, {1}, cs_fn_DECRQKT};
CE cs_DECRPKT= {{"Report Key Type", ENTRY_CS}, "DECRPKT", 1, {1}, cs_fn_DECRPKT};
CE cs_DECRQKD= {{"Request Key Definition", ENTRY_CS}, "DECRQKD", 1, {1}, cs_fn_DECRQKD};
CE cs_DECSPMA= {{"Session Page Memory Allocation", ENTRY_CS}, "DECSPMA", 1, {1},cs_fn_DECSPMA};
CE cs_DECUS = {{"Update Session", ENTRY_CS}, "DECUS", 1, {1}, cs_fn_DECUS};
CE cs_DECDLDA= {{"Down Line Load Allocation",ENTRY_CS}, "DECDLDA", 1, {1}, cs_fn_DECDLDA};
CE cs_DECSZS = {{"Select Zero Symbol", ENTRY_CS}, "DECSZS", 1, {1}, cs_fn_DECSZS};
CE cs_DECAC = {{"Assign Color", ENTRY_CS}, "DECAC", 1, {1}, cs_fn_DECAC};
CE cs_DECATC = {{"Alternate Text Color", ENTRY_CS}, "DECATC", 1, {1}, cs_fn_DECATC};
CE cs_DECPS = {{"Play Sound", ENTRY_CS}, "DECPS", 1, {1}, cs_fn_DECPS};
struct table_col CS_I12_7_DEC = {{
&cs_DECLTOD.head, &cs_DECTID.head, 0, 0,
0, &cs_DECRQKT.head, &cs_DECRPKT.head, &cs_DECRQKD.head,
&cs_DECSPMA.head, &cs_DECUS.head, &cs_DECDLDA.head, &cs_DECSZS.head,
&cs_DECAC.head, &cs_DECATC.head, &cs_DECPS.head, 0
}};
struct control_seq_final_table CS_I12 = {{ 0, 0, 0, &CS_I12_7_DEC }};
/*
* Intermediate Character 13, Final Character Cols 4 - 7
*/
/* No defined functions for Cols 4-6 */
/* Final Character Col 7 (DEC Private) */
CE cs_DECARR = {{"Select Auto Repeat Rate", ENTRY_CS}, "DECARR", 1, {1}, cs_fn_DECARR};
CE cs_DECCRTST= {{"CRT Saver Timing", ENTRY_CS}, "DECCRTST", 1, {1}, cs_fn_DECCRTST};
CE cs_DECSEST = {{"Energy Saver Timing", ENTRY_CS}, "DECSEST", 1, {1}, cs_fn_DECSEST};
struct table_col CS_I13_7_DEC = {{
&cs_DECARR.head, &cs_DECCRTST.head, &cs_DECSEST.head, 0,
0, 0, 0, 0,
0, 0, 0, 0,
0, 0, 0, 0
}};
struct control_seq_final_table CS_I13 = {{ 0, 0, 0, &CS_I13_7_DEC }};
/*
* No Intermediate Character 14-15 functions
*/
/*
* Full Control Sequence Table
*/
struct control_seq_table CS_Table = {
&CS_NoI,
{ &CS_I0, &CS_I1, &CS_I2, 0,
&CS_I4, 0, &CS_I6, &CS_I7,
0, &CS_I9, &CS_I10, &CS_I11,
&CS_I12, &CS_I13, 0, 0 }
};

213
ansi_cs_table_defs.h Normal file
View File

@ -0,0 +1,213 @@
#ifndef ANSI_CSI_TABLE_DEFS_H
#define ANSI_CSI_TABLE_DEFS_H
#include "ansi_table.h"
#define MAX_PARAMS 4
typedef struct cs_entry CE;
typedef void (*cs_function)(void *ctx, int paramc, unsigned int *paramv);
struct cs_entry {
Entry head;
const char *mnemonic;
int param_count;
int param_defaults[MAX_PARAMS];
cs_function function;
};
void cs_fn_ICH(void *ctx, int paramc, unsigned int *paramv); // Insert Character
void cs_fn_CUU(void *ctx, int paramc, unsigned int *paramv); // Cursor Up
void cs_fn_CUD_VPR(void *ctx, int paramc, unsigned int *paramv); // Cursor Down / Vertical Position Relative
void cs_fn_CUF_HPR(void *ctx, int paramc, unsigned int *paramv); // Cursor Forward / Horizontal Position Relative
void cs_fn_CUB(void *ctx, int paramc, unsigned int *paramv); // Cursor Back
void cs_fn_CNL(void *ctx, int paramc, unsigned int *paramv); // Cursor Next Line
void cs_fn_CPL(void *ctx, int paramc, unsigned int *paramv); // Cursor Previous Line
void cs_fn_CHA(void *ctx, int paramc, unsigned int *paramv); // Cursor Horizontal Absolute
void cs_fn_CUP_HVP(void *ctx, int paramc, unsigned int *paramv); // Cursor Position / Horizontal & Vertical Position
void cs_fn_CHT(void *ctx, int paramc, unsigned int *paramv); // Cursor Horizontal Forward Tab
void cs_fn_ED(void *ctx, int paramc, unsigned int *paramv); // Erase in Display
void cs_fn_EL(void *ctx, int paramc, unsigned int *paramv); // Erase in Line
void cs_fn_IL(void *ctx, int paramc, unsigned int *paramv); // Insert Line
void cs_fn_DL(void *ctx, int paramc, unsigned int *paramv); // Delete Line
void cs_fn_EF(void *ctx, int paramc, unsigned int *paramv); // Erase in Field
void cs_fn_EA(void *ctx, int paramc, unsigned int *paramv); // Erase in Area
void cs_fn_DCH(void *ctx, int paramc, unsigned int *paramv); // Delete Character
void cs_fn_SEE(void *ctx, int paramc, unsigned int *paramv); // Select Editing Extent
void cs_fn_CPR(void *ctx, int paramc, unsigned int *paramv); // Cursor Position Report
void cs_fn_SU(void *ctx, int paramc, unsigned int *paramv); // Scroll Up (DEC Pan Down)
void cs_fn_SD(void *ctx, int paramc, unsigned int *paramv); // Scroll Down (DEC Pan Up)
void cs_fn_NP(void *ctx, int paramc, unsigned int *paramv); // Next Page
void cs_fn_PP(void *ctx, int paramc, unsigned int *paramv); // Previous Page
void cs_fn_CTC(void *ctx, int paramc, unsigned int *paramv); // Cursor Tabulation Control
void cs_fn_ECH(void *ctx, int paramc, unsigned int *paramv); // Erase Character
void cs_fn_CVT(void *ctx, int paramc, unsigned int *paramv); // Cursor Vertical (Line) Tabulation
void cs_fn_CBT(void *ctx, int paramc, unsigned int *paramv); // Cursor Backward Tabulation
void cs_fn_SRS(void *ctx, int paramc, unsigned int *paramv); // Start Reversed String
void cs_fn_PTX(void *ctx, int paramc, unsigned int *paramv); // Parallel Texts
void cs_fn_SDS(void *ctx, int paramc, unsigned int *paramv); // Start Directed String
void cs_fn_SIMD(void *ctx, int paramc, unsigned int *paramv); // Select Implicit Movement Direction
void cs_fn_HPA(void *ctx, int paramc, unsigned int *paramv); // Horizontal Position Absolute
void cs_fn_REP(void *ctx, int paramc, unsigned int *paramv); // Repeat
void cs_fn_DA(void *ctx, int paramc, unsigned int *paramv); // Device Attributes
void cs_fn_VPA(void *ctx, int paramc, unsigned int *paramv); // Vertical Position Absolute
void cs_fn_TBC(void *ctx, int paramc, unsigned int *paramv); // Tabulation Clear
void cs_fn_SM(void *ctx, int paramc, unsigned int *paramv); // Set Mode
void cs_fn_MC(void *ctx, int paramc, unsigned int *paramv); // Media Copy
void cs_fn_HPB(void *ctx, int paramc, unsigned int *paramv); // Horizontal (Character) Position Backward
void cs_fn_VPB(void *ctx, int paramc, unsigned int *paramv); // Vertical (Line) Position Backward
void cs_fn_RM(void *ctx, int paramc, unsigned int *paramv); // Reset Mode
void cs_fn_SGR(void *ctx, int paramc, unsigned int *paramv); // Set Graphic Rendition
void cs_fn_DSR(void *ctx, int paramc, unsigned int *paramv); // Device Status Report
void cs_fn_DAQ(void *ctx, int paramc, unsigned int *paramv); // Define Area Qualification
void cs_fn_SL(void *ctx, int paramc, unsigned int *paramv); // Scroll Left
void cs_fn_SR(void *ctx, int paramc, unsigned int *paramv); // Scroll Right
void cs_fn_GSM(void *ctx, int paramc, unsigned int *paramv); // Graphic Size Modification
void cs_fn_GSS(void *ctx, int paramc, unsigned int *paramv); // Graphic Size Selection
void cs_fn_FNT(void *ctx, int paramc, unsigned int *paramv); // Font Selection
void cs_fn_TSS(void *ctx, int paramc, unsigned int *paramv); // Thin Space Specification
void cs_fn_JFY(void *ctx, int paramc, unsigned int *paramv); // Justify
void cs_fn_SPI(void *ctx, int paramc, unsigned int *paramv); // Spacing Increment
void cs_fn_QUAD(void *ctx, int paramc, unsigned int *paramv); // Quad
void cs_fn_SSU(void *ctx, int paramc, unsigned int *paramv); // Select Size Unit
void cs_fn_PFS(void *ctx, int paramc, unsigned int *paramv); // Page Format Selection
void cs_fn_SHS(void *ctx, int paramc, unsigned int *paramv); // Select Horizontal Spacing
void cs_fn_SVS(void *ctx, int paramc, unsigned int *paramv); // Select Vertical Spacing
void cs_fn_IGS(void *ctx, int paramc, unsigned int *paramv); // Identify Graphics Subrepertoire
void cs_fn_HTSA(void *ctx, int paramc, unsigned int *paramv); // Horizontal Tabulation Set Absolute
void cs_fn_IDCS(void *ctx, int paramc, unsigned int *paramv); // Identify Device Control String
void cs_fn_PPA(void *ctx, int paramc, unsigned int *paramv); // Page Position Absolute
void cs_fn_PPR(void *ctx, int paramc, unsigned int *paramv); // Page Position Relative
void cs_fn_PPB(void *ctx, int paramc, unsigned int *paramv); // Page Position Backward
void cs_fn_SPD(void *ctx, int paramc, unsigned int *paramv); // Select Presentation Directions
void cs_fn_DTA(void *ctx, int paramc, unsigned int *paramv); // Dimension Text Area
void cs_fn_SLH(void *ctx, int paramc, unsigned int *paramv); // Set Line Home
void cs_fn_SLL(void *ctx, int paramc, unsigned int *paramv); // Set Line Limit
void cs_fn_FNK(void *ctx, int paramc, unsigned int *paramv); // Function Key
void cs_fn_SPQR(void *ctx, int paramc, unsigned int *paramv); // Select Print Quality & Rapidity
void cs_fn_SEF(void *ctx, int paramc, unsigned int *paramv); // Sheet Eject & Feed
void cs_fn_PEC(void *ctx, int paramc, unsigned int *paramv); // Presentation Expand or Contract
void cs_fn_SSW(void *ctx, int paramc, unsigned int *paramv); // Set Space Width
void cs_fn_SACS(void *ctx, int paramc, unsigned int *paramv); // Set Additional Character Separation
void cs_fn_SAPV(void *ctx, int paramc, unsigned int *paramv); // Select Alternative Presentation Variants
void cs_fn_STAB(void *ctx, int paramc, unsigned int *paramv); // Selective Tabulation
void cs_fn_GCC(void *ctx, int paramc, unsigned int *paramv); // Graphic Character Combination
void cs_fn_TATE(void *ctx, int paramc, unsigned int *paramv); // Tabulation Aligned Trailing Edge
void cs_fn_TALE(void *ctx, int paramc, unsigned int *paramv); // Tabulation Aligned Leading Edge
void cs_fn_TAC(void *ctx, int paramc, unsigned int *paramv); // Tabulation Aligned Centered
void cs_fn_TCC(void *ctx, int paramc, unsigned int *paramv); // Tabulation Centered on Character
void cs_fn_TSR(void *ctx, int paramc, unsigned int *paramv); // Tabulation Stop Remove
void cs_fn_SCO(void *ctx, int paramc, unsigned int *paramv); // Set Character Orientation
void cs_fn_SRCS(void *ctx, int paramc, unsigned int *paramv); // Set Reduced Character Separation
void cs_fn_SCS(void *ctx, int paramc, unsigned int *paramv); // Set Character Spacing
void cs_fn_SLS(void *ctx, int paramc, unsigned int *paramv); // Set Line Spacing
void cs_fn_SPH(void *ctx, int paramc, unsigned int *paramv); // Set Page Home
void cs_fn_SPL(void *ctx, int paramc, unsigned int *paramv); // Set Page Limit
void cs_fn_SCP(void *ctx, int paramc, unsigned int *paramv); // Select Character Path
void cs_fn_DECSSL(void *ctx, int paramc, unsigned int *paramv); // Select Set-Up Language
void cs_fn_DECLL(void *ctx, int paramc, unsigned int *paramv); // Load LEDs
void cs_fn_DECSTBM(void *ctx, int paramc, unsigned int *paramv); // Set Top & Bottom Margins
void cs_fn_DECSLRM(void *ctx, int paramc, unsigned int *paramv); // Set Left & Right Margins
void cs_fn_DECSLPP(void *ctx, int paramc, unsigned int *paramv); // Set Lines per Physical Page
void cs_fn_DECREQTPARM(void *ctx, int paramc, unsigned int *paramv); // Request Terminal Parameters
void cs_fn_DECTST(void *ctx, int paramc, unsigned int *paramv); // Invoke Confidence Test
void cs_fn_DECTTC(void *ctx, int paramc, unsigned int *paramv); // Select Transmit Termination Character
void cs_fn_DECPRO(void *ctx, int paramc, unsigned int *paramv); // Set Protected Field Attributes
void cs_fn_DECFNK(void *ctx, int paramc, unsigned int *paramv); // Function Key
void cs_fn_DECSSCLS(void *ctx, int paramc, unsigned int *paramv); // Set Scroll Speed
void cs_fn_DECSCUSR(void *ctx, int paramc, unsigned int *paramv); // Set Cursor Style
void cs_fn_DECSKCV(void *ctx, int paramc, unsigned int *paramv); // Set Keyclick Volume
void cs_fn_DECSWBV(void *ctx, int paramc, unsigned int *paramv); // Set Warning Bell Volume
void cs_fn_DECSMBV(void *ctx, int paramc, unsigned int *paramv); // Set Margin Bell Volume
void cs_fn_DECSLCK(void *ctx, int paramc, unsigned int *paramv); // Set Lock Key Style
void cs_fn_DECKBD(void *ctx, int paramc, unsigned int *paramv); // Keyboard Language Selection
void cs_fn_DECTME(void *ctx, int paramc, unsigned int *paramv); // Terminal Mode Emulation
void cs_fn_DECSTR(void *ctx, int paramc, unsigned int *paramv); // Soft Terminal Reset
void cs_fn_DECSCL(void *ctx, int paramc, unsigned int *paramv); // Set Conformance Level
void cs_fn_DECSCA(void *ctx, int paramc, unsigned int *paramv); // Select Character Attributes
void cs_fn_DECSRFR(void *ctx, int paramc, unsigned int *paramv); // Select Refresh Rate
void cs_fn_DECSTRL(void *ctx, int paramc, unsigned int *paramv); // Set Transmit Rate Limit
void cs_fn_DECRQDE(void *ctx, int paramc, unsigned int *paramv); // Request Device Extent
void cs_fn_DECRPDE(void *ctx, int paramc, unsigned int *paramv); // Report Device Extent
void cs_fn_DECRQM(void *ctx, int paramc, unsigned int *paramv); // Request Mode Settings
void cs_fn_DECSDDT(void *ctx, int paramc, unsigned int *paramv); // Select Disconnect Delay Time
void cs_fn_DECCARA(void *ctx, int paramc, unsigned int *paramv); // Change Attributes in Rectangular Area
void cs_fn_DECSPRTT(void *ctx, int paramc, unsigned int *paramv); // Select Printer Type
void cs_fn_DECRARA(void *ctx, int paramc, unsigned int *paramv); // Reverse Attributes in Rectangular Area
void cs_fn_DECRQTSR(void *ctx, int paramc, unsigned int *paramv); // Request Terminal State Report
void cs_fn_DECCRA(void *ctx, int paramc, unsigned int *paramv); // Copy Rectangular Area
void cs_fn_DECRQPSR(void *ctx, int paramc, unsigned int *paramv); // Request Presentation State Report
void cs_fn_DECFRA(void *ctx, int paramc, unsigned int *paramv); // Fill Rectangular Area
void cs_fn_DECRPM(void *ctx, int paramc, unsigned int *paramv); // Report Mode Settings
void cs_fn_DECERA(void *ctx, int paramc, unsigned int *paramv); // Erase Rectangular Area
void cs_fn_DECSERA(void *ctx, int paramc, unsigned int *paramv); // Selective Erase Rectangular Area
void cs_fn_DECSCPP(void *ctx, int paramc, unsigned int *paramv); // Set Columns Per Page
void cs_fn_DECSASD(void *ctx, int paramc, unsigned int *paramv); // Select Active Status Display
void cs_fn_DECSSDT(void *ctx, int paramc, unsigned int *paramv); // Select Status Display Type
void cs_fn_DECRQUPSS(void *ctx, int paramc, unsigned int *paramv); // Request User-Preferred Supplemental Set
void cs_fn_DECLRP(void *ctx, int paramc, unsigned int *paramv); // Locator Report
void cs_fn_DECES(void *ctx, int paramc, unsigned int *paramv); // Enable Session
void cs_fn_DECTLTC(void *ctx, int paramc, unsigned int *paramv); // Transmit Line Termination Characters
void cs_fn_DECEFR(void *ctx, int paramc, unsigned int *paramv); // Enable Filter Rectangle
void cs_fn_DECELR(void *ctx, int paramc, unsigned int *paramv); // Enable Locator Reports
void cs_fn_DECSLE(void *ctx, int paramc, unsigned int *paramv); // Select Locator Events
void cs_fn_DECRQLP(void *ctx, int paramc, unsigned int *paramv); // Request Locator Position
void cs_fn_DECIC(void *ctx, int paramc, unsigned int *paramv); // Insert Column
void cs_fn_DECDC(void *ctx, int paramc, unsigned int *paramv); // Delete Column
void cs_fn_DECSPDT(void *ctx, int paramc, unsigned int *paramv); // Select Digital Printed Data Type
void cs_fn_DECSTGLT(void *ctx, int paramc, unsigned int *paramv); // Select Text/Graphics Look-Up Table
void cs_fn_DECSPPCS(void *ctx, int paramc, unsigned int *paramv); // Select ProPrinter Character Set
void cs_fn_DECSRC(void *ctx, int paramc, unsigned int *paramv); // Secure Reset Confirmation
void cs_fn_DECSCS(void *ctx, int paramc, unsigned int *paramv); // Select Communication Speed
void cs_fn_DECSFC(void *ctx, int paramc, unsigned int *paramv); // Select Flow Control
void cs_fn_DECSCP(void *ctx, int paramc, unsigned int *paramv); // Select Communication Port
void cs_fn_DECSACE(void *ctx, int paramc, unsigned int *paramv); // Select Attribute Change Extent
void cs_fn_DECRQCRA(void *ctx, int paramc, unsigned int *paramv); // Request Checksum of Rectangular Area
void cs_fn_DECINVM(void *ctx, int paramc, unsigned int *paramv); // Invoke Macro
void cs_fn_DECMSR(void *ctx, int paramc, unsigned int *paramv); // Macro Space Report
void cs_fn_DECSNLS(void *ctx, int paramc, unsigned int *paramv); // Select Number of Lines per Screen
void cs_fn_DECLFKC(void *ctx, int paramc, unsigned int *paramv); // Local Function Key Control
void cs_fn_DECSR(void *ctx, int paramc, unsigned int *paramv); // Secure Reset
void cs_fn_DECELF(void *ctx, int paramc, unsigned int *paramv); // Enable Local Functions
void cs_fn_DECSMKR(void *ctx, int paramc, unsigned int *paramv); // Select Modifier Key Reporting
void cs_fn_DECSPP(void *ctx, int paramc, unsigned int *paramv); // Select Port Parameter
void cs_fn_DECRQPKFM(void *ctx, int paramc, unsigned int *paramv); // Program Key Free Memory Inquiry
void cs_fn_DECPKFMR(void *ctx, int paramc, unsigned int *paramv); // Program Key Free Memory Report
void cs_fn_DECPKA(void *ctx, int paramc, unsigned int *paramv); // Program Key Action
void cs_fn_DECLTOD(void *ctx, int paramc, unsigned int *paramv); // Load Time of Day
void cs_fn_DECTID(void *ctx, int paramc, unsigned int *paramv); // Select Terminal ID
void cs_fn_DECRQKT(void *ctx, int paramc, unsigned int *paramv); // Key Type Inquiry
void cs_fn_DECRPKT(void *ctx, int paramc, unsigned int *paramv); // Report Key Type
void cs_fn_DECRQKD(void *ctx, int paramc, unsigned int *paramv); // Request Key Definition
void cs_fn_DECSPMA(void *ctx, int paramc, unsigned int *paramv); // Session Page Memory Allocation
void cs_fn_DECUS(void *ctx, int paramc, unsigned int *paramv); // Update Session
void cs_fn_DECDLDA(void *ctx, int paramc, unsigned int *paramv); // Down Line Load Allocation
void cs_fn_DECSZS(void *ctx, int paramc, unsigned int *paramv); // Select Zero Symbol
void cs_fn_DECAC(void *ctx, int paramc, unsigned int *paramv); // Assign Color
void cs_fn_DECATC(void *ctx, int paramc, unsigned int *paramv); // Alternate Text Color
void cs_fn_DECPS(void *ctx, int paramc, unsigned int *paramv); // Play Sound
void cs_fn_DECARR(void *ctx, int paramc, unsigned int *paramv); // Select Auto Repeat Rate
void cs_fn_DECCRTST(void *ctx, int paramc, unsigned int *paramv); // CRT Saver Timing
void cs_fn_DECSEST(void *ctx, int paramc, unsigned int *paramv); // Energy Saver Timing
extern struct control_seq_table CS_Table;
#endif

122
ansi_decls.h Normal file
View File

@ -0,0 +1,122 @@
#ifndef ANSI_DECLS_H
#define ANSI_DECLS_H
#include "sm.h"
/* Actions */
static void do_ignore(struct sm_context *ctx, sm_event_id code);
static void do_print(struct sm_context *ctx, sm_event_id code);
static void do_execute(struct sm_context *ctx, sm_event_id code);
static void do_clear(struct sm_context *ctx, sm_event_id code);
static void do_collect(struct sm_context *ctx, sm_event_id code);
static void do_param(struct sm_context *ctx, sm_event_id code);
static void do_esc_dispatch(struct sm_context *ctx, sm_event_id code);
static void do_csi_dispatch(struct sm_context *ctx, sm_event_id code);
static void do_hook(struct sm_context *ctx, sm_event_id code);
static void do_put(struct sm_context *ctx, sm_event_id code);
static void do_unhook(struct sm_context *ctx, sm_event_id code);
static void do_osc_start(struct sm_context *ctx, sm_event_id code);
static void do_osc_put(struct sm_context *ctx, sm_event_id code);
static void do_osc_end(struct sm_context *ctx, sm_event_id code);
/* Predicates */
static int global_execute_pred(sm_event_id code);
static int global_to_escape_pred(sm_event_id code);
static int global_to_string_pred(sm_event_id code);
static int global_to_dcs_pred(sm_event_id code);
static int global_to_osc_pred(sm_event_id code);
static int ground_execute_pred(sm_event_id code);
static int ground_print_pred(sm_event_id code);
static int sos_pm_apc_string_ignore_pred(sm_event_id code);
static int sos_pm_apc_string_to_ground_pred(sm_event_id code);
static int escape_execute_pred(sm_event_id code);
static int escape_ignore_pred(sm_event_id code);
static int escape_to_ground_pred(sm_event_id code);
static int escape_to_escape_intermediate_pred(sm_event_id code);
static int escape_to_string_pred(sm_event_id code);
static int escape_to_dcs_entry_pred(sm_event_id code);
static int escape_to_osc_string_pred(sm_event_id code);
static int escape_to_csi_entry_pred(sm_event_id code);
static int escape_intermediate_execute_pred(sm_event_id code);
static int escape_intermediate_collect_pred(sm_event_id code);
static int escape_intermediate_ignore_pred(sm_event_id code);
static int escape_intermediate_to_ground_pred(sm_event_id code);
static int csi_entry_execute_pred(sm_event_id code);
static int csi_entry_ignore_pred(sm_event_id code);
static int csi_entry_to_ground_pred(sm_event_id code);
static int csi_entry_to_param_pred(sm_event_id code);
static int csi_entry_to_param_collect_pred(sm_event_id code);
static int csi_entry_to_intermediate_pred(sm_event_id code);
static int csi_entry_to_ignore_pred(sm_event_id code);
static int csi_param_execute_pred(sm_event_id code);
static int csi_param_param_pred(sm_event_id code);
static int csi_param_ignore_pred(sm_event_id code);
static int csi_param_to_ground_pred(sm_event_id code);
static int csi_param_to_intermediate_pred(sm_event_id code);
static int csi_param_to_ignore_pred(sm_event_id code);
static int csi_intermediate_execute_pred(sm_event_id code);
static int csi_intermediate_collect_pred(sm_event_id code);
static int csi_intermediate_ignore_pred(sm_event_id code);
static int csi_intermediate_to_ground_pred(sm_event_id code);
static int csi_intermediate_to_ignore_pred(sm_event_id code);
static int csi_ignore_execute_pred(sm_event_id code);
static int csi_ignore_ignore_pred(sm_event_id code);
static int csi_ignore_to_ground_pred(sm_event_id code);
static int dcs_entry_ignore_pred(sm_event_id code);
static int dcs_entry_to_intermediate_pred(sm_event_id code);
static int dcs_entry_to_ignore_pred(sm_event_id code);
static int dcs_entry_to_param_pred(sm_event_id code);
static int dcs_entry_to_param_collect_pred(sm_event_id code);
static int dcs_entry_to_passthrough_pred(sm_event_id code);
static int dcs_param_ignore_pred(sm_event_id code);
static int dcs_param_param_pred(sm_event_id code);
static int dcs_param_to_ignore_pred(sm_event_id code);
static int dcs_param_to_intermediate_pred(sm_event_id code);
static int dcs_param_to_passthrough_pred(sm_event_id code);
static int dcs_intermediate_ignore_pred(sm_event_id code);
static int dcs_intermediate_collect_pred(sm_event_id code);
static int dcs_intermediate_to_passthrough_pred(sm_event_id code);
static int dcs_intermediate_to_ignore_pred(sm_event_id code);
static int dcs_passthrough_ignore_pred(sm_event_id code);
static int dcs_passthrough_put_pred(sm_event_id code);
static int dcs_passthrough_to_ground_pred(sm_event_id code);
static int dcs_ignore_ignore_pred(sm_event_id code);
static int dcs_ignore_to_ground_pred(sm_event_id code);
static int osc_string_ignore_pred(sm_event_id code);
static int osc_string_put_pred(sm_event_id code);
static int osc_string_to_ground_pred(sm_event_id code);
/* States */
static struct sm_state ground;
static struct sm_state escape;
static struct sm_state escape_intermediate;
static struct sm_state csi_entry;
static struct sm_state csi_param;
static struct sm_state csi_intermediate;
static struct sm_state csi_ignore;
static struct sm_state dcs_entry;
static struct sm_state dcs_param;
static struct sm_state dcs_intermediate;
static struct sm_state dcs_passthrough;
static struct sm_state dcs_ignore;
static struct sm_state osc_string;
static struct sm_state sos_pm_apc_string;
#endif

81
ansi_table.c Normal file
View File

@ -0,0 +1,81 @@
#include <stddef.h>
#include "ansi_table.h"
Entry *ansi_table_lookup(Table *t, unsigned char code)
{
struct table_col **table;
struct table_col *column = NULL;
struct table_entry *entry = NULL;
unsigned int row, col, lr;
col = (code & 0xF0) >> 4;
row = code & 0xF;
lr = !!(col & 0x8);
col = col & 0x7;
if (lr == 0) {
if (col < 2) {
table = t->c0->cols;
} else {
col = col - 2;
table = t->gl->cols;
}
} else {
if (col < 2) {
table = t->c1->cols;
} else {
col = col - 2;
table = t->gr->cols;
}
}
if (table) {
column = table[col];
}
if (column) {
entry = column->rows[row];
}
return entry;
}
Entry* csi_table_lookup(CsTable *t, int ic, unsigned char *iv, unsigned char f)
{
struct table_col **table;
struct table_col *column = NULL;
struct table_entry *entry = NULL;
unsigned int row, col, code;
if (ic > 1) return NULL;
if (ic == 1) {
code = iv[0];
col = (code & 0xF0) >> 4;
row = code & 0xF;
/* I values must come from column 2 */
if (col != 0x2) return NULL;
table = t->with_i[row]->cols;
} else {
table = t->no_i->cols;
}
if (table) {
col = (f & 0xF0) >> 4;
/* F values must come from columns 4-7 */
if (col < 0x4 || col > 0x7) return NULL;
col = col - 0x4;
column = table[col];
}
if (column) {
row = f & 0xF;
entry = column->rows[row];
}
return entry;
}

56
ansi_table.h Normal file
View File

@ -0,0 +1,56 @@
#ifndef ANSI_TABLE_H
#define ANSI_TABLE_H
#define ANSI_ITEM_COUNT 16
#define ANSI_C_COLUMNS 2
#define ANSI_G_COLUMNS 6
#define ANSI_CSI_FINAL_COLUMNS 4
#define ANSI_INTERMEDIATES 1
typedef struct ansi_table Table;
typedef struct control_seq_table CsTable;
typedef struct table_entry Entry;
enum entry_kind {
ENTRY_GRAPHIC,
ENTRY_CONTROL,
ENTRY_CS
};
struct table_entry {
const char *name;
const enum entry_kind kind;
};
struct table_col {
struct table_entry *rows[ANSI_ITEM_COUNT];
};
struct control_table {
struct table_col *cols[ANSI_C_COLUMNS];
};
struct graphic_table {
struct table_col *cols[ANSI_G_COLUMNS];
};
struct control_seq_final_table {
struct table_col *cols[ANSI_CSI_FINAL_COLUMNS];
};
struct ansi_table {
struct control_table *c0;
struct graphic_table *gl;
struct control_table *c1;
struct graphic_table *gr;
};
struct control_seq_table {
struct control_seq_final_table *no_i;
struct control_seq_final_table *with_i[ANSI_ITEM_COUNT];
};
Entry* ansi_table_lookup(Table *t, unsigned char code);
Entry* csi_table_lookup(CsTable *t, int ic, unsigned char *iv, unsigned char f);
#endif

112
regis.org Normal file
View File

@ -0,0 +1,112 @@
* Screen Display
** Bitmap
Memory associated with graphic display. It is divided into bit-planes, which
determine the number of simultaneous colors available. For a terminal with /n/
bit-planes, /2^n/ colors or shades of gray may be used at once. For each /x,y/
position, one bit is drawn from each bit-plane at that position to form a binary
integer. This integer is the index of the /color register/ that will determine
the display color of the pixel at /x,y/ on the screen. The number of colors that
may be chosen for each color register may be larger than the number of color
registers.
For example, the VT340 has 4 bit-planes. This means that a 4-bit number indexes
the color registers, so there are 2^4 or 16 color registers. But each register
can be set to one of 4096 colors. The VT330, on the other hand, has 2 bit-planes
(4 grayscale registers) and a selection of 64 shades of gray available.
** Graphics Pages
The terminal may have more bitmap memory than is displayable on the screen at
once. In this case, each screen-size bitmap is called a page. The application
can select which page is being drawn on and which is being displayed.
** Color Register
The terminal can usually generate more distinct colors or gray shades than it
has memory available to distinguish on a per-pixel basis. The color registers
therefore select from all available colors the smaller pallete that is currently
usable. The bit-planes values at a pixel position select a color register, and
the register selects the actual color value.
Color terminals have two sets of registers, one for the color pallete and one
for the grayscale pallete.
* ReGIS
** Syntax
*** Commands are case-insensitive single characters, mostly letters
**** S: Screen
***** A: Addressing
***** H: Printing
***** M: Output Map (color registers)
***** I: Background Intensity
****** E: Screen Erase (selected background)
***** T: Time Delay
***** E: Screen Erase (current background)
***** W: Write
****** M: Pixel Vector Multiplier
***** C: Cursor Control/Selection
****** H: Graphics Output Cursor Selection
****** I: Graphics Input Cursor Selection
***** P: Display Graphics Page
**** W: Write
***** M: Pixel Vector Multiplier
***** P: Pattern Control/Selection
****** M: Pattern Multiplication
***** I: Foreground Intensity
***** F: Plane Select
***** V: Overlay Writing
***** R: Replace Writing
***** C: Complement Writing
***** E: Erase Writing
***** N: Negative Pattern Control
***** S: Shading on/off Control
**** P: Position
***** W: Write
****** M: Pixel Vector Multiplier
***** B: Begin Bounded Position Stack
**** V: Vector
**** C: Curve
**** T: Text
**** L: Load
**** @: Macrograph
**** R: Report
**** F: Polygon Fill
**** ;: Resynchronization

53
sm.c Normal file
View File

@ -0,0 +1,53 @@
#include <stdlib.h>
#include <assert.h>
#include "sm.h"
static int sm_try_transitions(struct sm_transition *table, struct sm_context *machine, sm_event_id event);
void sm_put_event(struct sm_context *machine, sm_event_id event)
{
struct sm_state *st;
assert(machine != NULL);
assert(machine->current_state != NULL);
st = machine->current_state;
if (!sm_try_transitions(machine->global_transitions, machine, event)) {
sm_try_transitions(st->transitions, machine, event);
}
}
static int sm_try_transitions(struct sm_transition *table, struct sm_context *machine, sm_event_id event)
{
struct sm_state *st = machine->current_state;
struct sm_transition *tr;
int matched = 0;
for (tr = table; tr->event_matcher != NULL; tr++) {
if (tr->event_matcher(event)) {
if (tr->transition_target && st->exit_action) {
st->exit_action(machine, event);
}
if (tr->transition_action) {
tr->transition_action(machine, event);
}
if (tr->transition_target) {
st = tr->transition_target;
if (tr->transition_target->entry_action) {
st->entry_action(machine, event);
}
machine->current_state = st;
}
matched = 1;
break;
}
}
return matched;
}

33
sm.h Normal file
View File

@ -0,0 +1,33 @@
#ifndef TERM_SM_H
#define TERM_SM_H
typedef int sm_event_id;
struct sm_state;
struct sm_transition;
struct sm_context;
typedef void (*sm_action)(struct sm_context*, sm_event_id);
typedef int (*sm_predicate)(sm_event_id);
struct sm_transition {
sm_predicate event_matcher;
sm_action transition_action;
struct sm_state *transition_target;
};
struct sm_state {
const char *name;
sm_action entry_action;
sm_action exit_action;
struct sm_transition *transitions;
};
struct sm_context {
struct sm_state *current_state;
struct sm_transition *global_transitions;
};
void sm_put_event(struct sm_context *machine, sm_event_id event);
#endif

42
terminal.h Normal file
View File

@ -0,0 +1,42 @@
#ifndef TERMINAL_H
#define TERMINAL_H
typedef struct terminal Terminal;
enum {
DIR_UP,
DIR_DOWN,
DIR_FORWARD,
DIR_BACK
};
Terminal *Terminal_new(void);
void Terminal_init(Terminal *t);
void Terminal_clearScreen(Terminal *t);
void Terminal_clearTabs(Terminal *t);
void Terminal_defaultTabs(Terminal *t);
void Terminal_setTab(Terminal *t);
void Terminal_clearTab(Terminal *t);
void Terminal_bufferDump(Terminal *t);
void Terminal_setAutoWrap(Terminal *t, int mode);
void Terminal_scroll(Terminal *t, int lines);
void Terminal_carriageReturn(Terminal *t);
void Terminal_lineFeed(Terminal *t);
void Terminal_newLine(Terminal *t);
void Terminal_backspace(Terminal *t);
void Terminal_horizontalTab(Terminal *t, int count);
void Terminal_backTab(Terminal *t, int count);
void Terminal_cursorRel(Terminal *t, int direction, int count, int scroll);
void Terminal_cursorAbsH(Terminal *t, int column);
void Terminal_cursorAbsV(Terminal *t, int line);
void Terminal_cursorAbs(Terminal *t, int column, int line);
void Terminal_insertGraphic(Terminal *t, unsigned char code, int count);
void Terminal_putGraphic(Terminal *t, unsigned char code);
#endif

238
test.c Normal file
View File

@ -0,0 +1,238 @@
#include <stdlib.h>
#include <stdio.h>
#include "ansi.h"
#include "ansi_table.h"
#include "ansi_cs_table_defs.h"
#include "terminal.h"
const char test1[] = {ESC, '[', '?', '2', '3', ';', '2', '#', 'R'};
const char test2[] = "Hello, world!\r\n";
const char test3[] = {ESC, 'a', ESC, 'E', NEL};
const char test4[] = {
'0', '\r', '\n', '1', '\r', '\n', '2', '\r', '\n', '3', '\r', '\n', '4', '\r', '\n', '5', '\r', '\n',
'6', '\r', '\n', '7', '\r', '\n', '8', '\r', '\n', '9', '\r', '\n', '0', '\r', '\n', '1', '\r', '\n',
'2', '\r', '\n', '3', '\r', '\n', '4', '\r', '\n', '5', '\r', '\n', '6', '\r', '\n', '7', '\r', '\n',
'8', '\r', '\n', '9', '\r', '\n', '0', '\r', '\n', '1', '\r', '\n', '2', '\r', '\n', '3', '\r', '\n',
'4', '\r', '\n', '5', '\r', '\n', '6', '\r', '\n', '7', '\r', '\n', '8', '\r', '\n', '9', '\r', '\n',
'0', '\r', '\n', '1', '\r', '\n', '2', '\r', '\n', '3', '\r', '\n', '4', '\r', '\n', '5', '\r', '\n'
};
const char test5[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
const char test6[] = "1\t2\t3\t4\t5\t6\t7\t8\t9\t10\t11";
const char test7[] = {
' ', '|', ' ', '|', ' ', CR, LF,
'-', '-', '-', '-', '-', CR, LF,
' ', '|', ' ', '|', ' ', CR, LF,
'-', '-', '-', '-', '-', CR, LF,
' ', '|', ' ', '|', ' ', CR, LF,
ESC, '[', 'A', ESC, '[', '4', 'A',
'X',
ESC, '[', '0', 'C',
'O',
ESC, '[', 'D', ESC, '[', '1', 'B', ESC, '[', 'B',
'X',
ESC, '[', '5', ';', '5', 'H',
'O',
ESC, '[', '5', 'f',
'X'
};
Terminal *term;
#define RUNTEST(_name) do { \
unsigned int i; \
printf("\n*** Running test %s\n", #_name); \
for (i = 0; i < sizeof _name; i++) { \
ansi_context_put(machine, _name[i]); \
} \
} while (0)
void print_function_id(struct function_id id)
{
int i, len, priv;
len = id.i_count_priv & 0x0F;
priv = !!(id.i_count_priv & 0x80);
if (priv) {
printf("P ");
}
for (i = 0; i < len; i++) {
printf("I%d=0x%02x ", i, id.intermediates[i]);
}
printf("F=0x%02x", id.final);
}
void graphic_fn(unsigned char ch)
{
Terminal_putGraphic(term, ch);
}
void control_fn(unsigned char ch)
{
switch (ch) {
case NUL:
break;
case BEL:
break;
case BS:
Terminal_backspace(term);
break;
case HT:
Terminal_horizontalTab(term, 1);
break;
case LF:
case VT:
case FF:
Terminal_lineFeed(term);
break;
case CR:
Terminal_carriageReturn(term);
break;
case IND: // Index
Terminal_cursorRel(term, DIR_DOWN, 1, 1);
break;
case NEL: // Next Line
Terminal_newLine(term);
break;
case HTS: // Horizontal Tab Set
Terminal_setTab(term);
break;
case RI: // Reverse Index
Terminal_cursorRel(term, DIR_UP, 1, 1);
break;
case SS2: // Single Shift 2
break;
case SS3: // Single Shift 3
break;
default:
printf("\\x%02x", ch);
break;
}
}
void esc_fn(struct function_id esc_id) {
printf("\nESC: ");
print_function_id(esc_id);
printf("\n");
}
void normalize_params(int in_c, unsigned int *in_v, int out_c, unsigned int *out_v)
{
int i;
for (i = 0; i < in_c && i < out_c; i++) {
if (in_v[i] != 0) {
out_v[i] = in_v[i];
}
}
}
void csi_fn(struct function_id csi_id, int paramc, unsigned int *paramv)
{
int i, icount;
unsigned int params[4];
Entry *e;
CE *ce;
icount = csi_id.i_count_priv & 0x7;
e = csi_table_lookup(&CS_Table, csi_id.i_count_priv, csi_id.intermediates, csi_id.final);
ce = (CE *)e;
if (ce) {
for (i = 0; i < ce->param_count; i++) {
params[i] = ce->param_defaults[i];
}
normalize_params(paramc, paramv, ce->param_count, params);
ce->function((void *)term, paramc, params);
}
printf("\nCSI: ");
print_function_id(csi_id);
for (i = 0; i < paramc; i++) {
printf(" P%d=%d", i, paramv[i]);
}
printf("\n");
}
void str_put(void *user_ctx, unsigned char ch)
{
(void)user_ctx;
printf("<%c> ", ch);
}
void str_fn(struct str_hook *hook, struct function_id id, int c, unsigned int *v)
{
hook->user_ctx = NULL;
hook->handler_fn = str_put;
int i;
printf("\nSTR: ");
print_function_id(id);
for (i = 0; i < c; i++) {
printf(" P%d=%d", i, v[i]);
}
printf(": ");
}
void osc_fn(struct osc_hook *hook)
{
hook->user_ctx = NULL;
hook->handler_fn = str_put;
printf("\nOSC: ");
}
int main(void) {
struct ansi_actions actions = {
graphic_fn,
control_fn,
esc_fn,
csi_fn,
str_fn,
osc_fn
};
struct ansi_context *machine = new_ansi_context(&actions);
term = Terminal_new();
RUNTEST(test1);
printf("---Terminal Buffer--------------\n");
Terminal_bufferDump(term);
printf("--------------------------------\n");
Terminal_init(term);
RUNTEST(test2);
printf("---Terminal Buffer--------------\n");
Terminal_bufferDump(term);
printf("--------------------------------\n");
Terminal_init(term);
RUNTEST(test3);
printf("---Terminal Buffer--------------\n");
Terminal_bufferDump(term);
printf("--------------------------------\n");
Terminal_init(term);
RUNTEST(test4);
printf("---Terminal Buffer--------------\n");
Terminal_bufferDump(term);
printf("--------------------------------\n");
Terminal_init(term);
RUNTEST(test5);
printf("---Terminal Buffer--------------\n");
Terminal_bufferDump(term);
printf("--------------------------------\n");
Terminal_init(term);
Terminal_setAutoWrap(term, 1);
RUNTEST(test5);
printf("---Terminal Buffer--------------\n");
Terminal_bufferDump(term);
printf("--------------------------------\n");
Terminal_init(term);
RUNTEST(test6);
printf("---Terminal Buffer--------------\n");
Terminal_bufferDump(term);
printf("--------------------------------\n");
Terminal_init(term);
RUNTEST(test7);
printf("---Terminal Buffer--------------\n");
Terminal_bufferDump(term);
printf("--------------------------------\n");
Terminal_init(term);
return 0;
}

451
textmode_buffer.c Normal file
View File

@ -0,0 +1,451 @@
#include <string.h>
#include <stdio.h>
#include "terminal.h"
//#define BUF_COLUMNS (100)
//#define BUF_LINES (75)
#define BUF_COLUMNS (80)
#define BUF_LINES (24)
typedef unsigned char flag;
struct modes {
flag keyboard_action : 1; // KAM - Keyboard Action Mode
flag insert_replace : 1; // IRM - Insertion-Replacement Mode
flag linefeed_newline : 1; // LNM - Linefeed/Newline Mode
flag local_echo : 1; // SRM - Send/Receive Mode
flag cursor_key : 1; // DECCKM - Cursor Key Mode
flag column : 1; // DECCOLM - Column Mode (80/132)
flag scroll : 1; // DECSCLM - Smooth Scroll Mode
flag screen : 1; // DECSCNM - Screen Mode (normal/reverse)
flag origin : 1; // DECOM - Origin Mode
flag auto_wrap : 1; // DECAWM - Auto Wrap Mode
flag auto_repeat : 1; // DECARM - Auto Repeat Mode
flag cursor_enable : 1; // DECTCEM - Text Cursor Enable Mode
};
struct char_attribs { // SGR
flag underline : 1;
flag reverse : 1;
flag blink : 1;
flag bold : 1;
};
struct line_attribs { // DECSWL when neither is set
flag double_width : 1; // DECDWL - Can be set without DHL
flag double_height_t : 1; // DECDHL Top Half - DHL is always also DWL
flag double_height_b : 1; // DECDHL Bottom Half
};
struct position {
int col;
int line;
};
struct bounds {
int min;
int max;
};
struct cell {
struct char_attribs att;
unsigned char glyph;
};
struct line {
struct line_attribs att;
struct cell cells[BUF_COLUMNS];
};
struct page {
int col_count;
int line_count;
struct bounds scroll;
struct line lines[BUF_LINES];
};
struct terminal {
struct page pagebuf;
struct modes modes;
unsigned char tabstops[BUF_COLUMNS];
struct position cursor;
};
static const struct char_attribs blank_char_att = {
.underline = 0,
.reverse = 0,
.blink = 0,
.bold = 0
};
static const struct line_attribs blank_line_att = {
.double_width = 0,
.double_height_t = 0,
.double_height_b = 0
};
static Terminal singleton_terminal = {
.pagebuf = { BUF_COLUMNS, BUF_LINES, {0, BUF_LINES-1}, { {}, {} } },
.modes = {},
.tabstops = {},
{0, 0}
};
int bounded_move(int *pos, int amt, struct bounds b)
{
int orig_pos = *pos;
int actual_move = amt;
*pos += amt;
if (amt < 0) {
if (*pos < b.min) *pos = b.min;
} else {
if (*pos > b.max) *pos = b.max;
}
actual_move = *pos - orig_pos;
return actual_move;
}
void bounded_set(int *pos, int new_pos, struct bounds b)
{
if (new_pos < b.min)
*pos = b.min;
else if (new_pos > b.max)
*pos = b.max;
else
*pos = new_pos;
}
struct bounds Terminal_cursorHBounds(Terminal *term)
{
struct bounds b = { 0, 0 };
b.min = 0;
b.max = term->pagebuf.col_count - 1;
return b;
}
struct bounds Terminal_cursorVBounds(Terminal *term, int scroll_region)
{
struct bounds b = { 0, 0 };
if (scroll_region) {
b.min = term->pagebuf.scroll.min;
b.max = term->pagebuf.scroll.max;
} else {
b.min = 0;
b.max = term->pagebuf.line_count - 1;
}
return b;
}
Terminal *Terminal_new(void)
{
Terminal_init(&singleton_terminal);
return &singleton_terminal;
}
void Terminal_defaultModes(Terminal *t)
{
t->modes.auto_wrap = 0;
t->modes.insert_replace = 0;
t->modes.cursor_enable = 1;
}
void Terminal_clearScreen(Terminal *t)
{
int i, j;
struct cell *c;
struct line *l;
for (i = 0; i < t->pagebuf.line_count; i++) {
l = &t->pagebuf.lines[i];
l->att = blank_line_att;
for (j = 0; j < t->pagebuf.col_count; j++) {
c = &l->cells[j];
c->att = blank_char_att;
c->glyph = 0;
}
}
}
void Terminal_clearTabs(Terminal *t)
{
int i;
for (i = 0; i < t->pagebuf.col_count; i++) {
t->tabstops[i] = 0;
}
}
void Terminal_defaultTabs(Terminal *t)
{
int i;
for (i = 8; i < t->pagebuf.col_count; i += 8) {
t->tabstops[i] = 1;
}
}
void Terminal_setTab(Terminal *t)
{
t->tabstops[t->cursor.col] = 1;
}
void Terminal_clearTab(Terminal *t)
{
t->tabstops[t->cursor.col] = 0;
}
void Terminal_defaultScrollRegion(Terminal *t)
{
t->pagebuf.scroll.min = 0;
t->pagebuf.scroll.max = t->pagebuf.line_count - 1;
}
void Terminal_init(Terminal *t)
{
t->pagebuf.col_count = BUF_COLUMNS;
t->pagebuf.line_count = BUF_LINES;
Terminal_defaultModes(t);
Terminal_clearScreen(t);
Terminal_clearTabs(t);
Terminal_defaultTabs(t);
Terminal_defaultScrollRegion(t);
t->cursor.col = 0;
t->cursor.line = 0;
}
void Terminal_bufferDump(Terminal *t)
{
int i, j;
struct cell *c;
for (i = 0; i < t->pagebuf.line_count; i++) {
for (j = 0; j < t->pagebuf.col_count; j++) {
c = &t->pagebuf.lines[i].cells[j];
if (c->glyph) {
putchar(c->glyph);
} else {
putchar(' ');
}
}
putchar('\n');
}
}
void Terminal_setAutoWrap(Terminal *t, int mode)
{
t->modes.auto_wrap = mode;
}
void Terminal_scroll(Terminal *t, int lines)
{
struct line *scroll_top;
struct line *scroll_keep;
struct line *scroll_clear;
int direction, total_lines, keep_lines, clear_lines;
struct bounds b;
size_t scroll_size, clear_size;
if (lines < 0) {
lines = -lines;
direction = -1;
} else {
direction = 1;
}
b = Terminal_cursorVBounds(t, 1);
total_lines = b.max + 1 - b.min;
keep_lines = total_lines - lines;
if (keep_lines < 0) {
keep_lines = 0;
}
clear_lines = total_lines - keep_lines;
scroll_size = keep_lines * (sizeof (struct line));
clear_size = clear_lines * (sizeof (struct line));
if (direction > 0) {
scroll_top = &t->pagebuf.lines[b.min];
scroll_clear = &t->pagebuf.lines[b.min + keep_lines];
if (keep_lines) {
scroll_keep = &t->pagebuf.lines[b.min + lines];
memmove(scroll_top, scroll_keep, scroll_size);
}
} else {
scroll_top = &t->pagebuf.lines[b.min + clear_lines];
scroll_clear = &t->pagebuf.lines[b.min];
if (keep_lines) {
scroll_keep = &t->pagebuf.lines[b.min];
memmove(scroll_top, scroll_keep, scroll_size);
}
}
memset(scroll_clear, 0, clear_size);
}
void Terminal_cursorRel(Terminal *t, int direction, int count, int scroll)
{
int *axis;
struct bounds b;
int move, result;
int obey_margins = 1;
switch (direction) {
case DIR_UP:
axis = &t->cursor.line;
move = -count;
b = Terminal_cursorVBounds(t, obey_margins);
break;
case DIR_DOWN:
axis = &t->cursor.line;
move = count;
b = Terminal_cursorVBounds(t, obey_margins);
break;
case DIR_FORWARD:
axis = &t->cursor.col;
move = count;
b = Terminal_cursorHBounds(t);
break;
case DIR_BACK:
axis = &t->cursor.col;
move = -count;
b = Terminal_cursorHBounds(t);
break;
default:
return;
}
result = bounded_move(axis, move, b);
if (result != move && scroll) {
if (direction == DIR_UP || direction == DIR_DOWN) {
Terminal_scroll(t, move - result);
}
}
}
void Terminal_cursorAbsH(Terminal *t, int column)
{
bounded_set(&t->cursor.col, column, Terminal_cursorHBounds(t));
}
void Terminal_cursorAbsV(Terminal *t, int line)
{
int obey_margins = 0;
bounded_set(&t->cursor.line, line, Terminal_cursorVBounds(t, obey_margins));
}
void Terminal_cursorAbs(Terminal *t, int column, int line)
{
Terminal_cursorAbsH(t, column);
Terminal_cursorAbsV(t, line);
}
void Terminal_carriageReturn(Terminal *t)
{
Terminal_cursorAbsH(t, 0);
}
void Terminal_lineFeed(Terminal *t)
{
Terminal_cursorRel(t, DIR_DOWN, 1, 1);
}
void Terminal_newLine(Terminal *t)
{
Terminal_carriageReturn(t);
Terminal_lineFeed(t);
}
void Terminal_backspace(Terminal *t)
{
Terminal_cursorRel(t, DIR_BACK, 1, 0);
}
void Terminal_horizontalTab(Terminal *t, int count)
{
int i, target_col;
struct bounds b = Terminal_cursorHBounds(t);
target_col = -1;
for (i = t->cursor.col+1; i < b.max; i++) {
if (t->tabstops[i] == 1) {
if (count == 1) {
target_col = i;
break;
} else {
count--;
}
}
}
if (target_col == -1) {
t->cursor.col = b.max + 1;
} else {
Terminal_cursorAbsH(t, target_col);
}
}
void Terminal_backTab(Terminal *t, int count)
{
int i;
for (i = t->cursor.col-1; i >= 0; i--) {
if (t->tabstops[i] == 1) {
if (count == 1) {
t->cursor.col = i;
return;
} else {
count--;
}
}
}
t->cursor.col = 0;
}
void Terminal_insertGraphic(Terminal *t, unsigned char code, int count)
{
struct line *l;
int line, remain, from, to;
from = t->cursor.col;
line = t->pagebuf.col_count - from;
if (count > line) count = line;
remain = line - count;
if (remain) {
to = from + count;
l = &t->pagebuf.lines[t->cursor.line];
memmove(&l->cells[to], &l->cells[from], sizeof (struct cell) * remain);
}
while (count--) {
l->cells[from].att = blank_char_att;
l->cells[from++].glyph = code;
}
}
void Terminal_putGraphic(Terminal *t, unsigned char code)
{
int *col = &t->cursor.col;
int *line = &t->cursor.line;
/* Cursor pointing just past the end of line means we either need to wrap
or move back to the last position of the line */
if (*col == t->pagebuf.col_count) {
if (t->modes.auto_wrap == 1) {
Terminal_newLine(t);
} else {
*col -= 1;
}
}
t->pagebuf.lines[*line].cells[*col].glyph = code;
*col += 1;
}