home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume4 / kterm / part03 < prev    next >
Encoding:
Text File  |  1989-05-31  |  55.2 KB  |  2,087 lines

  1. Path: uunet!island!argv
  2. From: argv@island.uu.net (Dan Heller)
  3. Newsgroups: comp.sources.x
  4. Subject: v04i012:  kterm -- Kanji (japanese) xterm, Part03/04
  5. Message-ID: <781@island.uu.net>
  6. Date: 31 May 89 06:01:48 GMT
  7. Sender: news@island.uu.net
  8. Organization: Island Graphics, Marin County, California
  9. Lines: 2075
  10. Approved: island!argv@sun.com
  11.  
  12. Submitted-by: Hiroto Kagotani <kagotani@cs.titech.ac.jp>
  13. Posting-number: Volume 4, Issue 12
  14. Archive-name: kterm/part03
  15.  
  16. diff -rc ../xterm/charproc.c ./charproc.c
  17. *** ../xterm/charproc.c    Thu May  4 20:19:22 1989
  18. --- ./charproc.c    Tue May 30 14:53:35 1989
  19. ***************
  20. *** 1,5 ****
  21. --- 1,6 ----
  22.   /*
  23.    * $XConsortium: charproc.c,v 1.64 89/01/04 13:37:50 jim Exp $
  24. +  * $Header: charproc.c,v 1.1 89/05/30 14:53:32 kagotani Rel $
  25.    */
  26.   
  27.   
  28. ***************
  29. *** 96,106 ****
  30. --- 97,118 ----
  31.   #define    XtNscrollKey        "scrollKey"
  32.   #define XtNscrollPos        "scrollPos"
  33.   #define    XtNsignalInhibit    "signalInhibit"
  34. + #ifdef    STATUSLINE    /* michael */
  35. + #define    XtNstatusLine        "statusLine"
  36. + #define    XtNstatusNormal        "statusNormal"
  37. + #endif    STATUSLINE
  38.   #define    XtNtekInhibit        "tekInhibit"
  39.   #define    XtNtekStartup        "tekStartup"
  40.   #define XtNtiteInhibit        "titeInhibit"
  41.   #define    XtNvisualBell        "visualBell"
  42.   #define XtNallowSendEvents    "allowSendEvents"
  43. + #ifdef    KANJI    /* sano */
  44. + #define    XtNkanaFont        "kanaFont"
  45. + #define    XtNkanaBoldFont        "kanaBoldFont"
  46. + #define    XtNkanjiFont        "kanjiFont"
  47. + #define    XtNkanjiBoldFont    "kanjiBoldFont"
  48. + #define    XtNkanjiMode        "kanjiMode"
  49. + #endif    KANJI
  50.   
  51.   #define XtCAlwaysHighlight    "AlwaysHighlight"
  52.   #define    XtCC132            "C132"
  53. ***************
  54. *** 125,140 ****
  55. --- 137,171 ----
  56.   #define XtCScrollPos         "ScrollPos"
  57.   #define    XtCScrollCond        "ScrollCond"
  58.   #define    XtCSignalInhibit    "SignalInhibit"
  59. + #ifdef    STATUSLINE    /* michael */
  60. + #define    XtCStatusLine        "StatusLine"
  61. + #define    XtCStatusNormal        "StatusNormal"
  62. + #endif    STATUSLINE
  63.   #define    XtCTekInhibit        "TekInhibit"
  64.   #define    XtCTekStartup        "TekStartup"
  65.   #define XtCTiteInhibit        "TiteInhibit"
  66.   #define    XtCVisualBell        "VisualBell"
  67.   #define XtCAllowSendEvents    "AllowSendEvents"
  68. + #ifdef    KANJI    /* sano */
  69. + #define    XtCKanaFont        "KanaFont"
  70. + #define    XtCKanaBoldFont        "KanaBoldFont"
  71. + #define    XtCKanjiFont        "KanjiFont"
  72. + #define    XtCKanjiBoldFont    "KanjiBoldFont"
  73. + #define    XtCKanjiMode        "KanjiMode"
  74. + #endif    KANJI
  75.   
  76. + #ifdef    KANJI    /* sano */
  77. +     /*
  78. +      * To avoid the sign-extension problem, masks lower 8 bites.
  79. +      */
  80. + #define    doinput()        (0xff & (bcnt-- > 0 ? *bptr++ : in_put()))
  81. + #else    KANJI
  82.   #define    doinput()        (bcnt-- > 0 ? *bptr++ : in_put())
  83. + #endif    KANJI
  84.   
  85.   #ifndef lint
  86.   static char rcs_id[] = "$XConsortium: charproc.c,v 1.64 89/01/04 13:37:50 jim Exp $";
  87. + static char kterm_id[] = "$Header: charproc.c,v 1.1 89/05/30 14:53:32 kagotani Rel $";
  88.   #endif    /* lint */
  89.   
  90.   static long arg;
  91. ***************
  92. *** 155,160 ****
  93. --- 186,196 ----
  94.   extern int igntable[];
  95.   extern int scrtable[];
  96.   extern int scstable[];
  97. + #ifdef    KANJI    /* sano */
  98. + extern int mbcstable[];
  99. + static char pending_char;
  100. + static int pending_bad;
  101. + #endif    KANJI
  102.   
  103.   
  104.   /* event handlers */
  105. ***************
  106. *** 316,321 ****
  107. --- 352,365 ----
  108.   {XtNsignalInhibit,XtCSignalInhibit,XtRBoolean, sizeof(Boolean),
  109.       XtOffset(XtermWidget, misc.signalInhibit),
  110.       XtRBoolean, (caddr_t) &defaultFALSE},
  111. + #ifdef    STATUSLINE    /* michael */
  112. + {XtNstatusLine, XtCStatusLine, XtRBoolean, sizeof(Boolean),
  113. +     XtOffset(XtermWidget, screen.statusline),
  114. +     XtRBoolean, (caddr_t) &defaultFALSE},
  115. + {XtNstatusNormal, XtCStatusNormal, XtRBoolean, sizeof(Boolean),
  116. +     XtOffset(XtermWidget, misc.statusnormal),
  117. +     XtRBoolean, (caddr_t) &defaultFALSE},
  118. + #endif    STATUSLINE
  119.   {XtNtekInhibit, XtCTekInhibit, XtRBoolean, sizeof(Boolean),
  120.       XtOffset(XtermWidget, misc.tekInhibit),
  121.       XtRBoolean, (caddr_t) &defaultFALSE},
  122. ***************
  123. *** 331,336 ****
  124. --- 375,398 ----
  125.   {XtNallowSendEvents, XtCAllowSendEvents, XtRBoolean, sizeof(Boolean),
  126.       XtOffset(XtermWidget, screen.allowSendEvents),
  127.       XtRBoolean, (caddr_t) &defaultFALSE}
  128. + #ifdef    KANJI    /* sano */
  129. + ,
  130. + {XtNkanaFont, XtCKanaFont, XtRString, sizeof(char *),
  131. +     XtOffset(XtermWidget, misc.f_rn),
  132. +     XtRString, DEFKANAFONT},
  133. + {XtNkanaBoldFont, XtCKanaFont, XtRString, sizeof(char *),
  134. +     XtOffset(XtermWidget, misc.f_rb),
  135. +     XtRString, DEFKANABOLDFONT},
  136. + {XtNkanjiFont, XtCKanjiFont, XtRString, sizeof(char *),
  137. +     XtOffset(XtermWidget, misc.f_kn),
  138. +     XtRString, DEFKANJIFONT},
  139. + {XtNkanjiBoldFont, XtCKanjiFont, XtRString, sizeof(char *),
  140. +     XtOffset(XtermWidget, misc.f_kb),
  141. +     XtRString, DEFKANJIBOLDFONT},
  142. + {XtNkanjiMode,  XtCKanjiMode,  XtRString,  sizeof(char *),
  143. +     XtOffset(XtermWidget, misc.k_m),
  144. +     XtRString, (caddr_t) NULL}
  145. + #endif    KANJI
  146.   };
  147.   
  148.   
  149. ***************
  150. *** 384,400 ****
  151. --- 446,626 ----
  152.       register int c;
  153.       register char *cp;
  154.       register int row, col, top, bot, scstype;
  155. + #ifdef    KANJI
  156. +     int    mbcs;
  157. +     register short  gset;
  158. +     register unsigned char *ucp;
  159. + #endif    KANJI
  160.       extern int bitset(), bitclr(), finput(), TrackMouse();
  161.   
  162.       if(setjmp(vtjmpbuf))
  163.           parsestate = groundtable;
  164. + #ifdef    KANJI    /* sano */
  165. +     pending_char = pending_bad = 0;
  166. +     for( ; ; ) {
  167. +         if ((c = doinput()) & 0x80) {    /* if MSB is on */
  168. +             if (term->flags & EUC_KANJI) {
  169. +                     /*
  170. +                      * Do processing for EUC code
  171. +                      */
  172. + #define    EKANJI(c)    (0xa1 <= c && c <= 0xfe)/* true if EUC KANJI */
  173. + #define    EKANA1(c)    (0x8e == c)        /* true if SS2 */
  174. + #define    EKANA2(c)    (0xa1 <= c && c <= 0xdf)/* true if KANA */
  175. +                 if (EKANJI(c)) {
  176. +                     *--bptr = c;
  177. +                     bcnt++;
  178. +                     top = bcnt > TEXT_BUF_SIZE ?
  179. +                         TEXT_BUF_SIZE : bcnt;
  180. +                     ucp = (unsigned char *)bptr;
  181. +                     while (top > 1 && EKANJI(*ucp)
  182. +                                && EKANJI(*(ucp + 1))) {
  183. +                         top -= 2, bcnt -= 2;
  184. +                         /*
  185. +                          * Strip off of the both MSB
  186. +                          * to convert JIS code
  187. +                          */
  188. +                         *ucp &= 0x7f; ucp++;
  189. +                         *ucp &= 0x7f; ucp++;
  190. +                     }
  191. +                     dotext(screen, term->flags, MBCS|'B',
  192. +                         bptr, ucp);
  193. +                     bptr = (char *)ucp;
  194. +                     if (top > 1 && EKANJI(*ucp) &&
  195. +                              !EKANJI(*(ucp + 1))) {
  196. +                          doinput();
  197. +                     } else if (1 == top && EKANJI(*ucp) &&
  198. +                             1 == bcnt) {
  199. +                         pending_char = doinput();
  200. +                     }
  201. +                     continue;
  202. +                 } else if (EKANA1(c)) {
  203. +                     if (0 != bcnt) {
  204. +                         if (EKANA2((unsigned char)*bptr)) {
  205. +                             dotext(screen, term->flags, 'I', bptr, (bptr + 1));
  206. +                             doinput();
  207. +                         }
  208. +                     } else {
  209. +                         pending_char = c;
  210. +                     }
  211. +                     continue;
  212. +                 }
  213. +             } else if (term->flags & SJIS_KANJI) {
  214. +                 /*
  215. +                  * Do processing for Shift-JIS Kanji code
  216. +                  */
  217. + #define SJIS1(c) (0x81 <= c && c <= 0x9f) || (0xe0 <= c && c <= 0xef)
  218. +         /* SJIS1 is according to the range of 1st byte in Shift JIS */
  219. + #define SJIS2(c) (0x40 <= c && c <= 0xfc && c != 0x7f)
  220. +         /* SJIS2 is according to the range of 2nd byte in Shift JIS */
  221. + #define SJISK(c) (0xa1 <= c && c <= 0xdf)
  222. +         /* SJISK is according to the range of KANA (only one byte,
  223. +            the width is the same of ascii char (half of Kanji)) */
  224. +                 if (SJIS1(c)) {
  225. +                     *--bptr = c;
  226. +                     bcnt++;
  227. +                     top = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt;
  228. +                     ucp = (unsigned char *)bptr;
  229. +                     while (top > 1 && SJIS1(*ucp) && SJIS2(*(ucp + 1))) {
  230. +                         top -= 2, bcnt -= 2;
  231. +                         /*
  232. +                          * Do code conversion.
  233. +                          * It is quite complicated....
  234. +                          */
  235. +                         *ucp = (*ucp - ((*ucp <= 0x9f) ? 0x81 : 0xc1)) * 2 + 0x21;
  236. +                         ucp++;
  237. +                         if (*ucp <= 0x7e) {
  238. +                             *ucp -= 0x1f;
  239. +                         } else if (*ucp <= 0x9e) {
  240. +                             *ucp -= 0x20;
  241. +                         } else {
  242. +                             *ucp -= 0x7e;
  243. +                             *(ucp - 1) += 1;
  244. +                         }
  245. +                         ucp++;
  246. +                     }
  247. +                     dotext(screen, term->flags, MBCS|'B',
  248. +                         bptr, ucp);
  249. +                     bptr = (char *)ucp;
  250. +                     if (top > 1 && SJIS1(*ucp)
  251. +                             && !SJIS2(*(ucp + 1))) {
  252. +                         doinput();
  253. +                     } else if (1 == top && SJIS1(*ucp)
  254. +                                 && 1 == bcnt) {
  255. +                         pending_char = doinput();
  256. +                     }
  257. +                     continue;
  258. +                 } else if (SJISK(c)) {
  259. +                     top = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt;
  260. +                     cp = bptr;
  261. +                     *--bptr = c;
  262. +                     while (top > 0 &&
  263. +                         SJISK((unsigned char)*cp)) {
  264. +                         top--, bcnt--, cp++;
  265. +                     }
  266. +                     dotext(screen, term->flags, 'I', bptr, cp);
  267. +                     bptr = cp;
  268. +                     continue;
  269. +                 }
  270. +             }
  271. +             /*
  272. +              * If kanji code is JIS, then no processing is required
  273. +              * here. The preceeding escape sequence will turn on/off
  274. +              * the MBCS flags when dotext() is called.
  275. +              */
  276. +         }
  277. +         switch(parsestate[c &= CHAR]) {
  278. + #else    KANJI
  279.       for( ; ; )
  280.           switch(parsestate[c = doinput()]) {
  281. + #endif
  282.            case CASE_PRINT:
  283.               /* printable characters */
  284.               top = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt;
  285.               cp = bptr;
  286.               *--bptr = c;
  287. + #ifdef    KANJI    /* sano */
  288. +             if(screen->curss) {
  289. +                 dotext(screen, term->flags,
  290. +                  screen->gsets[screen->curss], bptr, bptr + 1) ;
  291. +                 screen->curss = 0;
  292. +                 bptr++;
  293. +                 c = *bptr & 0xff;
  294. +             }
  295. +             if ((gset = screen->gsets[screen->curgl]) & MBCS) {
  296. +                 if (' ' == c) {
  297. +                     gset &= ~MBCS;
  298. +                     while (top > 0 &&
  299. +                         ' ' == (unsigned char)*cp) {
  300. +                         top--; bcnt--; cp++;
  301. +                     }
  302. +                 } else {
  303. +                     while (top > 0 && 0x20 < *cp &&
  304. +                         *cp < 0x7f) {
  305. +                         top--; bcnt--; cp++;
  306. +                     }
  307. +                     if ((cp - bptr) & 1) {
  308. +                         --cp;
  309. +                         if (top == 0) {
  310. +                             if (bcnt == 0)
  311. +                                 pending_char = *cp;
  312. +                             else
  313. +                                 bcnt++;
  314. +                         } else
  315. +                             pending_bad = 1;
  316. +                     }
  317. +                 }
  318. +             } else
  319. +                 while (top > 0 && isprint((unsigned char)*cp)) {
  320. +                     top--; bcnt--; cp++;
  321. +             }
  322. +             if (bptr < cp)
  323. +                 dotext(screen, term->flags, gset, bptr, cp);
  324. +             bptr = cp;
  325. +             if (pending_bad) {
  326. +                 pending_bad = 0;
  327. +                 bptr++;
  328. +             }
  329. + #else    KANJI
  330.               while(top > 0 && isprint(*cp)) {
  331.                   top--;
  332.                   bcnt--;
  333. ***************
  334. *** 410,415 ****
  335. --- 636,642 ----
  336.                   dotext(screen, term->flags,
  337.                    screen->gsets[screen->curgl], bptr, cp);
  338.               bptr = cp;
  339. + #endif    KANJI
  340.               break;
  341.   
  342.            case CASE_GROUND_STATE:
  343. ***************
  344. *** 455,460 ****
  345. --- 682,690 ----
  346.               /*
  347.                * form feed, line feed, vertical tab
  348.                */
  349. + #ifdef    STATUSLINE    /* michael */
  350. +             if (!screen->instatus)
  351. + #endif    STATUSLINE
  352.               Index(screen, 1);
  353.               if (term->flags & LINEFEED)
  354.                   CarriageReturn(screen);
  355. ***************
  356. *** 507,512 ****
  357. --- 737,751 ----
  358.               parsestate = scstable;
  359.               break;
  360.   
  361. + #ifdef    KANJI    /* kagotani */
  362. +          case CASE_MBCS:
  363. +             /* enter smbcs mbcsesc */
  364. +             mbcs = 1;
  365. +             scstype = 0;
  366. +             parsestate = mbcstable;
  367. +             break;
  368. + #endif    KANJI
  369.            case CASE_ESC_IGNORE:
  370.               /* unknown escape sequence */
  371.               parsestate = eigtable;
  372. ***************
  373. *** 539,555 ****
  374. --- 778,808 ----
  375.   
  376.            case CASE_CUU:
  377.               /* CUU */
  378. + #ifdef    STATUSLINE    /* michael */
  379. +             /* only if not in status line */
  380. +             if (!screen->instatus) {
  381. + #endif    STATUSLINE
  382.               if((c = param[0]) < 1)
  383.                   c = 1;
  384.               CursorUp(screen, c);
  385. + #ifdef    STATUSLINE    /* michael */
  386. +             }
  387. + #endif    STATUSLINE
  388.               parsestate = groundtable;
  389.               break;
  390.   
  391.            case CASE_CUD:
  392.               /* CUD */
  393. + #ifdef    STATUSLINE    /* michael */
  394. +             /* only if not in status line */
  395. +             if (!screen->instatus) {
  396. + #endif    STATUSLINE
  397.               if((c = param[0]) < 1)
  398.                   c = 1;
  399.               CursorDown(screen, c);
  400. + #ifdef    STATUSLINE    /* michael */
  401. +             }
  402. + #endif    STATUSLINE
  403.               parsestate = groundtable;
  404.               break;
  405.   
  406. ***************
  407. *** 571,581 ****
  408. --- 824,841 ----
  409.   
  410.            case CASE_CUP:
  411.               /* CUP | HVP */
  412. + #ifdef    STATUSLINE    /* michael */
  413. +             /* only if not in status line */
  414. +             if (!screen->instatus) {
  415. + #endif    STATUSLINE
  416.               if((row = param[0]) < 1)
  417.                   row = 1;
  418.               if(nparam < 2 || (col = param[1]) < 1)
  419.                   col = 1;
  420.               CursorSet(screen, row-1, col-1, term->flags);
  421. + #ifdef    STATUSLINE    /* michael */
  422. +             }
  423. + #endif    STATUSLINE
  424.               parsestate = groundtable;
  425.               break;
  426.   
  427. ***************
  428. *** 584,597 ****
  429. --- 844,872 ----
  430.               switch (param[0]) {
  431.                case DEFAULT:
  432.                case 0:
  433. + #ifdef    STATUSLINE    /* michael */
  434. +                 if (screen->instatus)
  435. +                     ClearRight(screen);
  436. +                 else
  437. + #endif    STATUSLINE
  438.                   ClearBelow(screen);
  439.                   break;
  440.   
  441.                case 1:
  442. + #ifdef    STATUSLINE    /* michael */
  443. +                 if (screen->instatus)
  444. +                     ClearLeft(screen);
  445. +                 else
  446. + #endif    STATUSLINE
  447.                   ClearAbove(screen);
  448.                   break;
  449.   
  450.                case 2:
  451. + #ifdef    STATUSLINE    /* michael */
  452. +                 if (screen->instatus)
  453. +                     ClearLine(screen);
  454. +                 else
  455. + #endif    STATUSLINE
  456.                   ClearScreen(screen);
  457.                   break;
  458.               }
  459. ***************
  460. *** 617,633 ****
  461. --- 892,922 ----
  462.   
  463.            case CASE_IL:
  464.               /* IL */
  465. + #ifdef    STATUSLINE    /* michael */
  466. +             /* only if not in status line */
  467. +             if (!screen->instatus) {
  468. + #endif    STATUSLINE
  469.               if((c = param[0]) < 1)
  470.                   c = 1;
  471.               InsertLine(screen, c);
  472. + #ifdef    STATUSLINE    /* michael */
  473. +             }
  474. + #endif    STATUSLINE
  475.               parsestate = groundtable;
  476.               break;
  477.   
  478.            case CASE_DL:
  479.               /* DL */
  480. + #ifdef    STATUSLINE    /* michael */
  481. +             /* only if not in status line */
  482. +             if (!screen->instatus) {
  483. + #endif    STATUSLINE
  484.               if((c = param[0]) < 1)
  485.                   c = 1;
  486.               DeleteLine(screen, c);
  487. + #ifdef    STATUSLINE    /* michael */
  488. +             }
  489. + #endif    STATUSLINE
  490.               parsestate = groundtable;
  491.               break;
  492.   
  493. ***************
  494. *** 732,737 ****
  495. --- 1021,1030 ----
  496.   
  497.            case CASE_DECSTBM:
  498.               /* DECSTBM */
  499. + #ifdef    STATUSLINE    /* michael */
  500. +             /* only if not in status line */
  501. +             if (!screen->instatus) {
  502. + #endif    STATUSLINE
  503.               if((top = param[0]) < 1)
  504.                   top = 1;
  505.               if(nparam < 2 || (bot = param[1]) == DEFAULT
  506. ***************
  507. *** 745,750 ****
  508. --- 1038,1046 ----
  509.                   screen->bot_marg = bot-1;
  510.                   CursorSet(screen, 0, 0, term->flags);
  511.               }
  512. + #ifdef    STATUSLINE    /* michael */
  513. +             }
  514. + #endif    STATUSLINE
  515.               parsestate = groundtable;
  516.               break;
  517.   
  518. ***************
  519. *** 800,805 ****
  520. --- 1096,1107 ----
  521.               break;
  522.   
  523.            case CASE_GSETS:
  524. + #ifdef    KANJI    /* sano & kagotani */
  525. +             if (mbcs) {
  526. +                 c |= MBCS;
  527. +                 mbcs = 0;
  528. +             }
  529. + #endif    KANJI
  530.               screen->gsets[scstype] = c;
  531.               parsestate = groundtable;
  532.               break;
  533. ***************
  534. *** 830,835 ****
  535. --- 1132,1141 ----
  536.   
  537.            case CASE_IND:
  538.               /* IND */
  539. + #ifdef    STATUSLINE    /* michael */
  540. +             /* only if not in status line */
  541. +             if (!screen->instatus)
  542. + #endif    STATUSLINE
  543.               Index(screen, 1);
  544.               if(screen->display->qlen > 0 ||
  545.                (ioctl(screen->display->fd, FIONREAD, (char *)&arg), arg) > 0)
  546. ***************
  547. *** 839,844 ****
  548. --- 1145,1154 ----
  549.   
  550.            case CASE_NEL:
  551.               /* NEL */
  552. + #ifdef    STATUSLINE    /* michael */
  553. +             /* only if not in status line */
  554. +             if (!screen->instatus)
  555. + #endif    STATUSLINE
  556.               Index(screen, 1);
  557.               CarriageReturn(screen);
  558.               if(screen->display->qlen > 0 ||
  559. ***************
  560. *** 855,860 ****
  561. --- 1165,1174 ----
  562.   
  563.            case CASE_RI:
  564.               /* RI */
  565. + #ifdef    STATUSLINE    /* michael */
  566. +             /* only if not in status line */
  567. +             if (!screen->instatus)
  568. + #endif    STATUSLINE
  569.               RevIndex(screen, 1);
  570.               parsestate = groundtable;
  571.               break;
  572. ***************
  573. *** 920,925 ****
  574. --- 1234,1268 ----
  575.               parsestate = groundtable;
  576.               break;
  577.   
  578. + #ifdef    STATUSLINE    /* michael */
  579. +          case CASE_TO_STATUS:
  580. +             if ((c = param[0]) < 1)
  581. +                 c = 1;
  582. +             ToStatus(c - 1);
  583. +             parsestate = groundtable;
  584. +             break ;
  585. +          case CASE_FROM_STATUS:
  586. +             FromStatus();
  587. +             parsestate = groundtable;
  588. +             break ;
  589. +          case CASE_SHOW_STATUS:
  590. +             ShowStatus();
  591. +             parsestate = groundtable;
  592. +             break ;
  593. +          case CASE_HIDE_STATUS:
  594. +             HideStatus();
  595. +             parsestate = groundtable;
  596. +             break ;
  597. +          case CASE_ERASE_STATUS:
  598. +             EraseStatus();
  599. +             parsestate = groundtable;
  600. +             break ;
  601. + #endif    STATUSLINE
  602.            case CASE_XTERM_SAVE:
  603.               savemodes(term);
  604.               parsestate = groundtable;
  605. ***************
  606. *** 930,935 ****
  607. --- 1273,1281 ----
  608.               parsestate = groundtable;
  609.               break;
  610.           }
  611. + #ifdef    KANJI    /* sano */
  612. +     }
  613. + #endif    KANJI
  614.   }
  615.   
  616.   finput()
  617. ***************
  618. *** 1031,1038 ****
  619. --- 1377,1392 ----
  620.           if((select_mask & pty_mask) && (eventMode == NORMAL)) {
  621.               if(screen->logging)
  622.                   FlushLog(screen);
  623. + #ifdef    KANJI    /* sano */
  624. +             /*
  625. +              * buffer[0] is reserved for the pending_char.
  626. +              */
  627. +             if((bcnt = read(screen->respond, bptr = &buffer[1],
  628. +              BUF_SIZE)) < 0) {
  629. + #else    KANJI
  630.               if((bcnt = read(screen->respond, bptr = buffer,
  631.                BUF_SIZE)) < 0) {
  632. + #endif    KANJI
  633.                   if(errno == EIO)
  634.                       Cleanup (0);
  635.                   else if(errno != EWOULDBLOCK)
  636. ***************
  637. *** 1042,1050 ****
  638. --- 1396,1416 ----
  639.               } else if(bcnt == 0)
  640.                   Panic("input: read returned zero\n", 0);
  641.               else {
  642. + #ifdef    KANJI    /* sano */
  643. +                 if (pending_char) {
  644. +                     /*
  645. +                      * restore pending_char to the top of
  646. +                      * the text which just read.
  647. +                      */
  648. +                     *--bptr = pending_char;
  649. +                     bcnt++;
  650. +                     pending_char = 0;
  651. +                 }
  652. + #else    KANJI
  653.                   /* strip parity bit */
  654.                   for(i = bcnt, cp = bptr ; i > 0 ; i--)
  655.                       *cp++ &= CHAR;
  656. + #endif    KANJI
  657.                   if(screen->scrollWidget && screen->scrollinput &&
  658.                    screen->topline < 0)
  659.                       /* Scroll to bottom */
  660. ***************
  661. *** 1119,1125 ****
  662. --- 1485,1495 ----
  663.   dotext(screen, flags, charset, buf, ptr)
  664.   register TScreen    *screen;
  665.   unsigned    flags;
  666. + #ifdef    KANJI    /* sano */
  667. + short        charset;
  668. + #else    KANJI
  669.   char        charset;
  670. + #endif    KANJI
  671.   char    *buf;
  672.   char    *ptr;
  673.   {
  674. ***************
  675. *** 1127,1132 ****
  676. --- 1497,1505 ----
  677.       register int    len;
  678.       register int    n;
  679.       register int    next_col;
  680. + #ifdef    KANJI    /* sano */
  681. +     register int    do_wrap = 0;
  682. + #endif    KANJI
  683.   
  684.       switch (charset) {
  685.       case 'A':    /* United Kingdom set            */
  686. ***************
  687. *** 1136,1141 ****
  688. --- 1509,1526 ----
  689.           break;
  690.   
  691.       case 'B':    /* ASCII set                */
  692. + #ifdef    KANJI    /* sano */
  693. +         /*
  694. +          * 'H' should be removed here because it is *not*
  695. +          * ascii but Swedish character set. Some Kanji text
  696. +          * still includes ESC-(-H, which does not designate
  697. +          * Romaji nor ascii character set. This is due to
  698. +          * the mis-printing of early JIS documentation.
  699. +          */
  700. +     case 'J':
  701. +     case 'H':
  702. +     case '@':
  703. + #endif    KANJI
  704.           break;
  705.   
  706.       case '0':    /* special graphics (line drawing)    */
  707. ***************
  708. *** 1144,1149 ****
  709. --- 1529,1549 ----
  710.                   *s = *s == 0x5f ? 0x7f : *s - 0x5f;
  711.           break;
  712.   
  713. + #ifdef    KANJI    /* sano */
  714. +     case 'I':
  715. +         flags |= KANACS;
  716. +         for (s = buf; s < ptr; ++s)
  717. +             *s &= 0x7f;
  718. +         break;
  719. +         /*
  720. +          * ESC-$-(-@ and ESC-$-(-B designate the Kanji character set.
  721. +          * set KCS flags...
  722. +          */
  723. +     case MBCS|'@':
  724. +     case MBCS|'B':
  725. +         flags |= KCS;
  726. +         break;
  727. + #endif
  728.       default:    /* any character sets we don't recognize*/
  729.           return;
  730.       }
  731. ***************
  732. *** 1153,1159 ****
  733. --- 1553,1564 ----
  734.       while (len > 0) {
  735.           n = screen->max_col-screen->cur_col+1;
  736.           if (n <= 1) {
  737. + #ifdef    STATUSLINE    /* michael */
  738. +             if (screen->do_wrap && (flags&WRAPAROUND) &&
  739. +                 !screen->instatus) {
  740. + #else    STATUSLINE
  741.               if (screen->do_wrap && (flags&WRAPAROUND)) {
  742. + #endif    STATUSLINE
  743.                   Index(screen, 1);
  744.                   screen->cur_col = 0;
  745.                   screen->do_wrap = 0;
  746. ***************
  747. *** 1163,1168 ****
  748. --- 1568,1585 ----
  749.           }
  750.           if (len < n)
  751.               n = len;
  752. + #ifdef    KANJI
  753. +         if (flags & KCS) {
  754. +             if (n == 1) {
  755. +                 if (flags & WRAPAROUND) {
  756. +                     n--; do_wrap = 1;
  757. +                 } else
  758. +                     n++;
  759. +             } else
  760. +                 if (n & 1)
  761. +                     n--;
  762. +         }
  763. + #endif
  764.           next_col = screen->cur_col + n;
  765.           WriteText(screen, ptr, n, flags);
  766.           /*
  767. ***************
  768. *** 1170,1176 ****
  769. --- 1587,1597 ----
  770.            * If screen->cur_col != next_col, we must have
  771.            * hit the right margin, so set the do_wrap flag.
  772.            */
  773. + #ifdef    KANJI    /* sano */
  774. +         screen->do_wrap = (screen->cur_col < next_col) | do_wrap;
  775. + #else    KANJI
  776.           screen->do_wrap = (screen->cur_col < next_col);
  777. + #endif    KANJI
  778.           len -= n;
  779.           ptr += n;
  780.       }
  781. ***************
  782. *** 1190,1196 ****
  783. --- 1611,1624 ----
  784.       register unsigned fgs = flags;
  785.       GC    currentGC;
  786.    
  787. + #ifdef    STATUSLINE    /* michael */
  788. +    if(screen->instatus && screen->reversestatus)
  789. +     fgs ^= INVERSE;
  790. +    if(screen->cur_row - screen->topline <= screen->max_row ||
  791. +       screen->instatus) {
  792. + #else    STATUSLINE
  793.      if(screen->cur_row - screen->topline <= screen->max_row) {
  794. + #endif    STATUSLINE
  795.       /*
  796.       if(screen->cur_row == screen->cursor_row && screen->cur_col <=
  797.        screen->cursor_col && screen->cursor_col <= screen->cur_col + len - 1)
  798. ***************
  799. *** 1203,1208 ****
  800. --- 1631,1667 ----
  801.        *    make sure that the correct GC is current
  802.        */
  803.   
  804. + #ifdef    KANJI    /* sano */
  805. +     if (fgs & KCS) {    /* kanji */
  806. +         if (fgs & BOLD) {
  807. +             if (fgs & INVERSE) {
  808. +                 currentGC = screen->w_reverseboldGC;
  809. +             } else {
  810. +                 currentGC = screen->w_normalboldGC;
  811. +             }
  812. +         } else {
  813. +             if (fgs & INVERSE) {
  814. +                 currentGC = screen->w_reverseGC;
  815. +             } else {
  816. +                 currentGC = screen->w_normalGC;
  817. +             }
  818. +         }
  819. +     } else if (fgs & KANACS) {    /* kana */
  820. +         if (fgs & BOLD) {
  821. +             if (fgs & INVERSE) {
  822. +                 currentGC = screen->r_reverseboldGC;
  823. +             } else {
  824. +                 currentGC = screen->r_normalboldGC;
  825. +             }
  826. +         } else {
  827. +             if (fgs & INVERSE) {
  828. +                 currentGC = screen->r_reverseGC;
  829. +             } else {
  830. +                 currentGC = screen->r_normalGC;
  831. +             }
  832. +         }
  833. +     } else
  834. + #endif    KANJI
  835.       if (fgs & BOLD)
  836.           if (fgs & INVERSE)
  837.               currentGC = screen->reverseboldGC;
  838. ***************
  839. *** 1219,1231 ****
  840.               FlushScroll(screen);
  841.       cx = CursorX(screen, screen->cur_col);
  842.       cy = CursorY(screen, screen->cur_row)+screen->fnt_norm->ascent;
  843.        XDrawImageString(screen->display, TextWindow(screen), currentGC,
  844.               cx, cy, str, len);
  845.   
  846.       if((fgs & BOLD) && screen->enbolden) 
  847. !         if (currentGC == screen->normalGC || screen->reverseGC)
  848.               XDrawString(screen->display, TextWindow(screen),
  849.                         currentGC,cx + 1, cy, str, len);
  850.   
  851.       if(fgs & UNDERLINE) 
  852.           XDrawLine(screen->display, TextWindow(screen), currentGC,
  853. --- 1678,1727 ----
  854.               FlushScroll(screen);
  855.       cx = CursorX(screen, screen->cur_col);
  856.       cy = CursorY(screen, screen->cur_row)+screen->fnt_norm->ascent;
  857. + #ifdef    KANJI    /* sano & michael */
  858. +     if (fgs & KCS) {
  859. +         /*
  860. +          * Draw Kanji string with currentGC. If no k_boldGC nor
  861. +          * k_reverseboldGC, then overstrike it.
  862. +          */
  863. +         XDrawImageString16(screen->display, TextWindow(screen),
  864. +             currentGC, cx, cy, (XChar2b *)str, len / 2);
  865. +         if ((fgs & BOLD) && screen->w_enbolden)
  866. +             if (currentGC == screen->w_normalGC ||
  867. +                 currentGC == screen->w_reverseGC)
  868. +                 XDrawString16(screen->display, 
  869. +                     TextWindow(screen), currentGC,
  870. +                     cx + 1, cy, (XChar2b *)str, len / 2);
  871. +     } else if (fgs & KANACS) {
  872. +         /*
  873. +          * Draw Kanji string with currentGC. If no k_boldGC nor
  874. +          * k_reverseboldGC, then overstrike it.
  875. +          */
  876. +         XDrawImageString(screen->display, TextWindow(screen),
  877. +             currentGC, cx, cy, str, len);
  878. +         if ((fgs & BOLD) && screen->r_enbolden)
  879. +             if (currentGC == screen->r_normalGC ||
  880. +                 currentGC == screen->r_reverseGC)
  881. +                 XDrawString(screen->display, 
  882. +                     TextWindow(screen), currentGC,
  883. +                     cx + 1, cy, str, len);
  884. +     } else {
  885. + #endif    KANJI
  886.        XDrawImageString(screen->display, TextWindow(screen), currentGC,
  887.               cx, cy, str, len);
  888.   
  889.       if((fgs & BOLD) && screen->enbolden) 
  890. ! /*
  891. !  * Bug fix by michael
  892. !  * original:    if (currentGC == screen->normalGC || screen->reverseGC) 
  893. !  */
  894. !         if (currentGC == screen->normalGC ||
  895. !             currentGC == screen->reverseGC)
  896.               XDrawString(screen->display, TextWindow(screen),
  897.                         currentGC,cx + 1, cy, str, len);
  898. + #ifdef    KANJI    /* sano */
  899. +     }
  900. + #endif    KANJI
  901.   
  902.       if(fgs & UNDERLINE) 
  903.           XDrawLine(screen->display, TextWindow(screen), currentGC,
  904. ***************
  905. *** 1309,1314 ****
  906. --- 1805,1813 ----
  907.                           + screen->scrollbar,
  908.                           (Dimension) FontHeight(screen)
  909.                           * (screen->max_row + 1)
  910. + #ifdef    STATUSLINE    /* michael */
  911. +                         + screen->statusheight
  912. + #endif    STATUSLINE
  913.                           + 2 * screen->border,
  914.                           &replyWidth, &replyHeight);
  915.   
  916. ***************
  917. *** 1399,1404 ****
  918. --- 1898,1912 ----
  919.               else
  920.                   FromAlternate(screen);
  921.               break;
  922. + #ifdef    STATUSLINE    /* michael */
  923. +         case 48:
  924. +             j = screen->reversestatus;
  925. +             (*func)(&screen->reversestatus, 1);
  926. +             if (j != screen->reversestatus)
  927. +                 ScrnRefresh(screen, screen->max_row + 1, 0, 1,
  928. +                     screen->max_col + 1);
  929. +             break;
  930. + #endif    STATUSLINE
  931.           case 1000:        /* xtem bogus sequence        */
  932.               if(func == bitset)
  933.                   screen->send_mouse_pos = 2;
  934. ***************
  935. *** 1474,1479 ****
  936. --- 1982,1992 ----
  937.           case 47:        /* alternate buffer        */
  938.               screen->save_modes[15] = screen->alternate;
  939.               break;
  940. + #ifdef    STATUSLINE    /* michael */
  941. +         case 48:
  942. +             screen->save_modes[16] = screen->reversestatus;
  943. +             break;
  944. + #endif    STATUSLINE
  945.           case 1000:        /* mouse bogus sequence        */
  946.           case 1001:
  947.               screen->save_modes[7] = screen->send_mouse_pos;
  948. ***************
  949. *** 1514,1519 ****
  950. --- 2027,2035 ----
  951.                           + screen->scrollbar,
  952.                           (Dimension) FontHeight(screen)
  953.                           * (screen->max_row + 1)
  954. + #ifdef    STATUSLINE    /* michael */
  955. +                         + screen->statusheight
  956. + #endif    STATUSLINE
  957.                           + 2*screen->border,
  958.                           &replyWidth, &replyHeight);
  959.   
  960. ***************
  961. *** 1601,1606 ****
  962. --- 2117,2131 ----
  963.               else
  964.                   FromAlternate(screen);
  965.               break;
  966. + #ifdef    STATUSLINE    /* michael */
  967. +         case 48:        /* reverse status line */
  968. +             if (screen->save_modes[16] != screen->reversestatus) {
  969. +                 screen->reversestatus = screen->save_modes[16];
  970. +                 ScrnRefresh(screen, screen->max_row + 1, 0, 1,
  971. +                         screen->max_col + 1);
  972. +             }
  973. +             break;
  974. + #endif    STATUSLINE
  975.           case 1000:        /* mouse bogus sequence        */
  976.           case 1001:
  977.               screen->send_mouse_pos = screen->save_modes[7];
  978. ***************
  979. *** 1695,1702 ****
  980. --- 2220,2232 ----
  981.       if(screen->alternate)
  982.           return;
  983.       if(!screen->altbuf)
  984. + #ifdef    STATUSLINE    /* michael */
  985. +         screen->altbuf = Allocate(screen->max_row + 2, screen->max_col
  986. +          + 1);
  987. + #else    STATUSLINE
  988.           screen->altbuf = Allocate(screen->max_row + 1, screen->max_col
  989.            + 1);
  990. + #endif    STATUSLINE
  991.       SwitchBufs(screen);
  992.       screen->alternate = TRUE;
  993.   }
  994. ***************
  995. *** 1727,1733 ****
  996. --- 2257,2267 ----
  997.       if((top = -screen->topline) <= screen->max_row) {
  998.           if(screen->scroll_amt)
  999.               FlushScroll(screen);
  1000. + #ifdef    STATUSLINE    /* michael */
  1001. +         if(top == 0 && !screen->statusline)
  1002. + #else    STATUSLINE
  1003.           if(top == 0)
  1004. + #endif    STATUSLINE
  1005.               XClearWindow(screen->display, TextWindow(screen));
  1006.           else
  1007.               XClearArea(
  1008. ***************
  1009. *** 1846,1852 ****
  1010. --- 2380,2397 ----
  1011.   Widget w;
  1012.   {
  1013.          if (XtIsRealized(w))
  1014. + #ifdef    STATUSLINE    /* kato */
  1015. +     {
  1016.             ScreenResize (&term->screen, term->core.width, term->core.height, &term->flags);
  1017. +       XClearWindow(term->screen.display, term->screen.fullVwin.window);
  1018. +       ScrnRefresh(&term->screen, 0, 0,
  1019. +         term->screen.max_row,
  1020. +         term->screen.max_col);
  1021. +     }
  1022. + #else    STATUSLINE
  1023. +           ScreenResize (&term->screen, term->core.width, term->core.height, &term->flags);
  1024. + #endif    STATUSLINE
  1025.   }
  1026.   
  1027.   static Boolean failed = FALSE;
  1028. ***************
  1029. *** 1909,1914 ****
  1030. --- 2454,2463 ----
  1031.      new->screen.always_highlight = request->screen.always_highlight;
  1032.      new->screen.pointer_cursor = request->screen.pointer_cursor;
  1033.      new->misc.titeInhibit = request->misc.titeInhibit;
  1034. + #ifdef    STATUSLINE    /* kato */
  1035. +    new->screen.statusline = request->screen.statusline;
  1036. +    new->screen.reversestatus = request->screen.reversestatus;
  1037. + #endif    STATUSLINE
  1038.   
  1039.       /*
  1040.        * set the colors if reverse video; this is somewhat tricky since
  1041. ***************
  1042. *** 1993,1998 ****
  1043. --- 2542,2551 ----
  1044.       
  1045.       TabReset (term->tabs);
  1046.   
  1047. + #ifdef    KANJI    /* sano */
  1048. +     screen->fnt_r_norm = screen->fnt_r_bold =
  1049. +     screen->fnt_w_norm = screen->fnt_w_bold =
  1050. + #endif    KANJI
  1051.       screen->fnt_norm = screen->fnt_bold = NULL;
  1052.       
  1053.       /* do the XFont calls */
  1054. ***************
  1055. *** 2014,2020 ****
  1056. --- 2567,2596 ----
  1057.           screen->fnt_bold = screen->fnt_norm;
  1058.           screen->enbolden = TRUE;  /*no bold font */
  1059.       }
  1060. + #ifdef    KANJI    /* sano */
  1061. +     if (!term->misc.f_rn ||
  1062. +         !(screen->fnt_r_norm =
  1063. +             XLoadQueryFont(screen->display, term->misc.f_rn)))
  1064. +         screen->fnt_r_norm = screen->fnt_norm;
  1065. +     if (!term->misc.f_rb ||
  1066. +         !(screen->fnt_r_bold =
  1067. +             XLoadQueryFont(screen->display, term->misc.f_rb))) {
  1068. +         screen->fnt_r_bold = screen->fnt_r_norm;
  1069. +         screen->r_enbolden = TRUE;    /* no bold font */
  1070. +     }
  1071.   
  1072. +     if (!term->misc.f_kn ||
  1073. +         !(screen->fnt_w_norm =
  1074. +             XLoadQueryFont(screen->display, term->misc.f_kn)))
  1075. +         screen->fnt_w_norm = screen->fnt_norm;
  1076. +     if (!term->misc.f_kb ||
  1077. +         !(screen->fnt_w_bold =
  1078. +             XLoadQueryFont(screen->display, term->misc.f_kb))) {
  1079. +         screen->fnt_w_bold = screen->fnt_w_norm;
  1080. +         screen->w_enbolden = TRUE;    /* no bold font */
  1081. +     }
  1082. + #endif    KANJI
  1083.       /* find the max width and higth of the font */
  1084.   
  1085.       screen->fullVwin.f_width = screen->fnt_norm->max_bounds.width;
  1086. ***************
  1087. *** 2042,2051 ****
  1088. --- 2618,2635 ----
  1089.                  screen->scrollWidget->core.width : 0);
  1090.       i = 2 * screen->border + scrollbar_width;
  1091.       j = 2 * screen->border;
  1092. + #ifdef    STATUSLINE    /* michael */
  1093. +     if (screen->statusline)
  1094. +         j += (screen->statusheight = screen->fullVwin.f_height + 2);
  1095. + #endif    STATUSLINE
  1096.   
  1097.   
  1098.       /* set defaults */
  1099. + #ifdef    KANJI    /* ishisone */
  1100. +     xpos = 0; ypos = 0; width = 80; height = 24;
  1101. + #else    /* KANJI */
  1102.       xpos = 1; ypos = 1; width = 80; height = 24;
  1103. + #endif    /* KANJI */
  1104.   
  1105.       pr = XParseGeometry(term->misc.geo_metry, &xpos, &ypos, &width, &height);
  1106.   
  1107. ***************
  1108. *** 2064,2069 ****
  1109. --- 2648,2656 ----
  1110.       /* set up size hints for window manager */
  1111.       sizehints.min_width = 2 * screen->border + scrollbar_width;
  1112.       sizehints.min_height = 2 * screen->border;
  1113. + #ifdef    STATUSLINE    /* ishisone */
  1114. +     sizehints.min_height += screen->statusheight;
  1115. + #endif
  1116.       sizehints.width_inc = FontWidth(screen);
  1117.       sizehints.height_inc = FontHeight(screen);
  1118.       sizehints.flags = PMinSize|PResizeInc;
  1119. ***************
  1120. *** 2101,2107 ****
  1121. --- 2688,2698 ----
  1122.       if (term->misc.re_verse && (term->core.border_pixel == term->core.background_pixel))
  1123.           values->border_pixel = term->core.border_pixel = term->screen.foreground;
  1124.       
  1125. + #ifdef STATUSLINE
  1126. +     values->bit_gravity = ForgetGravity;
  1127. + #else
  1128.       values->bit_gravity = NorthWestGravity;
  1129. + #endif
  1130.       term->screen.fullVwin.window = term->core.window =
  1131.         XCreateWindow(XtDisplay(term), XtWindow(term->core.parent),
  1132.           term->core.x, term->core.y,
  1133. ***************
  1134. *** 2122,2127 ****
  1135. --- 2713,2732 ----
  1136.       xgcv.background = term->core.background_pixel;
  1137.   
  1138.       screen->normalGC = XtGetGC((Widget)term, mask, &xgcv);
  1139. + #ifdef    KANJI    /* sano */
  1140. +     if (screen->fnt_r_norm == screen->fnt_norm) {
  1141. +         screen->r_normalGC = screen->normalGC;
  1142. +     } else {
  1143. +         xgcv.font = screen->fnt_r_norm->fid;
  1144. +         screen->r_normalGC = XtGetGC((Widget)term, mask, &xgcv) ;
  1145. +     }
  1146. +     if (screen->fnt_w_norm == screen->fnt_norm) {
  1147. +         screen->w_normalGC = screen->normalGC;
  1148. +     } else {
  1149. +         xgcv.font = screen->fnt_w_norm->fid;
  1150. +         screen->w_normalGC = XtGetGC((Widget)term, mask, &xgcv) ;
  1151. +     }
  1152. + #endif    KANJI
  1153.   
  1154.       if (screen->enbolden) { /* there is no bold font */
  1155.           xgcv.font = screen->fnt_norm->fid;
  1156. ***************
  1157. *** 2130,2135 ****
  1158. --- 2735,2756 ----
  1159.           xgcv.font = screen->fnt_bold->fid;
  1160.           screen->normalboldGC = XtGetGC((Widget)term, mask, &xgcv);
  1161.       }
  1162. + #ifdef    KANJI    /* sano */
  1163. +     if (screen->r_enbolden) {    /* there is no bold kana font */
  1164. +         xgcv.font = screen->fnt_r_norm->fid;
  1165. +         screen->r_normalboldGC = screen->r_normalGC;
  1166. +     } else {
  1167. +         xgcv.font = screen->fnt_r_bold->fid;
  1168. +         screen->r_normalboldGC = XtGetGC((Widget)term, mask, &xgcv);
  1169. +     }
  1170. +     if (screen->w_enbolden) {    /* there is no bold kanji font */
  1171. +         xgcv.font = screen->fnt_w_norm->fid;
  1172. +         screen->w_normalboldGC = screen->w_normalGC;
  1173. +     } else {
  1174. +         xgcv.font = screen->fnt_w_bold->fid;
  1175. +         screen->w_normalboldGC = XtGetGC((Widget)term, mask, &xgcv);
  1176. +     }
  1177. + #endif    KANJI
  1178.   
  1179.       xgcv.font = screen->fnt_norm->fid;
  1180.       xgcv.foreground = term->core.background_pixel;
  1181. ***************
  1182. *** 2137,2142 ****
  1183. --- 2758,2778 ----
  1184.   
  1185.       screen->reverseGC = XtGetGC((Widget)term, mask, &xgcv);
  1186.   
  1187. + #ifdef    KANJI    /* sano */
  1188. +     if (screen->fnt_r_norm == screen->fnt_norm) {
  1189. +         screen->r_reverseGC = screen->reverseGC;
  1190. +     } else {
  1191. +         xgcv.font = screen->fnt_r_norm->fid;
  1192. +         screen->r_reverseGC = XtGetGC((Widget)term, mask, &xgcv);
  1193. +     }
  1194. +     if (screen->fnt_w_norm == screen->fnt_norm) {
  1195. +         screen->w_reverseGC = screen->reverseGC;
  1196. +     } else {
  1197. +         xgcv.font = screen->fnt_w_norm->fid;
  1198. +         screen->w_reverseGC = XtGetGC((Widget)term, mask, &xgcv);
  1199. +     }
  1200. + #endif    KANJI
  1201.       if (screen->enbolden) /* there is no bold font */
  1202.           xgcv.font = screen->fnt_norm->fid;
  1203.       else
  1204. ***************
  1205. *** 2144,2149 ****
  1206. --- 2780,2801 ----
  1207.   
  1208.       screen->reverseboldGC = XtGetGC((Widget)term, mask, &xgcv);
  1209.   
  1210. + #ifdef    KANJI    /* sano */
  1211. +     if (screen->r_enbolden) {    /* there is no bold kana font */
  1212. +         xgcv.font = screen->fnt_r_norm->fid;
  1213. +     } else {
  1214. +         xgcv.font = screen->fnt_r_bold->fid;
  1215. +     }
  1216. +     screen->r_reverseboldGC = XtGetGC((Widget)term, mask, &xgcv);
  1217. +     if (screen->w_enbolden) {    /* there is no bold kanji font */
  1218. +         xgcv.font = screen->fnt_w_norm->fid;
  1219. +     } else {
  1220. +         xgcv.font = screen->fnt_w_bold->fid;
  1221. +     }
  1222. +     screen->w_reverseboldGC = XtGetGC((Widget)term, mask, &xgcv);
  1223. + #endif    KANJI
  1224.       /* we also need a set of caret (called a cursor here) gc's */
  1225.   
  1226.       xgcv.font = screen->fnt_norm->fid;
  1227. ***************
  1228. *** 2198,2208 ****
  1229. --- 2850,2908 ----
  1230.           screen->cursoroutlineGC = (GC) 0;
  1231.           }
  1232.       }
  1233. + #ifdef    KANJI    /* michael */
  1234. +     xgcv.font = screen->fnt_r_norm->fid;
  1235. +     {
  1236. +         unsigned long cc = screen->cursorcolor;
  1237. +         unsigned long fg = screen->foreground;
  1238. +         unsigned long bg = term->core.background_pixel;
  1239.   
  1240. +         if (cc != fg && cc != bg) {
  1241. +         /* we have a colored cursor */
  1242. +         xgcv.foreground = fg;
  1243. +         xgcv.background = cc;
  1244. +         screen->r_cursorGC = XtGetGC ((Widget) term, mask, &xgcv);
  1245. +         xgcv.foreground = bg;
  1246. +         xgcv.background = cc;
  1247. +         screen->r_reversecursorGC = XtGetGC ((Widget) term, mask, &xgcv);
  1248. +         } else {
  1249. +         screen->r_cursorGC = (GC) 0;
  1250. +         screen->r_reversecursorGC = (GC) 0;
  1251. +         }
  1252. +     }
  1253. +     xgcv.font = screen->fnt_w_norm->fid;
  1254. +     {
  1255. +         unsigned long cc = screen->cursorcolor;
  1256. +         unsigned long fg = screen->foreground;
  1257. +         unsigned long bg = term->core.background_pixel;
  1258. +         if (cc != fg && cc != bg) {
  1259. +         /* we have a colored cursor */
  1260. +         xgcv.foreground = fg;
  1261. +         xgcv.background = cc;
  1262. +         screen->w_cursorGC = XtGetGC ((Widget) term, mask, &xgcv);
  1263. +         xgcv.foreground = bg;
  1264. +         xgcv.background = cc;
  1265. +         screen->w_reversecursorGC = XtGetGC ((Widget) term, mask, &xgcv);
  1266. +         } else {
  1267. +         screen->w_cursorGC = (GC) 0;
  1268. +         screen->w_reversecursorGC = (GC) 0;
  1269. +         }
  1270. +     }
  1271. + #endif    KANJI
  1272. +     
  1273.       /* Reset variables used by ANSI emulation. */
  1274.   
  1275.       screen->gsets[0] = 'B';            /* ASCII_G        */
  1276. + #ifdef    KANJI    /* sano */
  1277. +     screen->gsets[1] = 'I';
  1278. + #else    KANJI
  1279.       screen->gsets[1] = 'B';
  1280. + #endif    KANJI
  1281.       screen->gsets[2] = 'B';            /* DEC supplemental.    */
  1282.       screen->gsets[3] = 'B';
  1283.       screen->curgl = 0;            /* G0 => GL.        */
  1284. ***************
  1285. *** 2230,2240 ****
  1286. --- 2930,2969 ----
  1287.       screen->scrolls = screen->incopy = 0;
  1288.   /*    free((char *)fInfo);    */
  1289.       vp = &VTbox[1];
  1290. + #ifdef R2SERVER
  1291.       (vp++)->x = FontWidth(screen) - 1;
  1292. +     (vp++)->y = screen->fnt_norm->max_bounds.ascent +
  1293. +             screen->fnt_norm->max_bounds.descent - 1;
  1294. +     (vp++)->x = -(FontWidth(screen) - 1);
  1295. +     vp->y = -(screen->fnt_norm->max_bounds.ascent +
  1296. +             screen->fnt_norm->max_bounds.descent - 1);
  1297. + #else
  1298. +     (vp++)->x = FontWidth(screen) - 1;
  1299.       (vp++)->y = FontHeight(screen) - 1;
  1300.       (vp++)->x = -(FontWidth(screen) - 1);
  1301.       vp->y = -(FontHeight(screen) - 1);
  1302. + #endif
  1303.       screen->box = VTbox;
  1304. + #ifdef    KANJI    /* sano */
  1305. +     vp = &VTwbox[1];
  1306. + #ifdef R2SERVER
  1307. +     (vp++)->x = FontWidth(screen) * 2 - 1;
  1308. +     (vp++)->y = screen->fnt_norm->max_bounds.ascent +
  1309. +             screen->fnt_norm->max_bounds.descent - 1;
  1310. +     (vp++)->x = -(FontWidth(screen) * 2 - 1);
  1311. +     vp->y = -(screen->fnt_norm->max_bounds.ascent +
  1312. +             screen->fnt_norm->max_bounds.descent - 1);
  1313. + #else
  1314. +     (vp++)->x = FontWidth(screen) * 2 - 1;
  1315. +     (vp++)->y = FontHeight(screen) - 1;
  1316. +     (vp++)->x = -(FontWidth(screen) * 2 - 1);
  1317. +     vp->y = -(FontHeight(screen) - 1);
  1318. + #endif
  1319. +     screen->w_box = VTwbox;
  1320. + #endif    KANJI
  1321. + #ifdef    STATUSLINE    /* michael */
  1322. +     status_box[0].x = screen->border - 1;
  1323. + #endif    STATUSLINE
  1324.   
  1325.       screen->savedlines = 0;
  1326.   
  1327. ***************
  1328. *** 2254,2272 ****
  1329. --- 2983,3030 ----
  1330.   {
  1331.       register TScreen *screen = &term->screen;
  1332.       register int x, y, flags;
  1333. + #ifdef    KANJI    /* sano */
  1334. +     register int offset = 0;
  1335. +     unsigned char cc[2];
  1336. + #else    KANJI
  1337.       char c;
  1338. + #endif    KANJI
  1339.       GC    currentGC;
  1340.       Boolean    in_selection;
  1341.   
  1342.       if (eventMode != NORMAL) return;
  1343.   
  1344. + #ifdef    STATUSLINE    /* michael */
  1345. +     if (!screen->instatus &&
  1346. +         screen->cur_row - screen->topline > screen->max_row)
  1347. + #else    STATUSLINE
  1348.       if (screen->cur_row - screen->topline > screen->max_row)
  1349. + #endif    STATUSLINE
  1350.           return;
  1351. + #ifdef    KANJI    /* sano */
  1352. +     cc[0] = screen->buf[y = 2 * (screen->cursor_row = screen->cur_row)]
  1353. + #else    KANJI
  1354.       c = screen->buf[y = 2 * (screen->cursor_row = screen->cur_row)]
  1355. + #endif    KANJI
  1356.        [x = screen->cursor_col = screen->cur_col];
  1357.       flags = screen->buf[y + 1][x];
  1358. + #ifdef    KANJI    /* sano */
  1359. +     if (cc[0] == 0) {
  1360. +         cc[0] = ' ';
  1361. +         flags &= ~(KCS|KANACS);
  1362. +     } else if (flags & KCS) {
  1363. +         if (flags & KCS1)
  1364. +             cc[1] = screen->buf[y][x + 1];
  1365. +         else {
  1366. +             offset = -1;
  1367. +             cc[1] = cc[0];
  1368. +             cc[0] = screen->buf[y][x - 1];
  1369. +         }
  1370. +     }
  1371. + #else    KANJI
  1372.       if (c == 0)
  1373.           c = ' ';
  1374. + #endif    KANJI
  1375.   
  1376.       if (screen->cur_row > screen->endHRow ||
  1377.           (screen->cur_row == screen->endHRow &&
  1378. ***************
  1379. *** 2278,2284 ****
  1380. --- 3036,3109 ----
  1381.       else
  1382.           in_selection = True;
  1383.   
  1384. + #ifdef    STATUSLINE    /* michael */
  1385. +     if(screen->instatus && screen->reversestatus)
  1386. + /*    if (screen->instatus)    */
  1387. +         flags ^= INVERSE;
  1388. + #endif    STATUSLINE
  1389.       if(screen->select || screen->always_highlight) {
  1390. + #ifdef    KANJI    /* sano & micheal */
  1391. +         if (flags & KCS) {
  1392. +             if (( (flags & INVERSE) && !in_selection) ||
  1393. +                 (!(flags & INVERSE) &&  in_selection)){
  1394. +                 /* text is reverse video */
  1395. +                 if (screen->w_cursorGC) {
  1396. +                     currentGC = screen->w_cursorGC;
  1397. +                 } else {
  1398. +                     if (flags & BOLD) {
  1399. +                         currentGC =
  1400. +                             screen->w_normalboldGC;
  1401. +                     } else {
  1402. +                         currentGC =
  1403. +                             screen->w_normalGC;
  1404. +                     }
  1405. +                 }
  1406. +             } else {    /* normal video */
  1407. +                 if (screen->w_reversecursorGC) {
  1408. +                     currentGC = screen->w_reversecursorGC;
  1409. +                 } else {
  1410. +                     if (flags & BOLD) {
  1411. +                         currentGC =
  1412. +                             screen->w_reverseboldGC;
  1413. +                     } else {
  1414. +                         currentGC =
  1415. +                             screen->w_reverseGC;
  1416. +                     }
  1417. +                 }
  1418. +             }
  1419. +         } else if (flags & KANACS) {
  1420. +             if (( (flags & INVERSE) && !in_selection) ||
  1421. +                 (!(flags & INVERSE) &&  in_selection)){
  1422. +                 /* text is reverse video */
  1423. +                 if (screen->r_cursorGC) {
  1424. +                     currentGC = screen->r_cursorGC;
  1425. +                 } else {
  1426. +                     if (flags & BOLD) {
  1427. +                         currentGC =
  1428. +                             screen->r_normalboldGC;
  1429. +                     } else {
  1430. +                         currentGC =
  1431. +                             screen->r_normalGC;
  1432. +                     }
  1433. +                 }
  1434. +             } else {    /* normal video */
  1435. +                 if (screen->r_reversecursorGC) {
  1436. +                     currentGC = screen->r_reversecursorGC;
  1437. +                 } else {
  1438. +                     if (flags & BOLD) {
  1439. +                         currentGC =
  1440. +                             screen->r_reverseboldGC;
  1441. +                     } else {
  1442. +                         currentGC =
  1443. +                             screen->r_reverseGC;
  1444. +                     }
  1445. +                 }
  1446. +             }
  1447. +         } else
  1448. + #endif    KANJI
  1449.           if (( (flags & INVERSE) && !in_selection) ||
  1450.               (!(flags & INVERSE) &&  in_selection)){
  1451.               /* text is reverse video */
  1452. ***************
  1453. *** 2303,2321 ****
  1454.               }
  1455.           }
  1456.       } else { /* not selected */
  1457.           if (( (flags & INVERSE) && !in_selection) ||
  1458.               (!(flags & INVERSE) &&  in_selection)) {
  1459.               /* text is reverse video */
  1460. !             currentGC = screen->reverseGC;
  1461.           } else { /* normal video */
  1462. !             currentGC = screen->normalGC;
  1463.           }
  1464.           
  1465.       }
  1466.   
  1467.       x = CursorX (screen, screen->cur_col);
  1468.       y = CursorY(screen, screen->cur_row) + 
  1469.         screen->fnt_norm->ascent;
  1470.       XDrawImageString(screen->display, TextWindow(screen), currentGC,
  1471.           x, y, &c, 1);
  1472.   
  1473. --- 3128,3254 ----
  1474.               }
  1475.           }
  1476.       } else { /* not selected */
  1477. + #ifdef    KANJI    /* sano */
  1478. +         if (flags & KCS) {
  1479. +             if (( (flags & INVERSE) && !in_selection) ||
  1480. +                 (!(flags & INVERSE) &&  in_selection)) {
  1481. +                 /* text is reverse video */
  1482. +                 if (screen->w_reversecursorGC) {
  1483. +                     currentGC = screen->w_reversecursorGC;
  1484. +                 } else {
  1485. +                     currentGC = screen->w_reverseGC;
  1486. +                 }
  1487. +             } else {    /* normal video */
  1488. +                 if (screen->w_cursorGC) {
  1489. +                     currentGC = screen->w_cursorGC;
  1490. +                 } else {
  1491. +                     currentGC = screen->w_normalGC;
  1492. +                 }
  1493. +             }
  1494. +         } else if (flags & KANACS) {
  1495. +             if (( (flags & INVERSE) && !in_selection) ||
  1496. +                 (!(flags & INVERSE) &&  in_selection)) {
  1497. +                 /* text is reverse video */
  1498. +                 if (screen->r_reversecursorGC) {
  1499. +                     currentGC = screen->r_reversecursorGC;
  1500. +                 } else {
  1501. +                     currentGC = screen->r_reverseGC;
  1502. +                 }
  1503. +             } else {    /* normal video */
  1504. +                 if (screen->r_cursorGC) {
  1505. +                     currentGC = screen->r_cursorGC;
  1506. +                 } else {
  1507. +                     currentGC = screen->r_normalGC;
  1508. +                 }
  1509. +             }
  1510. +         } else
  1511. + #endif    KANJI
  1512. + /*
  1513. +  * Bug fix by michael
  1514. +  * Originials:
  1515. +  *        if(flags & INVERSE) { /* is reverse video */
  1516. + /*            currentGC = screen->reverseGC;
  1517. +  *        } else { /* normal video */
  1518. + /*            currentGC = screen->normalGC;
  1519. +  *        }
  1520. +  */
  1521.           if (( (flags & INVERSE) && !in_selection) ||
  1522.               (!(flags & INVERSE) &&  in_selection)) {
  1523.               /* text is reverse video */
  1524. !             if (screen->reversecursorGC) {
  1525. !                 currentGC = screen->reversecursorGC;
  1526. !             } else {
  1527. !                 currentGC = screen->reverseGC;
  1528. !             }
  1529.           } else { /* normal video */
  1530. !             if (screen->cursorGC) {
  1531. !                 currentGC = screen->cursorGC;
  1532. !             } else {
  1533. !                 currentGC = screen->normalGC;
  1534. !             }
  1535.           }
  1536.           
  1537.       }
  1538.   
  1539. + #ifdef    KANJI    /* sano */
  1540. +     x = CursorX (screen, screen->cur_col + offset);
  1541. + #else    KANJI
  1542.       x = CursorX (screen, screen->cur_col);
  1543. + #endif    KANJI
  1544.       y = CursorY(screen, screen->cur_row) + 
  1545.         screen->fnt_norm->ascent;
  1546. + #ifdef    KANJI    /* sano */
  1547. +     if (flags & KCS) {
  1548. +         /*
  1549. +          * If the cursor is on a Kanji character, then it should
  1550. +          * be drawn as the double sized cursor. If the screen is
  1551. +          * selected, the currentGC should be k_reverseGC or
  1552. +          * k_reverseboldGC, and then inversed cursor is obtained.
  1553. +          * If the screen is not selected, draw a box with w_box.
  1554. +          */
  1555. +         XDrawImageString16(screen->display, TextWindow(screen),
  1556. +             currentGC, x, y, (XChar2b *)cc, 1);
  1557. +         if ((flags & BOLD) && screen->w_enbolden) /* no bold kanji font*/
  1558. +             XDrawString16(screen->display, TextWindow(screen),
  1559. +                 currentGC, x + 1, y, (XChar2b *)cc, 1);
  1560. +         if (flags & UNDERLINE)
  1561. +             XDrawLine(screen->display, TextWindow(screen),
  1562. +                 currentGC, x, y + 1,
  1563. +                 x + FontWidth(screen) * 2, y + 1);
  1564. +         if (!screen->select) {
  1565. +             screen->w_box->x = x;
  1566. +             screen->w_box->y = y - screen->fnt_norm->ascent;
  1567. +             XDrawLines(screen->display, TextWindow(screen),
  1568. +                 currentGC, screen->w_box, NBOX,
  1569. +                 CoordModePrevious);
  1570. +         }
  1571. +     } else {
  1572. +         XDrawImageString(screen->display, TextWindow(screen),
  1573. +             currentGC, x, y, cc, 1);
  1574. +         if (flags & KANACS) {
  1575. +             if ((flags & BOLD) && screen->r_enbolden) /* no bold */
  1576. +                 XDrawString(screen->display, TextWindow(screen),
  1577. +                     currentGC, x + 1, y, cc, 1);
  1578. +         } else {
  1579. +             if ((flags & BOLD) && screen->enbolden) /* no bold */
  1580. +                 XDrawString(screen->display, TextWindow(screen),
  1581. +                     currentGC, x + 1, y, cc, 1);
  1582. +         }
  1583. +         if (flags & UNDERLINE)
  1584. +             XDrawLine(screen->display, TextWindow(screen),
  1585. +                 currentGC, x, y + 1,
  1586. +                 x + FontWidth(screen), y + 1);
  1587. +         if (!screen->select) {
  1588. +             screen->box->x = x;
  1589. +             screen->box->y = y - screen->fnt_norm->ascent;
  1590. +             XDrawLines(screen->display, TextWindow(screen),
  1591. +                 currentGC, screen->box,
  1592. +                 NBOX, CoordModePrevious);
  1593. +         }
  1594. +     }
  1595. + #else    KANJI
  1596.       XDrawImageString(screen->display, TextWindow(screen), currentGC,
  1597.           x, y, &c, 1);
  1598.   
  1599. ***************
  1600. *** 2333,2338 ****
  1601. --- 3266,3272 ----
  1602.                                   : currentGC,
  1603.                   screen->box, NBOX, CoordModePrevious);
  1604.       }
  1605. + #endif    KANJI
  1606.       screen->cursor_state = ON;
  1607.   }
  1608.   
  1609. ***************
  1610. *** 2344,2355 ****
  1611. --- 3278,3306 ----
  1612.       register TScreen *screen = &term->screen;
  1613.       GC    currentGC;
  1614.       register int x, y, flags;
  1615. + #ifdef    STATUSLINE    /* michael */
  1616. +     register int instatus;
  1617. + #endif    STATUSLINE
  1618. + #ifdef    KANJI    /* sano */
  1619. +     register offset = 0;
  1620. +     unsigned char cc[2];
  1621. + #else    KANJI
  1622.       char c;
  1623. + #endif    KANJI
  1624.       Boolean    in_selection;
  1625.   
  1626. + #ifdef    STATUSLINE    /* michael */
  1627. +     if(!(instatus = screen->cursor_row > screen->max_row) &&
  1628. +        screen->cursor_row - screen->topline > screen->max_row)
  1629. + #else    STATUSLINE
  1630.       if(screen->cursor_row - screen->topline > screen->max_row)
  1631. + #endif    STATUSLINE
  1632.           return;
  1633. + #ifdef    KANJI    /* sano */
  1634. +     cc[0] = screen->buf[y = 2 * screen->cursor_row][x = screen->cursor_col];
  1635. + #else    KANJI
  1636.       c = screen->buf[y = 2 * screen->cursor_row][x = screen->cursor_col];
  1637. + #endif    KANJI
  1638.       flags = screen->buf[y + 1][x];
  1639.   
  1640.       if (screen->cursor_row > screen->endHRow ||
  1641. ***************
  1642. *** 2362,2367 ****
  1643. --- 3313,3356 ----
  1644.       else
  1645.           in_selection = True;
  1646.   
  1647. + #ifdef    STATUSLINE    /* michael */
  1648. +     if(screen->instatus && screen->reversestatus)
  1649. + /*    if (screen->instatus)    */
  1650. +         flags ^= INVERSE;
  1651. + #endif    STATUSLINE
  1652. + #ifdef    KANJI    /* sano */
  1653. +     if (flags & KCS) {
  1654. +         if (( (flags & INVERSE) && !in_selection) ||
  1655. +             (!(flags & INVERSE) &&  in_selection)) {
  1656. +             if (flags & BOLD) {
  1657. +                 currentGC = screen->w_reverseboldGC;
  1658. +             } else {
  1659. +                 currentGC = screen->w_reverseGC;
  1660. +             }
  1661. +         } else {
  1662. +             if (flags & BOLD) {
  1663. +                 currentGC = screen->w_normalboldGC;
  1664. +             } else {
  1665. +                 currentGC = screen->w_normalGC;
  1666. +             }
  1667. +         }
  1668. +     } else if (flags & KANACS) {
  1669. +         if (( (flags & INVERSE) && !in_selection) ||
  1670. +             (!(flags & INVERSE) &&  in_selection)) {
  1671. +             if (flags & BOLD) {
  1672. +                 currentGC = screen->r_reverseboldGC;
  1673. +             } else {
  1674. +                 currentGC = screen->r_reverseGC;
  1675. +             }
  1676. +         } else {
  1677. +             if (flags & BOLD) {
  1678. +                 currentGC = screen->r_normalboldGC;
  1679. +             } else {
  1680. +                 currentGC = screen->r_normalGC;
  1681. +             }
  1682. +         }
  1683. +     } else
  1684. + #endif    KANJI
  1685.       if (( (flags & INVERSE) && !in_selection) ||
  1686.           (!(flags & INVERSE) &&  in_selection)) {
  1687.           if(flags & BOLD) {
  1688. ***************
  1689. *** 2377,2388 ****
  1690. --- 3366,3430 ----
  1691.           }
  1692.       }
  1693.   
  1694. + #ifdef    KANJI    /* sano */
  1695. +     if (cc[0] == 0) {
  1696. +         cc[0] = ' ';
  1697. +         flags &= ~(KCS|KANACS);
  1698. +     } else if (flags & KCS) {
  1699. +         if (flags & KCS1)
  1700. +             cc[1] = screen->buf[y][x + 1];
  1701. +         else {
  1702. +             offset = -1;
  1703. +             cc[1] = cc[0];
  1704. +             cc[0] = screen->buf[y][x - 1];
  1705. +         }
  1706. +     }
  1707. + #else     KANJI
  1708.       if (c == 0)
  1709.           c = ' ';
  1710. + #endif    KANJI
  1711. + #ifdef    KANJI    /* sano */
  1712. +     x = CursorX (screen, screen->cursor_col + offset);
  1713. + #else    KANJI
  1714.       x = CursorX (screen, screen->cursor_col);
  1715. + #endif    KANJI
  1716. + #ifdef    STATUSLINE    /* michael */
  1717. +     y = (instatus ? (screen->cursor_row * FontHeight(screen) + 1) :
  1718. +           ((screen->cursor_row - screen->topline) * FontHeight(screen))) +
  1719. + #else    STATUSLINE
  1720.       y = (((screen->cursor_row - screen->topline) * FontHeight(screen))) +
  1721. + #endif    STATUSLINE
  1722.        screen->border;
  1723.       y = y+screen->fnt_norm->ascent;
  1724. + #ifdef    KANJI    /* sano */
  1725. +     if (flags & KCS) {
  1726. +         XDrawImageString16(screen->display, TextWindow(screen),
  1727. +             currentGC, x, y, (XChar2b *)cc, 1);
  1728. +         if ((flags & BOLD) && screen->w_enbolden)
  1729. +             XDrawString16(screen->display, TextWindow(screen),
  1730. +                 currentGC, x + 1, y, (XChar2b *)cc, 1);
  1731. +         if (flags & UNDERLINE)
  1732. +             XDrawLine(screen->display, TextWindow(screen),
  1733. +                 currentGC, x, y + 1,
  1734. +                 x + FontWidth(screen) * 2, y + 1);
  1735. +     } else {
  1736. +         XDrawImageString(screen->display, TextWindow(screen),
  1737. +             currentGC, x, y, cc, 1);
  1738. +         if (flags & KANACS) {
  1739. +             if ((flags & BOLD) && screen->r_enbolden)
  1740. +                 XDrawString(screen->display, TextWindow(screen),
  1741. +                     currentGC, x + 1, y, cc, 1);
  1742. +         } else {
  1743. +             if ((flags & BOLD) && screen->enbolden)
  1744. +                 XDrawString(screen->display, TextWindow(screen),
  1745. +                     currentGC, x + 1, y, cc, 1);
  1746. +         }
  1747. +         if (flags & UNDERLINE)
  1748. +             XDrawLine(screen->display, TextWindow(screen),
  1749. +                 currentGC, x, y + 1,
  1750. +                 x + FontWidth(screen), y + 1);
  1751. +     }
  1752. + #else    KANJI
  1753.       XDrawImageString(screen->display, TextWindow(screen), currentGC,
  1754.           x, y, &c, 1);
  1755.       if((flags & BOLD) && screen->enbolden)
  1756. ***************
  1757. *** 2391,2396 ****
  1758. --- 3433,3439 ----
  1759.       if(flags & UNDERLINE) 
  1760.           XDrawLine(screen->display, TextWindow(screen), currentGC,
  1761.               x, y+1, x + FontWidth(screen), y+1);
  1762. + #endif    KANJI
  1763.       screen->cursor_state = OFF;
  1764.   }
  1765.   
  1766. ***************
  1767. *** 2444,2450 ****
  1768. --- 3487,3498 ----
  1769.                   (Dimension) 80*FontWidth(screen)
  1770.                   + 2 * screen->border + screen->scrollbar,
  1771.                   (Dimension) FontHeight(screen)
  1772. + #ifdef    STATUSLINE    /* michael */
  1773. +                     * (screen->max_row + 1) + screen->statusheight +
  1774. +                 2 * screen->border,
  1775. + #else    STATUSLINE
  1776.                       * (screen->max_row + 1) + 2 * screen->border,
  1777. + #endif    STATUSLINE
  1778.                   &junk, &junk);
  1779.               XSync(screen->display, FALSE);    /* synchronize */
  1780.               if(QLength(screen->display) > 0)
  1781. ***************
  1782. *** 2455,2461 ****
  1783. --- 3503,3603 ----
  1784.       longjmp(vtjmpbuf, 1);    /* force ground state in parser */
  1785.   }
  1786.   
  1787. + #ifdef    STATUSLINE    /* michael */
  1788. + ToStatus(col)
  1789. + int col;
  1790. + {
  1791. +     register TScreen *screen = &term->screen;
  1792.   
  1793. +     if (screen->cursor_state)
  1794. +         HideCursor();
  1795. +     if (col > screen->max_col)
  1796. +         col = screen->max_col;
  1797. +     if (!screen->instatus) {
  1798. +         if (!screen->statusline)
  1799. +             ShowStatus();
  1800. +         CursorSave(term, &screen->statussc);
  1801. +         screen->instatus = TRUE;
  1802. +         screen->cur_row = screen->max_row + 1;
  1803. +     }
  1804. +     screen->cur_col = col;
  1805. + }
  1806. + FromStatus()
  1807. + {
  1808. +     register TScreen *screen = &term->screen;
  1809. +     if (!screen->instatus)
  1810. +         return;
  1811. +     screen->instatus = FALSE;
  1812. +     CursorRestore(term, &screen->statussc);
  1813. + }
  1814. + ShowStatus()
  1815. + {
  1816. +     register TScreen *screen = &term->screen;
  1817. +     register int border = 2 * screen->border;
  1818. +     if (screen->statusline)
  1819. +         return;
  1820. +     screen->statusline = 1;
  1821. +     screen->statusheight = FontHeight(screen) + 2;
  1822. +     ResizeScreen(term, border + screen->scrollbar, border);
  1823. + }
  1824. + HideStatus()
  1825. + {
  1826. +     register TScreen *screen = &term->screen;
  1827. +     register int border = 2 * screen->border;
  1828. +     register int i, j;
  1829. +     if (!screen->statusline)
  1830. +         return;
  1831. +     if (screen->instatus)
  1832. +         FromStatus();
  1833. +     screen->statusline = 0;
  1834. +     screen->statusheight = 0;
  1835. +     bzero(screen->buf[i = 2 * (screen->max_row + 1)],
  1836. +         j = screen->max_col + 1);
  1837. +     bzero(screen->buf[i + 1], j);
  1838. +     ResizeScreen(term, border + screen->scrollbar, border);
  1839. + }
  1840. + EraseStatus()
  1841. + {
  1842. +     register TScreen *screen = &term->screen;
  1843. +     register int i, j, pix;
  1844. +     if (!screen->statusline)
  1845. +         return;
  1846. +     bzero(screen->buf[i = 2 * (screen->max_row + 1)],
  1847. +         j = screen->max_col + 1);
  1848. +     bzero(screen->buf[i + 1], j) ;
  1849. +     XFillRectangle(screen->display, TextWindow(screen),
  1850. +         screen->reversestatus ? screen->normalGC : screen->reverseGC,
  1851. +         screen->border - 1 + screen->scrollbar,
  1852. +         (screen->max_row + 1) * FontHeight(screen) +
  1853. +         screen->border,
  1854. +         j * FontWidth(screen) + 2, screen->statusheight);
  1855. +     if (!screen->reversestatus)
  1856. +         StatusBox(screen);
  1857. + }
  1858. + StatusBox(screen)
  1859. + register TScreen *screen;
  1860. + {
  1861. +     status_box[0].x = screen->scrollbar;
  1862. +     status_box[0].y = (screen->max_row + 1) * FontHeight(screen) +
  1863. +         screen->border;
  1864. +     status_box[3].x = -(status_box[1].x = (screen->max_col + 1) *
  1865. +         FontWidth(screen) + screen->border + 1);
  1866. +     status_box[4].y = -(status_box[2].y = FontHeight(screen) + 1);
  1867. +     XDrawLines(screen->display, TextWindow(screen), screen->normalGC,
  1868. +         status_box, NBOX, CoordModePrevious);
  1869. + }
  1870. + #endif    STATUSLINE
  1871.   #ifdef MODEMENU
  1872.   #define    MMENU_SCROLLBAR        0
  1873.   #define    MMENU_SCROLL        (MMENU_SCROLLBAR+1)
  1874. ***************
  1875. *** 2472,2483 ****
  1876. --- 3614,3637 ----
  1877.   #define MMENU_SCROLLKEY        (MMENU_PAD+1)
  1878.   #endif /* DO_AUTOREPEAT */
  1879.   #define    MMENU_SCROLLINPUT    (MMENU_SCROLLKEY+1)
  1880. + #ifdef    STATUSLINE    /* michael */
  1881. + #define    MMENU_STATUS        (MMENU_SCROLLINPUT+1)
  1882. + #define    MMENU_REVSTATUS        (MMENU_STATUS+1)
  1883. + #define    MMENU_C132        (MMENU_REVSTATUS+1)
  1884. + #else    STATUSLINE
  1885.   #define    MMENU_C132        (MMENU_SCROLLINPUT+1)
  1886. + #endif    STATUSLINE
  1887.   #define    MMENU_CURSES        (MMENU_C132+1)
  1888.   #define    MMENU_MARGBELL        (MMENU_CURSES+1)
  1889.   #define    MMENU_TEKWIN        (MMENU_MARGBELL+1)
  1890.   #define    MMENU_ALTERN        (MMENU_TEKWIN+1)
  1891. + #ifdef    KANJI    /* sano */
  1892. + #define    MMENU_EUC        (MMENU_ALTERN+1)
  1893. + #define    MMENU_SJIS        (MMENU_EUC+1)
  1894. + #define    MMENU_LINE        (MMENU_SJIS+1)
  1895. + #else    KANJI
  1896.   #define    MMENU_LINE        (MMENU_ALTERN+1)
  1897. + #endif    KANJI
  1898.   #define    MMENU_RESET        (MMENU_LINE+1)
  1899.   #define    MMENU_FULLRESET        (MMENU_RESET+1)
  1900.   #define    MMENU_TEKMODE        (MMENU_FULLRESET+1)
  1901. ***************
  1902. *** 2497,2507 ****
  1903. --- 3651,3669 ----
  1904.   #endif /* DO_AUTOREPEAT */
  1905.       "Scroll to bottom on key press",
  1906.       "Scroll to bottom on tty output",
  1907. + #ifdef    STATUSLINE    /* michael */
  1908. +     "Status Line",
  1909. +     "Reverse Status Line",
  1910. + #endif    STATUSLINE
  1911.       "Allow 80/132 switching",
  1912.       "Curses Emulation",
  1913.       "Margin Bell",
  1914.       "Tek Window Showing",
  1915.       "Alternate Screen",
  1916. + #ifdef    KANJI    /* sano */
  1917. +     "EUC Mode",
  1918. +     "Shift-JIS Mode",
  1919. + #endif    KANJI
  1920.       "-",
  1921.       "Soft Reset",
  1922.       "Full Reset",
  1923. ***************
  1924. *** 2521,2526 ****
  1925. --- 3683,3692 ----
  1926.   static int tscrollkey;
  1927.   static int tscrollinput;
  1928.   static Boolean tshow;
  1929. + #ifdef    STATUSLINE    /* michael */
  1930. + static int tstatusline;
  1931. + static int trevstatus;
  1932. + #endif    STATUSLINE
  1933.   
  1934.   Menu *setupmenu(menu)
  1935.   register Menu **menu;
  1936. ***************
  1937. *** 2565,2570 ****
  1938. --- 3731,3746 ----
  1939.               tscrollinput = FALSE;
  1940.               DisableItem(*menu, MMENU_SCROLLINPUT);
  1941.           }
  1942. + #ifdef    STATUSLINE    /* michael */
  1943. +         if (tstatusline = screen->statusline) {
  1944. +             CheckItem(*menu, MMENU_STATUS);
  1945. +             if (trevstatus = screen->reversestatus)
  1946. +                 CheckItem(*menu, MMENU_REVSTATUS);
  1947. +         } else {
  1948. +             trevstatus = FALSE;
  1949. +             DisableItem(*menu, MMENU_REVSTATUS);
  1950. +         }
  1951. + #endif    STATUSLINE
  1952.           if(t132 = screen->c132)
  1953.               CheckItem(*menu, MMENU_C132);
  1954.           if(tcurses = screen->curses)
  1955. ***************
  1956. *** 2584,2589 ****
  1957. --- 3760,3771 ----
  1958.               DisableItem(*menu, MMENU_TEKWIN);
  1959.               DisableItem(*menu, MMENU_TEKMODE);
  1960.           }
  1961. + #ifdef    KANJI    /* sano */
  1962. +         if (flags & EUC_KANJI)
  1963. +             CheckItem(*menu, MMENU_EUC);
  1964. +         if (flags & SJIS_KANJI)
  1965. +             CheckItem(*menu, MMENU_SJIS);
  1966. + #endif    KANJI
  1967.           menutermflags = flags;
  1968.           menukbdflags = kflags;
  1969.           return(*menu);
  1970. ***************
  1971. *** 2625,2630 ****
  1972. --- 3807,3825 ----
  1973.               SetItemCheck(*menu, MMENU_SCROLLINPUT,
  1974.                tscrollinput = screen->scrollinput);
  1975.       }
  1976. + #ifdef    STATUSLINE    /* michael */
  1977. +     if (tstatusline != screen->statusline) {
  1978. +         SetItemCheck(*menu, MMENU_STATUS,
  1979. +             tstatusline = screen->statusline);
  1980. +         SetItemDisable(*menu, MMENU_REVSTATUS, !tstatusline);
  1981. +         SetItemCheck(*menu, MMENU_REVSTATUS,
  1982. +             trevstatus = (tstatusline && screen->reversestatus));
  1983. +     } else if (tstatusline) {
  1984. +         if (tstatusline != screen->reversestatus)
  1985. +             SetItemCheck(*menu, MMENU_REVSTATUS,
  1986. +                 trevstatus = screen->reversestatus);
  1987. +     }
  1988. + #endif    STATUSLINE
  1989.       if(t132 != screen->c132)
  1990.           SetItemCheck(*menu, MMENU_C132, (t132 = screen->c132));
  1991.       if(tcurses != screen->curses)
  1992. ***************
  1993. *** 2640,2645 ****
  1994. --- 3835,3846 ----
  1995.           SetItemCheck(*menu, MMENU_ALTERN, (taltern =
  1996.            screen->alternate));
  1997.       }
  1998. + #ifdef    KANJI    /* sano */
  1999. +     if (menutermflags & EUC_KANJI)
  2000. +         SetItemCheck(*menu, MMENU_EUC, flags & EUC_KANJI);
  2001. +     if (menutermflags & SJIS_KANJI)
  2002. +         SetItemCheck(*menu, MMENU_SJIS, flags & SJIS_KANJI);
  2003. + #endif    KANJI
  2004.       menutermflags = flags;
  2005.       menukbdflags = kflags;
  2006.       return(*menu);
  2007. ***************
  2008. *** 2710,2715 ****
  2009. --- 3911,3930 ----
  2010.           screen->scrollinput = !screen->scrollinput;
  2011.           break;
  2012.   
  2013. + #ifdef    STATUSLINE    /* michael */
  2014. +     case MMENU_STATUS:
  2015. +         if (screen->statusline)
  2016. +             HideStatus();
  2017. +         else
  2018. +             ShowStatus();
  2019. +         break;
  2020. +     case MMENU_REVSTATUS:
  2021. +         screen->reversestatus = !screen->reversestatus;
  2022. +         ScrnRefresh(screen, screen->max_row + 1, 0, 1,
  2023. +             screen->max_col + 1);
  2024. +         break;
  2025. + #endif    STATUSLINE
  2026.           
  2027.       case MMENU_C132:
  2028.           screen->c132 = !screen->c132;
  2029. ***************
  2030. *** 2750,2755 ****
  2031. --- 3965,3986 ----
  2032.           }
  2033.           reselectwindow(screen);
  2034.           break;
  2035. + #ifdef    KANJI    /* sano */
  2036. +     case MMENU_EUC:
  2037. +         term->flags ^= EUC_KANJI;
  2038. +         if (term->flags & EUC_KANJI)
  2039. +             /*
  2040. +              * Reset SJIS_KANJI mode because
  2041. +              * EUC_KANJI and SJIS_KANJI are specified exclusively.
  2042. +              */
  2043. +             term->flags &= ~SJIS_KANJI;
  2044. +         break;
  2045. +     case MMENU_SJIS:
  2046. +         term->flags ^= SJIS_KANJI;
  2047. +         if (term->flags & SJIS_KANJI)
  2048. +             term->flags &= ~EUC_KANJI;
  2049. +         break;
  2050. + #endif    KANJI
  2051.       }
  2052.   }
  2053.   #endif    /* MODEMENU */
  2054.