home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
rtsi.com
/
2014.01.www.rtsi.com.tar
/
www.rtsi.com
/
OS9
/
OSK
/
EFFO
/
forum7.lzh
/
C
/
CHARDEF
/
chardef.lex
< prev
next >
Wrap
Text File
|
1988-10-04
|
3KB
|
211 lines
%{
/* chardef ein Program um den freidefinierbaren Zeichensatz eine VT220-kompatiblen Terminals zu definieren */
/* Uwe Simon 25.9.88 */
/* */
#include <ctype.h>
int aktline = -1;
int aktchar = -1; /* noch kein Zeichen aktiviert */
int erase = 1; /* kein loeschen der alten Zeichen */
int line_nr=1; /* aktuelle Zeilennummer */
int charset=0; /* Zeichensatz fuer die definition */
int character[94][14];
int is_def[95];
char c_set = '<'; /* default: der Supplemental-charset wird ueberschrieben */
set_charset(s)
char *s;
{
c_set = s[7];
}
clear_charset()
{
erase=0;
}
char_number(s)
char *s;
{
int h;
h=atoi(s);
if((h<33) || (h>126)) /* falsche Nummer */
{
aktchar = -1;
aktline = -1;
in_line();
fprintf(stderr,"Illegal Characternumber\n");
return;
}
aktchar = h-33;
is_def[aktchar] = 1;
aktline = 0;
}
build_char(n)
int n;
{
int i, j, k, mask;
char s[20];
for(i=0;i<15;i++) s[i]='\0';
for(i=0; i<6; i++) character[n][i] = character[n][i+6] | (character[n][i]<<7);
mask = 0x01;
for(i=0;i<6;i++)
{
k=0;
for(j=0x2000; j; j=j>>1)
{
if(character[n][i] & j)
s[k] |= mask;
k++;
}
mask = mask <<1;
}
for(i=0;i<14;i++)
{
s[i]+= 0x3f;
if(i==7)
printf("/");
printf("%c",s[i]);
}
if(is_def[n+1])
{
printf(";");
return(0);
}
else
return(1);
}
send_charset()
{
int i,j;
int first;
first=1;
for(i=0;i<94;i++)
if(is_def[i])
{
if(first)
{
printf("%cP1;%d;%d{%c",0x1b,i+1,erase,c_set);
erase=1;
}
first = build_char(i);
if(first)
printf("%c\\",0x1b);
}
}
build_line(s)
char *s;
{
int h;
if((aktchar < 0) || (aktline < 0)) /* keine Zeichennummer gewesen */
{
in_line();
fprintf(stderr, "no Characternumber spezified\n");
}
else
if(aktline >10) /* keine Zeichennummer gewesen */
{
in_line();
fprintf(stderr, "Only 10 lines per character\n");
}
else
{
h=0;
for(; *s; s++)
{
h = h<<1;
if(*s == '*')
h++;
}
character[aktchar][aktline++] = h & 0xff;
}
}
in_line()
{
fprintf(stderr,"Line %d:",line_nr);
}
usage()
{
fprintf(stderr,"Syntax: defchar [<path>]\n");
fprintf(stderr,"Function:defines a new Charset for VT220 Terminals\n");
fprintf(stderr,"Options: none\n");
exit(0);
}
yywrap()
{
return(feof(stdin));
}
main(argc, argv)
int argc;
char *argv[];
{
int h;
int line=1;
if(argc > 1)
{
if(strcmp(argv[1], "-?") == 0)
usage();
if(freopen(argv[1],"r", stdin) == NULL)
{
fprintf(stderr,"can't open %s\n", argv[1]);
exit(1);
}
}
cleareof(stdin);
while(h=yylex())
{
switch(h)
{
default:
in_line(line);
printf("Syntax-Error\n");
break;
}
line++;
}
}
%}
%%
#[ -~]*$ ;
"charset"[0-~] set_charset(yytext);
"clear" clear_charset();
[ ]+ ;
[0-9]+: char_number(yytext);
[
] line_nr++;
[.*]+ build_line(yytext);
"end" send_charset();