Commit cd3b8411 authored by rswindell's avatar rswindell
Browse files

Added 4 additional fields to the Device Attributes response:

- first available loadable-font slot number (e.g. 43)
- result of previous "select font" request (0 = success)
- current video mode flags (e.g. high-intensity background)
- current emulation mode flags (e.g. cursor visible, doorway mode)

These are to aid the server (BBS) in making better use of advanced features,
namely alternative/loadable fonts and high-intensity background colors (aka iCE
colors). Being able to detect when these features are supported and working as
intended is vital in providing a smooth/automated BBS experience which is
automatically enhanced, when possible (supported by the client) and does not
interfere with legacy (non-enhanced client) users.
Even better would be a command that tells the server:
if the server were to attempt a request 'X', it would likely work.
Instead, we have to try request 'X' and then query the device attributes to
find out if it actually worked, which is better than nothing (or asking the
poor user to tell the BBS whether it worked or not).
parent f54b778f
......@@ -503,11 +503,12 @@ int bitmap_setfont(int font, int force, int font_num)
int attr;
char *pold;
char *pnew;
int result = CIOLIB_SETFONT_CHARHEIGHT_NOT_SUPPORTED;
if(!bitmap_initialized)
return(-1);
return(CIOLIB_SETFONT_NOT_INITIALIZED);
if(font < 0 || font>(sizeof(conio_fontdata)/sizeof(struct conio_font_data_struct)-2))
return(-1);
return(CIOLIB_SETFONT_INVALID_FONT);
if(conio_fontdata[font].eight_by_sixteen!=NULL)
newmode=C80;
......@@ -543,8 +544,10 @@ int bitmap_setfont(int font, int force, int font_num)
}
break;
}
if(changemode && (newmode==-1 || font_num > 1))
if(changemode && (newmode==-1 || font_num > 1)) {
result = CIOLIB_SETFONT_ILLEGAL_VIDMODE_CHANGE;
goto error_return;
}
switch(font_num) {
case 0:
default_font=font;
......@@ -578,7 +581,7 @@ int bitmap_setfont(int font, int force, int font_num)
new=malloc(ti.screenwidth*ti.screenheight*2);
if(!new) {
free(old);
return -1;
return CIOLIB_SETFONT_MALLOC_FAILURE;
}
pold=old;
pnew=new;
......@@ -612,11 +615,11 @@ int bitmap_setfont(int font, int force, int font_num)
}
}
bitmap_loadfont(NULL);
return(0);
return(CIOLIB_SETFONT_SUCCESS);
error_return:
pthread_mutex_unlock(&vstatlock);
return(-1);
return(result);
}
int bitmap_getfont(void)
......
......@@ -4,7 +4,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
......@@ -1477,7 +1477,7 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_setfont(int font, int force, int font_num)
if(cio_api.setfont!=NULL)
return(cio_api.setfont(font,force,font_num));
else
return(-1);
return(CIOLIB_SETFONT_NOT_SUPPORTED);
}
/* Optional */
......
......@@ -68,6 +68,16 @@
#define CIOLIBEXPORTVAR extern
#endif
enum {
CIOLIB_SETFONT_SUCCESS = 0
,CIOLIB_SETFONT_NOT_SUPPORTED = 1
,CIOLIB_SETFONT_NOT_INITIALIZED = 2
,CIOLIB_SETFONT_CHARHEIGHT_NOT_SUPPORTED = 3
,CIOLIB_SETFONT_INVALID_FONT = 4
,CIOLIB_SETFONT_ILLEGAL_VIDMODE_CHANGE = 5
,CIOLIB_SETFONT_MALLOC_FAILURE = 6
};
enum {
CIOLIB_MODE_AUTO
,CIOLIB_MODE_CURSES
......
......@@ -4,7 +4,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2006 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
......@@ -1366,7 +1366,7 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
case 1:
case 2:
case 3:
SETFONT(j,FALSE,i+1);
cterm->setfont_result = SETFONT(j,FALSE,i+1);
}
}
}
......@@ -1592,8 +1592,16 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
i=strtoul(cterm->escbuf+1,NULL,10);
if(!i) {
if(retbuf!=NULL) {
if(strlen(retbuf)+strlen(cterm->DA) < retsize)
strcat(retbuf,cterm->DA);
uint8_t mode_flags = cterm->autowrap
| (cterm->origin_mode << 1)
| (cterm->doorway_mode << 2)
| (cterm->cursor << 3);
if(strlen(retbuf)+strlen(cterm->DA)+12 < retsize)
sprintf(retbuf + strlen(retbuf), "%s;%u;%u;%uc"
,cterm->DA
,(uint8_t)cterm->setfont_result
,(uint8_t)GETVIDEOFLAGS()
,mode_flags);
}
}
break;
......@@ -1922,7 +1930,7 @@ struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypo
cterm->origin_mode=false;
if(cterm->scrollback!=NULL)
memset(cterm->scrollback,0,cterm->width*2*cterm->backlines);
strcpy(cterm->DA,"\x1b[=67;84;101;114;109;");
sprintf(cterm->DA,"\x1b[=67;84;101;114;109;%u;", CONIO_FIRST_FREE_FONT);
out=strchr(cterm->DA, 0);
if(out != NULL) {
for(in=revision; *in; in++) {
......@@ -1933,7 +1941,6 @@ struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypo
}
*out=0;
}
strcat(cterm->DA,"c");
/* Fire up note playing thread */
if(!cterm->playnote_thread_running) {
listInit(&cterm->notes, LINK_LIST_SEMAPHORE|LINK_LIST_MUTEX);
......
......@@ -4,7 +4,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html *
* Copyright Rob Swindell - http://www.synchro.net/copyright.html *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
......@@ -76,6 +76,7 @@ struct cterminal {
/* conio stuff */
int x; // X position of the left side on the screen
int y; // Y position of the top pn the screen
int setfont_result;
/* emulation mode */
cterm_emulation_t emulation;
......@@ -132,7 +133,7 @@ struct cterminal {
int font_size; // Bytes
int doorway_mode;
int doorway_char; // Indicates next char is a "doorway" mode char
int cursor; // Current cursor mode (Normal or None)z
int cursor; // Current cursor mode (Normal or None)
/* conio function pointers */
#ifdef CTERM_WITHOUT_CONIO
......
......@@ -324,7 +324,7 @@ CSI [ p1 [ ; p2 ] ] sp D
Font Selection
Defaults: p1 = 0 p2 = 0
"sp" indicates a single space character.
Sets font p1 to be the one indicated bu p2. Currently four fonts are
Sets font p1 to be the one indicated by p2. Currently four fonts are
supported. p2 must be between 0 and 255. Not all output types support
font selection. Only X11 and SDL currently do.
Supported p1 values:
......@@ -380,7 +380,8 @@ CSI [ p1 [ ; p2 ] ] sp D
41 - MicroKnight (Amiga)
42 - Topaz (Amiga)
Not all fonts are supported in all modes. If a font is not supported in
the current mode, no action is taken.
the current mode, no action is taken, but there should be a non-zero
'setfont_result' value in the Device Attributes response.
SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
......@@ -525,13 +526,36 @@ CSI [ p1 ] c
Device Attributes
Defaults: p1 = 0
If p1 is 0, CTerm will reply with the sequence:
CSI [ = 67;84;101;114;109;pN... c
CSI [ = 67;84;101;114;109;pN;pF;pS;pV;pM... c
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.
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
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
one!
pF is the first available loadable-font slot number, in decimal
pS is the result of any 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 initalized
3 = character height of selected font is not supported in current video mode
4 = invalid font slot number specified in request
5 = required video mode for selected font is not compatible with current video mode
6 = memory allocation failure
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 curren 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: No cursor (CSI ? 25 l)
01b = 1: Solid cursor
02b = 2: Normal cursor (CSI ? 25 h)
SOURCE: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-048.pdf
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment