diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 1997-07-18 14:09:51 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 1997-07-18 14:09:51 -0400 |
commit | 57bfc74ff4ec4c2980b2330f2badc54a8990842d (patch) | |
tree | 81bffba3be5c8037a5064ec5d49cf243130697fb /src/UCAuto.c | |
parent | fb4db89ab1d82336978b68a66532da971702e2fb (diff) | |
download | lynx-snapshots-57bfc74ff4ec4c2980b2330f2badc54a8990842d.tar.gz |
snapshot of project "lynx", label v2-7-1ac_0-36
Diffstat (limited to 'src/UCAuto.c')
-rw-r--r-- | src/UCAuto.c | 236 |
1 files changed, 158 insertions, 78 deletions
diff --git a/src/UCAuto.c b/src/UCAuto.c index cd786b76..b09df4ab 100644 --- a/src/UCAuto.c +++ b/src/UCAuto.c @@ -1,32 +1,43 @@ -#ifdef EXP_CHARTRANS -#ifdef EXP_CHARTRANS_AUTOSWITCH -#ifdef LINUX - -/* This file contains code for changing the Linux console mode. -** Currently some names for font files are hardwired in here. -** You have to change this code if it needs accomodation for your -** system (or get the required files...). +/* +** This file contains code for changing the Linux console mode. +** Currently some names for font files are hardwired in here. +** You have to change this code if it needs accomodation for your +** system (or get the required files...). ** -** Depending on the Display Character Set switched to, and the previous -** one as far as it is known, system("setfont ...") and/or output of -** escape sequences to switch console mode are done. Curses will be -** temporarily suspended while that happens. +** Depending on the Display Character Set switched to, and the previous +** one as far as it is known, system("setfont ...") and/or output of +** escape sequences to switch console mode are done. Curses will be +** temporarily suspended while that happens. ** -** NOTE that the setfont calls will also affect all other virtual consoles. +** NOTE that the setfont calls will also affect all other virtual consoles. ** -** Any ideas how to do this for other systems? +** Any ideas how to do this for other systems? */ -#include "tcp.h" + #include "HTUtils.h" +#include "tcp.h" + #include "UCMap.h" #include "UCDefs.h" #include "UCAuto.h" #include "LYGlobalDefs.h" -typedef enum {Is_Unset, Is_Set, Dunno, Dont_Care} TGen_state_t; -typedef enum {G0, G1} TGNstate_t; -typedef enum -{ +#ifdef EXP_CHARTRANS_AUTOSWITCH + +#ifdef VMS +#define DISPLAY "DECW$DISPLAY" +#else +#define DISPLAY "DISPLAY" +#endif /* VMS */ + +#ifdef LINUX +typedef enum { + Is_Unset, Is_Set, Dunno, Dont_Care +} TGen_state_t; +typedef enum { + G0, G1 +} TGNstate_t; +typedef enum { GN_Blat1, GN_0decgraf, GN_Ucp437, GN_Kuser, GN_dunno, GN_dontCare } TTransT_t; @@ -36,11 +47,17 @@ static char T_setfont_cmd[200] = "\0"; #define SETFONT "setfont" #define NOOUTPUT "2>/dev/null" -PRIVATE void call_setfont ARGS3(char *,font, char *,fnsuffix, char *,umap) +PRIVATE void call_setfont ARGS3( + char *, font, + char *, fnsuffix, + char *, umap) { if (font && *font && umap && *umap && - 0==strcmp(font,T_font_fn) && 0==strcmp(umap,T_umap_fn)) { - return; /* no need to repeat */ + !strcmp(font, T_font_fn) && !strcmp(umap, T_umap_fn)) { + /* + * No need to repeat. + */ + return; } if (font) strcpy(T_font_fn, font); @@ -62,21 +79,21 @@ PRIVATE void call_setfont ARGS3(char *,font, char *,fnsuffix, char *,umap) } else { *T_setfont_cmd = '\0'; } - + if (*T_setfont_cmd) { - - if (TRACE) { - fprintf(stderr, "Executing setfont: '%s'\n", - T_setfont_cmd); - } - + if (TRACE) { + fprintf(stderr, "Executing setfont: '%s'\n", T_setfont_cmd); + } system(T_setfont_cmd); } } -/* This is the thing that actually gets called from display_page(). */ - -PUBLIC void UCChangeTerminalCodepage ARGS2(int, newcs, LYUCcharset *,p) +/* + * This is the thing that actually gets called from display_page(). + */ +PUBLIC void UCChangeTerminalCodepage ARGS2( + int, newcs, + LYUCcharset *, p) { static int lastcs = -1; static char * lastname = NULL; @@ -94,98 +111,128 @@ PUBLIC void UCChangeTerminalCodepage ARGS2(int, newcs, LYUCcharset *,p) char tmpbuf1[100], tmpbuf2[20]; char *cp; -/* Font sizes are currently hardwired here... */ + /* + * Font sizes are currently hardwired here. + */ #define SUFF1 ".f16" #define SUFF2 "-16.psf" #define SUFF3 "-8x16" #define SUFF4 "8x16" -/* use this for output of escape sequences... */ -/* for some reason stdout won't do... maybe needs flush() somewhere.. */ + /* + * Use this for output of escape sequences. + * + * For some reason stdout won't do; maybe needs flush() somewhere. + */ #define ESCOUT stderr - -#ifdef VMS -#define DISPLAY "DECW$DISPLAY" -#else -#define DISPLAY "DISPLAY" -#endif /* VMS */ - if (display || (cp = getenv(DISPLAY)) != NULL) { - /* We won't do anything in an xterm. Better that way... */ + /* + * We won't do anything in an xterm. Better that way... + */ return; } - if (0==strcmp(name,"iso-8859-10")) { - call_setfont("iso10", SUFF1, "iso10.uni"); + if (!strcmp(name, "iso-8859-10")) { + call_setfont("iso10", SUFF1, "iso10.uni"); TransT = GN_Kuser; HasUmap = Is_Set; Utf = Is_Unset; - } else if (0==strncmp(name,"iso-8859-1",10)) { - if ((lastHasUmap==Is_Set) && 0==strcmp(lastname,"cp850")) { - /* cp850 already contains all latin1 characters */ - if (lastTransT != GN_Blat1) + } else if (!strncmp(name, "iso-8859-1", 10)) { + if ((lastHasUmap == Is_Set) && !strcmp(lastname, "cp850")) { + /* + * cp850 already contains all latin1 characters. + */ + if (lastTransT != GN_Blat1) { TransT = GN_Blat1; + } } else { - call_setfont("lat1u", SUFF2, "lat1u.uni"); - /* "setfont lat1u-16.psf -u lat1u.uni" */ + /* + * "setfont lat1u-16.psf -u lat1u.uni" + */ + call_setfont("lat1u", SUFF2, "lat1u.uni"); HasUmap = Is_Set; - if (lastTransT != GN_Blat1) + if (lastTransT != GN_Blat1) { TransT = GN_Blat1; + } } Utf = Is_Unset; - } else if (0==strcmp(name,"iso-8859-2")) { -/* call_setfont("lat2", SUFF2, "lat2.uni"); */ - /* "setfont lat2-16.psf -u lat2.uni" */ - call_setfont("iso02", SUFF1, "iso02.uni"); - /* "setfont iso02.f16 -u iso02.uni" */ + } else if (!strcmp(name, "iso-8859-2")) { +#ifdef NOTDEFINED + /* + * "setfont lat2-16.psf -u lat2.uni" + */ + call_setfont("lat2", SUFF2, "lat2.uni"); */ +#endif /* NOTDEFINED */ + /* + * "setfont iso02.f16 -u iso02.uni" + */ + call_setfont("iso02", SUFF1, "iso02.uni"); TransT = GN_Kuser; HasUmap = Is_Set; Utf = Is_Unset; - } else if (0==strncmp(name,"iso-8859-",9)) { + } else if (!strncmp(name, "iso-8859-", 9)) { sprintf(tmpbuf1, "iso0%s", &name[9]); sprintf(tmpbuf2, "iso0%s%s", &name[9],".uni"); - call_setfont(tmpbuf1,SUFF1, tmpbuf2); - /* "setfont iso0N.f16 -u iso0N.uni" */ + /* + * "setfont iso0N.f16 -u iso0N.uni" + */ + call_setfont(tmpbuf1, SUFF1, tmpbuf2); TransT = GN_Kuser; HasUmap = Is_Set; Utf = Is_Unset; - } else if (0==strcmp(name,"koi8-r")) { - call_setfont("koi8", SUFF3, NULL); + } else if (!strcmp(name, "koi8-r")) { + /* + * "setfont koi8-8x16" + */ + call_setfont("koi8", SUFF3, NULL); TransT = GN_Kuser; HasUmap = Is_Unset; Utf = Is_Unset; - } else if (0==strcmp(name,"cp437")) { - call_setfont("default", SUFF4 , "cp437.uni"); - /* "setfont default8x16 -u cp437.uni" */ + } else if (!strcmp(name, "cp437")) { + /* + * "setfont default8x16 -u cp437.uni" + */ + call_setfont("default", SUFF4, "cp437.uni"); if (TransT == GN_Kuser || TransT == GN_Ucp437) TransT = GN_dontCare; else TransT = GN_Ucp437; HasUmap = Is_Set; Utf = Is_Unset; - } else if (0==strcmp(name,"cp850")) { - call_setfont("cp850" ,SUFF3 , "cp850.uni"); - /* "setfont cp850-8x16 -u cp850.uni" */ + } else if (!strcmp(name, "cp850")) { + /* + * "setfont cp850-8x16 -u cp850.uni" + */ + call_setfont("cp850", SUFF3, "cp850.uni"); TransT = GN_Kuser; HasUmap = Is_Set; Utf = Is_Unset; - } else if (0==strcmp(name,"x-transparent")) { + } else if (!strcmp(name, "x-transparent")) { Utf = Dont_Care; - } else if (0==strcmp(name,"us-ascii")) { + } else if (!strcmp(name, "us-ascii")) { Utf = Dont_Care; - } else if (0==strncmp(name,"mnem",4)) { + } else if (!strncmp(name, "mnem", 4)) { Utf = Dont_Care; } if (TransT != lastTransT) { if (TransT == GN_Blat1) { - fprintf(ESCOUT,"\033(B"); /* switch Linux console to lat1 table */ + /* + * Switch Linux console to lat1 table. + */ + fprintf(ESCOUT, "\033(B"); } else if (TransT == GN_0decgraf) { - fprintf(ESCOUT,"\033(0"); + fprintf(ESCOUT, "\033(0"); } else if (TransT == GN_Ucp437) { - fprintf(ESCOUT,"\033(U"); /* switch Linux console to 437 table? */ + /* + * Switch Linux console to 437 table? + */ + fprintf(ESCOUT, "\033(U"); } else if (TransT == GN_Kuser) { - fprintf(ESCOUT,"\033(K"); /* switch Linux console to user table */ + /* + * Switch Linux console to user table. + */ + fprintf(ESCOUT, "\033(K"); } if (TransT != GN_dunno && TransT != GN_dontCare) { lastTransT = TransT; @@ -200,13 +247,19 @@ PUBLIC void UCChangeTerminalCodepage ARGS2(int, newcs, LYUCcharset *,p) if (p->enc == UCT_ENC_UTF8) { if (lastUtf != Is_Set) { Utf = Is_Set; - fprintf(ESCOUT,"\033%%G"); /* turn Linux console UTF8 mode ON */ + /* + * Turn Linux console UTF8 mode ON. + */ + fprintf(ESCOUT, "\033%%G"); lastUtf = Utf; } return; } else if (lastUtf == Is_Set && Utf != Dont_Care) { Utf = Is_Unset; - fprintf(ESCOUT,"\033%%@"); /* turn Linux console UTF8 mode OFF */ + /* + * Turn Linux console UTF8 mode OFF. + */ + fprintf(ESCOUT, "\033%%@"); lastUtf = Utf; } @@ -216,6 +269,33 @@ PUBLIC void UCChangeTerminalCodepage ARGS2(int, newcs, LYUCcharset *,p) lastcs = newcs; lastname = name; } + +#else /* Not LINUX: */ +/* + * This is the thing that actually gets called from display_page(). + */ +PUBLIC void UCChangeTerminalCodepage ARGS2( + int, newcs, + LYUCcharset *, p) +{ + if (TRACE) { + fprintf(stderr, + "UCChangeTerminalCodepage: Called, but not implemented!"); + } +} #endif /* LINUX */ + +#else /* EXP_CHARTRANS_AUTOSWITCH not defined: */ +/* + * This is the thing that actually gets called from display_page(). + */ +PUBLIC void UCChangeTerminalCodepage ARGS2( + int, newcs, + LYUCcharset *, p) +{ + if (TRACE) { + fprintf(stderr, + "UCChangeTerminalCodepage: Called, but not implemented!"); + } +} #endif /* EXP_CHARTRANS_AUTOSWITCH */ -#endif /* EXP_CHARTRANS */ |