#include #include #include #include #include #include #include #include #include "msgwin.h" #include "xlocale.h" #include "fonts.h" #include "text.h" #include "tag.h" #include "parse.h" #include "timer.h" FontTable fonts[] = { { HEAD_ISO8859_1, "iso8859-1", NULL, NULL }, { HEAD_JISX0208, "jisx0208.1983-0", NULL, NULL }, { HEAD_JISX0201, "jisx0201.1976-0", NULL, NULL }, { HEAD_JISX0212, "jisx0212.1990-0", NULL, NULL }, { HEAD_ISO8859_2, "iso8859-2", NULL, NULL }, { HEAD_ISO8859_3, "iso8859-3", NULL, NULL }, { HEAD_ISO8859_4, "iso8859-4", NULL, NULL }, { HEAD_ISO8859_5, "iso8859-5", NULL, NULL }, { HEAD_ISO8859_6, "iso8859-6", NULL, NULL }, { HEAD_ISO8859_7, "iso8859-7", NULL, NULL }, { HEAD_ISO8859_8, "iso8859-8", NULL, NULL }, { HEAD_ISO8859_9, "iso8859-9", NULL, NULL }, { HEAD_KSC5601, "ksc5601.1987-0", NULL, NULL }, { 0x62310000, "viscii1.1-1", NULL, NULL }, { 0x62540000, "tis620.2529-1", NULL, NULL }, { HEAD_GB2312, "gb2312.1980-0", NULL, NULL }, { HEAD_CNS11643_1, "cns11643.1-0", NULL, NULL }, { HEAD_CNS11643_2, "cns11643.2-0", NULL, NULL }, { HEAD_UNICODE, "unicode1.1-0", NULL, NULL }, { 0, NULL, NULL, NULL, } }; struct { wchar_t head; char *foundry; char *name; } font_data[] = { { HEAD_ISO8859_1, "adobe", "times" }, { HEAD_JISX0208, NULL, "fixed" }, { HEAD_JISX0201, NULL, "fixed" }, { HEAD_JISX0212, NULL, "fixed" }, { 0, NULL, NULL } }; int main(int argc, char **argv) { Display *dpy; Window win; MessageWin *msg; FontInfoTableList fitl; FontNameTable font_name[sizeof(font_data)/sizeof(font_data[0])]; int i; int b2press = 0; int b2x, b2y; Frame *frame; mysetlocale(0); /* for my locale lib */ if (argv[1] == NULL) exit(1); if ((dpy = XOpenDisplay(NULL)) == NULL) exit(1); msg = msgwin_new(); win = msgwin_create_win(msg, dpy, RootWindow(dpy,DefaultScreen(dpy)), 600, 500, BlackPixel(dpy,DefaultScreen(dpy)), WhitePixel(dpy,DefaultScreen(dpy))); fitl = MakeFontInfoTable(dpy, fonts); for (i=0;ioff_x, msg->off_y); frame_file_open(frame, argv[1]); XMapWindow(dpy, win); while(1) { XEvent event; while (XPending(dpy) || frame->eof) { XNextEvent (dpy, &event); switch(event.type) { case Expose: frame_expose(frame, event.xexpose.x, event.xexpose.y, event.xexpose.width, event.xexpose.height); break; case ButtonPress: switch (event.xbutton.button) { case Button1: break; case Button2: b2press = 1; b2x = event.xbutton.x; b2y = event.xbutton.y; break; case Button3: frame_resize(frame, 300, 500, msg->off_x, msg->off_y); break; } break; case ButtonRelease: switch (event.xbutton.button) { case Button2: b2press = 0; break; } break; case MotionNotify: if (b2press) { int dx = b2x - event.xmotion.x; int dy = b2y - event.xmotion.y; frame_scroll(frame, dx, dy); b2x = event.xmotion.x; b2y = event.xmotion.y; } break; } } { HTMLObj *obj = frame->line_p; frame_parse(frame); while (obj->next != frame->obj) { obj = obj->next; frame_disp_obj(frame, obj); } } } }