Commit 7d491d1a authored by deuce's avatar deuce
Browse files

Add setvideoflags() function. Support in CTerm using:

                 Enable         Disable
Alt Charset     CSI[?31h       CSI[?31l
Disable Bright  CSI[?32h       CSI[?32l
Bright BG       CSI[?33h       CSI[?33l
parent e44ec674
......@@ -252,6 +252,37 @@ void bitmap_setcustomcursor(int s, int e, int r, int b, int v)
pthread_mutex_unlock(&vstatlock);
}
int bitmap_getvideoflags(void)
{
int flags=0;
if(vstat.bright_background)
flags |= CIOLIB_VIDEO_BGBRIGHT;
if(vstat.no_bright)
flags |= CIOLIB_VIDEO_NOBRIGHT;
if(vstat.bright_altcharset)
flags |= CIOLIB_VIDEO_ALTCHARS;
return(flags);
}
void bitmap_setvideoflags(int flags)
{
if(flags & CIOLIB_VIDEO_BGBRIGHT)
vstat.bright_background=1;
else
vstat.bright_background=0;
if(flags & CIOLIB_VIDEO_NOBRIGHT)
vstat.no_bright=1;
else
vstat.no_bright=0;
if(flags & CIOLIB_VIDEO_ALTCHARS)
vstat.bright_altcharset=1;
else
vstat.bright_altcharset=0;
}
int bitmap_movetext(int x, int y, int ex, int ey, int tox, int toy)
{
int direction=1;
......@@ -598,7 +629,7 @@ int bitmap_loadfont(char *filename)
if(current_secondary_font==-1)
memcpy(secondary_font, font, fontsize);
}
if(current_font != -1 || secondary_font != -1) {
if(current_font != -1 || current_secondary_font != -1) {
switch(vstat.charwidth) {
case 8:
switch(vstat.charheight) {
......@@ -608,9 +639,10 @@ int bitmap_loadfont(char *filename)
goto error_return;
memcpy(font, conio_fontdata[current_font].eight_by_eight, fontsize);
}
if(secondary_font != -1) {
if(conio_fontdata[current_secondary_font].eight_by_eight==NULL)
if(current_secondary_font != -1) {
if(conio_fontdata[current_secondary_font].eight_by_eight==NULL) {
FREE_AND_NULL(secondary_font);
}
else
memcpy(font, conio_fontdata[current_secondary_font].eight_by_eight, fontsize);
}
......@@ -621,9 +653,10 @@ int bitmap_loadfont(char *filename)
goto error_return;
memcpy(font, conio_fontdata[current_font].eight_by_fourteen, fontsize);
}
if(secondary_font != -1) {
if(conio_fontdata[current_secondary_font].eight_by_fourteen==NULL)
if(current_secondary_font != -1) {
if(conio_fontdata[current_secondary_font].eight_by_fourteen==NULL) {
FREE_AND_NULL(secondary_font);
}
else
memcpy(font, conio_fontdata[current_secondary_font].eight_by_fourteen, fontsize);
}
......@@ -634,9 +667,10 @@ int bitmap_loadfont(char *filename)
goto error_return;
memcpy(font, conio_fontdata[current_font].eight_by_sixteen, fontsize);
}
if(secondary_font != -1) {
if(conio_fontdata[current_secondary_font].eight_by_sixteen==NULL)
if(current_secondary_font != -1) {
if(conio_fontdata[current_secondary_font].eight_by_sixteen==NULL) {
FREE_AND_NULL(secondary_font);
}
else
memcpy(font, conio_fontdata[current_secondary_font].eight_by_sixteen, fontsize);
}
......
......@@ -13,7 +13,7 @@ int bitmap_gettext(int sx, int sy, int ex, int ey, void *fill);
int bitmap_puttext(int sx, int sy, int ex, int ey, void *fill);
void bitmap_gotoxy(int x, int y);
void bitmap_setcursortype(int type);
int bitmap_setfont(int font, int force);
int bitmap_setfont(int font, int force, int font_no);
int bitmap_getfont(void);
int bitmap_loadfont(char *filename);
......@@ -26,5 +26,7 @@ void bitmap_clreol(void);
void bitmap_clrscr(void);
void bitmap_getcustomcursor(int *s, int *e, int *r, int *b, int *v);
void bitmap_setcustomcursor(int s, int e, int r, int b, int v);
int bitmap_getvideoflags(void);
void bitmap_setvideoflags(int flags);
#endif
......@@ -133,6 +133,8 @@ int try_sdl_init(int mode)
cio_api.clrscr=bitmap_clrscr;
cio_api.getcustomcursor=bitmap_getcustomcursor;
cio_api.setcustomcursor=bitmap_setcustomcursor;
cio_api.getvideoflags=bitmap_getvideoflags;
cio_api.setvideoflags=bitmap_setvideoflags;
cio_api.kbhit=sdl_kbhit;
cio_api.getch=sdl_getch;
......@@ -176,6 +178,8 @@ int try_x_init(int mode)
cio_api.clrscr=bitmap_clrscr;
cio_api.getcustomcursor=bitmap_getcustomcursor;
cio_api.setcustomcursor=bitmap_setcustomcursor;
cio_api.getvideoflags=bitmap_getvideoflags;
cio_api.setvideoflags=bitmap_setvideoflags;
cio_api.kbhit=x_kbhit;
cio_api.getch=x_getch;
......@@ -269,6 +273,7 @@ int try_conio_init(int mode)
cio_api.resume=win32_resume;
cio_api.getcustomcursor=win32_getcustomcursor;
cio_api.setcustomcursor=win32_setcustomcursor;
cio_api.getvideoflags=win32_getvideoflags;
return(1);
}
return(0);
......@@ -1297,3 +1302,18 @@ CIOLIBEXPORT void ciolib_setcustomcursor(int start, int end, int range, int blin
if(cio_api.setcustomcursor)
cio_api.setcustomcursor(start,end,range,blink,visible);
}
/* Optional */
CIOLIBEXPORT void CIOLIBCALL ciolib_setvideoflags(int flags)
{
if(cio_api.setvideoflags)
cio_api.setvideoflags(flags);
}
/* Optional */
CIOLIBEXPORT int CIOLIBCALL ciolib_getvideoflags(void)
{
if(cio_api.getvideoflags)
return(cio_api.getvideoflags());
return(0);
}
......@@ -117,6 +117,10 @@ enum {
#define BLINK 128
#endif
#define CIOLIB_VIDEO_ALTCHARS (1<<0) // Attribute bit 3 selects alternate char set
#define CIOLIB_VIDEO_NOBRIGHT (1<<1) // Attribute bit 3 does not increase intensity
#define CIOLIB_VIDEO_BGBRIGHT (1<<2) // Attribute bit 7 selects high intensity background, not blink
enum text_modes
{
/* DOS-compatible modes */
......@@ -269,6 +273,8 @@ typedef struct {
int (*get_window_info) (int* width, int* height, int* xpos, int* ypos);
void (*getcustomcursor) (int *startline, int *endline, int *range, int *blink, int *visible);
void (*setcustomcursor) (int startline, int endline, int range, int blink, int visible);
void (*setvideoflags) (int flags);
int (*getvideoflags) ();
int *ESCDELAY;
} cioapi_t;
......@@ -332,6 +338,8 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_get_window_info(int *width, int *height, int
CIOLIBEXPORT int CIOLIBCALL ciolib_beep(void);
CIOLIBEXPORT void CIOLIBCALL ciolib_getcustomcursor(int *startline, int *endline, int *range, int *blink, int *visible);
CIOLIBEXPORT void CIOLIBCALL ciolib_setcustomcursor(int startline, int endline, int range, int blink, int visible);
CIOLIBEXPORT void CIOLIBCALL ciolib_setvideoflags(int flags);
CIOLIBEXPORT int CIOLIBCALL ciolib_getvideoflags(void);
/* DoorWay specific stuff that's only applicable to ANSI mode. */
CIOLIBEXPORT void CIOLIBCALL ansi_ciolib_setdoorway(int enable);
......@@ -389,6 +397,8 @@ CIOLIBEXPORT void CIOLIBCALL ansi_ciolib_setdoorway(int enable);
#define beep() ciolib_beep()
#define getcustomcursor(a,b,c,d,e) ciolib_getcustomcursor(a,b,c,d,e)
#define setcustomcursor(a,b,c,d,e) ciolib_setcustomcursor(a,b,c,d,e)
#define setvideoflags(a) ciolib_setvideoflags(a)
#define getvideoflags() ciolib_getvideoflags()
#endif
#ifdef WITH_SDL
......
......@@ -563,6 +563,21 @@ void do_ansi(char *retbuf, size_t retsize, int *speed)
cterm.cursor=_NORMALCURSOR;
_setcursortype(cterm.cursor);
}
if(!strcmp(cterm.escbuf,"[?31h")) {
i=getvideoflags();
i|=CIOLIB_VIDEO_ALTCHARS;
setvideoflags(i);
}
if(!strcmp(cterm.escbuf,"[?32h")) {
i=getvideoflags();
i|=CIOLIB_VIDEO_NOBRIGHT;
setvideoflags(i);
}
if(!strcmp(cterm.escbuf,"[?33h")) {
i=getvideoflags();
i|=CIOLIB_VIDEO_BGBRIGHT;
setvideoflags(i);
}
if(!strcmp(cterm.escbuf,"[=255h"))
cterm.doorway_mode=1;
break;
......@@ -571,6 +586,21 @@ void do_ansi(char *retbuf, size_t retsize, int *speed)
cterm.cursor=_NOCURSOR;
_setcursortype(cterm.cursor);
}
if(!strcmp(cterm.escbuf,"[?31l")) {
i=getvideoflags();
i&=~CIOLIB_VIDEO_ALTCHARS;
setvideoflags(i);
}
if(!strcmp(cterm.escbuf,"[?32l")) {
i=getvideoflags();
i&=~CIOLIB_VIDEO_NOBRIGHT;
setvideoflags(i);
}
if(!strcmp(cterm.escbuf,"[?33l")) {
i=getvideoflags();
i&=~CIOLIB_VIDEO_BGBRIGHT;
setvideoflags(i);
}
if(!strcmp(cterm.escbuf,"[=255l"))
cterm.doorway_mode=0;
break;
......
......@@ -367,6 +367,27 @@ CSI [ ? 25 h
SOURCE: "Installing and Using the VT320 Video Terminal"
CSI [ ? 31 h
NON-STANDARD EXTENSION
Enable alt character set
With this mode set, the bright (1) graphic rendition selects characters
from an alternate character set.
CSI [ ? 32 h
NON-STANDARD EXTENSION
Bright Intensity Disable
With this mode set, the bright (1) graphic rendition does not cause
characters to be display in a bright colour
CSI [ ? 33 h
NON-STANDARD EXTENSION
Blink to Bright Intensity Background
With this mode set, the blink (5,6) graphic renditions cause the
background colour to be high intensity rather than causing blink
CSI [ = 255 l
NON-STANDARD EXTENSION
Disable DoorWay Mode
......@@ -379,6 +400,24 @@ CSI [ ? 25 l
SOURCE: "Installing and Using the VT320 Video Terminal"
CSI [ ? 31 l
NON-STANDARD EXTENSION
Disable alt character set
Reverses CSI [ ? 31 h
CSI [ ? 32 l
NON-STANDARD EXTENSION
Bright Intensity Enable
Reverses CSI [ ? 32 h
CSI [ ? 33 l
NON-STANDARD EXTENSION
Blink Normal
Reverses CSI [ ? 33 h
CSI [ p1 [ ; pX ... ] ] m
Select Graphic Rendition
Defaults: p1 = 0
......
......@@ -848,7 +848,7 @@ void win32_getcustomcursor(int *s, int *e, int *r, int *b, int *v)
*v=ci.bVisible?1:0;
}
void win32_set customcursor(int s, int e, int r, int b, int v)
void win32_setcustomcursor(int s, int e, int r, int b, int v)
{
CONSOLE_CURSOR_INFO ci;
HANDLE h;
......@@ -866,3 +866,14 @@ void win32_set customcursor(int s, int e, int r, int b, int v)
ci.dwSize=100;
}
}
int win32_getvideoflags(void)
{
DWORD mode;
if(!NT_GetConsoleDisplayMode(&mode))
return(CIOLIB_VIDEO_BGBRIGHT);
if(mode==CONSOLE_FULLSCREEN_MODE)
return(0);
return(CIOLIB_VIDEO_BGBRIGHT);
}
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