Logo Search packages:      
Sourcecode: xcin2.3 version File versions  Download package

intcode.c

/*
      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(" iXj");
}
}

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<'8' ) return 1;
if (cin==1 && inch[0]=='F' && key=='F') return 1;
if (cin==2 && (key<'4' || (key>'7' && key<'A'))) return 1;
if (cin==3 && (inch[2]=='7'||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;
}

Generated by  Doxygen 1.6.0   Back to index