Skip to content
Snippets Groups Projects
Commit edb6ed5d authored by rswindell's avatar rswindell
Browse files

Deuce didn't like the font and video/emu mode state information tacked onto

the DA response, so I added 2 new requests: CSI=1n and CSI=2n which query
a state report from the terminal (for font state or video/emu mode), the same
information returned in the DA in the previous rev, but in a format more in
line with the corresponding CSI? N h/l requests (no bit checking required).
parent 4b3acf15
Branches
Tags
No related merge requests found
...@@ -980,7 +980,7 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int * ...@@ -980,7 +980,7 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
case '[': case '[':
/* ANSI stuff */ /* ANSI stuff */
p=cterm->escbuf+strlen(cterm->escbuf)-1; p=cterm->escbuf+strlen(cterm->escbuf)-1;
if(cterm->escbuf[1]>=60 && cterm->escbuf[1] <= 63) { /* Private extenstions */ if(cterm->escbuf[1]>=60 && cterm->escbuf[1] <= 63) { /* Private extensions */
switch(*p) { switch(*p) {
case 'M': case 'M':
if(cterm->escbuf[1] == '=') { /* ANSI Music setup */ if(cterm->escbuf[1] == '=') { /* ANSI Music setup */
...@@ -1078,6 +1078,48 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int * ...@@ -1078,6 +1078,48 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
if(!strcmp(cterm->escbuf,"[=255l")) if(!strcmp(cterm->escbuf,"[=255l"))
cterm->doorway_mode=0; cterm->doorway_mode=0;
break; break;
case 'n': /* Query (extended) state information */
if(cterm->escbuf[1] != '=' || retbuf == NULL)
break;
tmp[0] = 0;
switch(strtoul(cterm->escbuf+2,NULL,10)) {
case 1: /* Font state set via "CSI sp D" */
sprintf(tmp, "\x1b[=1;%u;%u;%u;%u;%u;%un"
,CONIO_FIRST_FREE_FONT
,(uint8_t)cterm->setfont_result
,(uint8_t)cterm->altfont[0]
,(uint8_t)cterm->altfont[1]
,(uint8_t)cterm->altfont[2]
,(uint8_t)cterm->altfont[3]
);
break;
case 2: /* Video and emulation modes/flags set via "CSI ? N h" */
{
int vidflags = GETVIDEOFLAGS();
strcpy(tmp, "\x1b[=2");
if(cterm->origin_mode)
strcat(tmp, ";6");
if(cterm->autowrap)
strcat(tmp, ";7");
if(cterm->cursor == _NORMALCURSOR)
strcat(tmp, ";25");
if(vidflags & CIOLIB_VIDEO_ALTCHARS)
strcat(tmp, ";31");
if(vidflags & CIOLIB_VIDEO_NOBRIGHT)
strcat(tmp, ";32");
if(vidflags & CIOLIB_VIDEO_BGBRIGHT)
strcat(tmp, ";33");
if(vidflags & CIOLIB_VIDEO_BLINKALTCHARS)
strcat(tmp, ";34");
if(vidflags & CIOLIB_VIDEO_NOBLINK)
strcat(tmp, ";35");
strcat(tmp, "n");
break;
}
}
if(*tmp && strlen(retbuf) + strlen(tmp) < retsize)
strcat(retbuf, tmp);
break;
case 's': case 's':
if(cterm->escbuf[1] == '?') { if(cterm->escbuf[1] == '?') {
*p=0; *p=0;
...@@ -1595,21 +1637,8 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int * ...@@ -1595,21 +1637,8 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
i=strtoul(cterm->escbuf+1,NULL,10); i=strtoul(cterm->escbuf+1,NULL,10);
if(!i) { if(!i) {
if(retbuf!=NULL) { if(retbuf!=NULL) {
uint8_t mode_flags = cterm->autowrap if(strlen(retbuf) + strlen(cterm->DA) < retsize)
| (cterm->origin_mode << 1) strcat(retbuf,cterm->DA);
| (cterm->doorway_mode << 2)
| (cterm->cursor << 3);
if(strlen(retbuf) + strlen(cterm->DA) + 29 < retsize)
sprintf(retbuf + strlen(retbuf), "%s;%u;%u;%u;%u;%u;%u;%uc"
,cterm->DA
,(uint8_t)GETVIDEOFLAGS()
,mode_flags
,(uint8_t)cterm->setfont_result
,(uint8_t)cterm->altfont[0]
,(uint8_t)cterm->altfont[1]
,(uint8_t)cterm->altfont[2]
,(uint8_t)cterm->altfont[3]
);
} }
} }
break; break;
...@@ -1949,7 +1978,7 @@ struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypo ...@@ -1949,7 +1978,7 @@ struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypo
} }
*out=0; *out=0;
} }
sprintf(cterm->DA + strlen(cterm->DA), ";%u", CONIO_FIRST_FREE_FONT); strcat(cterm->DA,"c");
cterm->setfont_result = CTERM_NO_SETFONT_REQUESTED; cterm->setfont_result = CTERM_NO_SETFONT_REQUESTED;
/* Fire up note playing thread */ /* Fire up note playing thread */
if(!cterm->playnote_thread_running) { if(!cterm->playnote_thread_running) {
......
...@@ -112,6 +112,38 @@ CSI = [ p1 [ ; p2 ] ] { ...@@ -112,6 +112,38 @@ CSI = [ p1 [ ; p2 ] ] {
SOURCE: CTerm only. SOURCE: CTerm only.
CSI = [ p1 [ ; ... ] ] n
NON-STANDARD EXTENSION
State/Mode Request/Report
Defaults: p1 = 0
When p1 is 1, CTerm will respond with a Font State Report of the form
CSI = 1 ;pF ;pR ;pS0 ;pS1 ;pS2 ;pS3 n
pF is the first available loadable-font slot number
pR is the result of the previous "Font Selection" request:
0 = successful font selection
1 = font selection requests are not supported by client
2 = required subsystem for font use has not been initialized
3 = selected font is not available or is incompatible with current video mode
4 = invalid font slot number specified in request
5 = required video mode for selected font is incompatible with current video mode
6 = memory allocation failure
99 = no font selection request has been received
pS0 - pS3 contain the font slots numbers of previously successful "Font Selection" requests
into the 4 available alternate-font style/attribute values:
pS0 - normal attribute font slot
PS1 - high intensity foreground attribute font slot
PS2 - blink attribute font slot
PS3 - high intensity blink attribute font slot
When p1 is 2, CTerm will respond with a Mode Report of the form
CSI = 2[;pN [;pN] [...]] n
Where pN represent zero or more mode values set previously (e.g. via CSI ? pN h).
Mode values cleared (disabled via CSI ? pN l) will not be included in the set of values
returned in the Mode Report.
Other values of p1 will be ignored by CTerm.
CSI = 255 h CSI = 255 h
NON-STANDARD EXTENSION NON-STANDARD EXTENSION
...@@ -383,7 +415,7 @@ CSI [ p1 [ ; p2 ] ] sp D ...@@ -383,7 +415,7 @@ CSI [ p1 [ ; p2 ] ] sp D
42 - Topaz (Amiga) 42 - Topaz (Amiga)
Not all fonts are supported in all modes. If a font is not supported in Not all fonts are supported in all modes. If a font is not supported in
the current mode, no action is taken, but there should be a non-zero the current mode, no action is taken, but there should be a non-zero
'Font Selection result' value in the Device Attributes response. 'Font Selection result' value in the Font State Report.
SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
...@@ -528,43 +560,13 @@ CSI [ p1 ] c ...@@ -528,43 +560,13 @@ CSI [ p1 ] c
Device Attributes Device Attributes
Defaults: p1 = 0 Defaults: p1 = 0
If p1 is 0, CTerm will reply with the sequence: If p1 is 0, CTerm will reply with the sequence:
CSI [ = 67;84;101;114;109;pN;pV;pM;pF;pR;pS0;pS1;pS2;pS3... c CSI = 67;84;101;114;109;pN c
64;84;101;114;109 is the ASCII values of the "CTerm" string. pN is the 64;84;101;114;109 is the ASCII values of the "CTerm" string. pN is the
CVS revision ID of CTerm with dots converted to semi-colons (e.g. "1;156"). CVS revision ID of CTerm with dots converted to semi-colons (e.g. "1;156").
Use the CVS revision to detect if a specific feature is available. If Use the CVS revision to detect if a specific feature is available. If
you are adding features to a forked version of cterm, please do so by you are adding features to a forked version of cterm, please do so by
adding an extra parameter to the end, not by incrementing any existing adding an extra parameter to the end, not by incrementing any existing
one! one!
pV is the set of current video flags, in decimal:
bit 0 = high intensity foreground selects alternate font (CSI ? 31 h)
bit 1 = high intensity foreground attribute does not change intensity (CSI ? 32 h)
bit 2 = blink attribute control high intensity background attributes (CSI ? 33 h)
bit 3 = blink attribute selects alternate font (CSI ? 34 h)
bit 4 = blink attribute does not blink text (CSI ? 35 h)
pM is the current emulation mode, in decimal:
bit 0 = auto wrap enabled (CSI ? 7 h)
bit 1 = origin mode enabled (CSI ? 6 h)
bit 2 = doorway mode enabled (CSI = 255 h)
bits 3:4 = cursor:
00b = 0: Invisible cursor (CSI ? 25 l)
01b = 1: Solid cursor
10b = 2: Normal cursor (CSI ? 25 h)
pF is the first available loadable-font slot number, in decimal
pR is the result of the previous "Font Selection" request:
0 = successful font selection
1 = font selection requests are not supported by client
2 = required subsystem for font use has not been initialized
3 = selected font is not available or is incompatible with current video mode
4 = invalid font slot number specified in request
5 = required video mode for selected font is incompatible with current video mode
6 = memory allocation failure
99 = no font selection request has been received
pS0 - pS3 contain the font slots numbers of previously successful "Font Selection" requests
into the 4 available alternate-font style/attribute values:
pS0 - normal attribute font slot
PS1 - high intensity foreground attribute font slot
PS2 - blink attribute font slot
PS3 - high intensity blink attribute font slot
SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment