1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
/*
Copyright (C) 1994 Edward Der-Hua Liu, Hsin-Chu, Taiwan
*/
#include <sys/types.h>
#include <X11/keysym.h>
#include "xi.h"
static char inch[4];
static int cin;
extern void ClrShowArea( int x );
extern void change_window_name(char *str);
extern void gotoxy(int x, int y);
extern void set_att(u_char att);
extern int toupper (int c);
extern void sendkey_b5(u_char *s);
void init_inter_code(int usenow)
{
cin=0;
if (usenow) {
change_window_name("Inter Code");
gotoxy(InAreaX,MROW-1);
set_att(InAreaColor);
xprintf(" ");
set_att(NormalColor);
ClrShowArea( 0 );
gotoxy(0,MROW-1);
xprintf(" 롿");
}
}
static int h2i(int x)
{
return (x<='9'?x-'0':x-'A'+10);
}
static char dstr[]="£ãģţ";
int feedkey_intcode(int key)
{
int i;
/*extern int cursor_x;*/
key=toupper(key);
if (key==XK_BackSpace||key==XK_Delete) {
if (cin) cin--;
else return 0;
if (!cin) {
gotoxy(InAreaX,MROW-1);
xprintf(" ");
return 1;
}
goto dispIn;
}
else
if (key<'0'||key>'F'||(key>'9' && key<'A')) return 0;
if (cin==0 && key<'A' ) return 1;
if (cin==1 && inch[0]=='F' && key >'9') return 1;
if (cin==2 && key<'A' ) return 1;
if (cin==3 && inch[2]=='F' && key=='F') return 1;
if (cin<4) inch[cin++]=key;
dispIn:
gotoxy(InAreaX,MROW-1);
set_att(InAreaColor);
for(i=0;i<cin;i++) {
xprintf("%c%c", dstr[h2i(inch[i])<<1], dstr[(h2i(inch[i])<<1)+1] );
}
if (cin<4) xprintf(" ");
set_att(NormalColor);
if (cin==4) {
u_char ttt[3];
ttt[3]=0;
ttt[0]=(h2i(inch[0])<<4)+h2i(inch[1]);
ttt[1]=(h2i(inch[2])<<4)+h2i(inch[3]);
sendkey_b5(ttt);
cin=0;
gotoxy(InAreaX,MROW-1);
set_att(InAreaColor);
xprintf(" ");
set_att(NormalColor);
}
return 1;
}
|