diff -rub orig/PDCurses-2.5/curses.h PDCurses-2.5/curses.h
--- orig/PDCurses-2.5/curses.h	2001-10-16 20:03:16.000000000 +0900
+++ PDCurses-2.5/curses.h	2006-08-13 23:45:36.000000000 +0900
@@ -704,6 +704,10 @@
 
 /*---------------------------------------------------------------------*/
 #include <stdio.h>		/* Required by X/Open usage below	*/
+/*---------------------------------------------------------------------*/
+#if defined(JAPAN) && defined(FEPCTRL)
+#include <fepctrl.h>
+#endif
 /*----------------------------------------------------------------------
  *
  *	PDCurses Manifest Constants
@@ -1133,6 +1137,35 @@
 #endif
 
 #if defined(DOS) || defined(OS2) || defined(WIN32)
+#ifdef JAPAN
+/* we use characters in POSIX Locale Default in Win32-J Environment. */
+# define ACS_ULCORNER	(chtype)'+'
+# define ACS_LLCORNER	(chtype)'+'
+# define ACS_URCORNER	(chtype)'+'
+# define ACS_LRCORNER	(chtype)'+'
+# define ACS_RTEE	(chtype)'+'
+# define ACS_LTEE	(chtype)'+'
+# define ACS_BTEE	(chtype)'+'
+# define ACS_TTEE	(chtype)'+'
+# define ACS_HLINE	(chtype)'-'
+# define ACS_VLINE	(chtype)'|'
+# define ACS_PLUS	(chtype)'+'
+# define ACS_S1	(chtype)'-'
+# define ACS_S9	(chtype)'_'
+# define ACS_DIAMOND	(chtype)'+'
+# define ACS_CKBOARD	(chtype)':'
+# define ACS_DEGREE	(chtype)'\''
+# define ACS_PLMINUS	(chtype)'#'
+# define ACS_BULLET	(chtype)'o'
+# define ACS_LARROW	(chtype)'<'
+# define ACS_RARROW	(chtype)'>'
+# define ACS_DARROW	(chtype)'v'
+# define ACS_UARROW	(chtype)'^'
+# define ACS_BOARD	(chtype)'#'
+# define ACS_LANTERN	(chtype)'#'
+# define ACS_BLOCK	(chtype)'#'
+
+#else /* #ifdef JAPAN */
 /* ALTCHARSET definitions from jshumate@wrdis01.robins.af.mil */
 # define ACS_ULCORNER	(chtype)0xda			/* SysV		*/
 # define ACS_LLCORNER	(chtype)0xc0			/* SysV		*/
@@ -1159,6 +1192,7 @@
 # define ACS_BOARD	(chtype)0x23			/* SysV		*/
 # define ACS_LANTERN	(chtype)0x23			/* SysV		*/
 # define ACS_BLOCK	(chtype)0x23			/* SysV		*/
+#endif /* ifdef JAPAN */
 
 /* the following definitions can be used if you have set raw_output()
    or are using the PDCurses *raw*() functions                        */
diff -rub orig/PDCurses-2.5/curspriv.h PDCurses-2.5/curspriv.h
--- orig/PDCurses-2.5/curspriv.h	2001-02-25 13:38:58.000000000 +0900
+++ PDCurses-2.5/curspriv.h	2006-08-13 23:45:36.000000000 +0900
@@ -590,4 +590,8 @@
 #define XCURSCR_ATRTAB_OFF  (XCURSCR_LENGTH_OFF+XCURSCR_LENGTH_SIZE)
 #endif
 
+#ifdef JAPAN
+extern int isWin95;
+#endif
+
 #endif /* __CURSES_INTERNALS__*/
diff -rub orig/PDCurses-2.5/pdcurses/getch.c PDCurses-2.5/pdcurses/getch.c
--- orig/PDCurses-2.5/pdcurses/getch.c	2001-01-10 17:27:02.000000000 +0900
+++ PDCurses-2.5/pdcurses/getch.c	2006-08-13 23:45:36.000000000 +0900
@@ -22,6 +22,9 @@
 #  include <config.h>
 #endif
 #include <curses.h>
+#if defined(WIN32) && defined(JAPAN) & defined(FEPCTRL)
+#include <windows.h>
+#endif
 
 /* undefine any macros for functions defined in this module */
 #undef	getch
@@ -297,13 +300,32 @@
 			 */
 			key = '\n';
 		}
+#if defined(WIN32) && defined(JAPAN) & defined(FEPCTRL)
+		if ((SP->echo && (key < display_key)) || (fep_get_mode() && isWin95))
+#else
 		if ( SP->echo && (key < display_key) )
+#endif
 		{
 			/*
 			 * if echo is enabled
 			 */
 			waddch(w, key);
 			wrefresh(w);
+#if defined(WIN32) && defined(JAPAN) & defined(FEPCTRL)
+			if (fep_get_mode()) {
+			    COORD coord;
+			    DWORD written;
+			    extern HANDLE hConOut;
+			    char ch;
+
+			    ch = key;
+			    coord.X = w->_begx + w->_curx - 1;
+			    coord.Y = w->_begy + w->_cury;
+			    WriteConsoleOutputCharacter(hConOut, &ch, 1, coord, &written);
+			    coord.X++;
+			    SetConsoleCursorPosition(hConOut, coord);
+			}
+#endif
 		}
 		if ( (SP->raw_inp || SP->cbreak) )
 		{
diff -rub orig/PDCurses-2.5/pdcurses/initscr.c PDCurses-2.5/pdcurses/initscr.c
--- orig/PDCurses-2.5/pdcurses/initscr.c	2001-01-10 17:27:08.000000000 +0900
+++ PDCurses-2.5/pdcurses/initscr.c	2006-08-13 23:45:36.000000000 +0900
@@ -529,6 +529,10 @@
 	PDC_gotoxy(PDC_get_rows() - 2, 0);
 #endif
 
+#if defined(WIN32) && defined(JAPAN) & defined(FEPCTRL)
+    fep_term();
+#endif
+
 	SP->alive = FALSE;
 
 #endif
diff -rub orig/PDCurses-2.5/pdcurses/refresh.c PDCurses-2.5/pdcurses/refresh.c
--- orig/PDCurses-2.5/pdcurses/refresh.c	2001-01-10 17:27:26.000000000 +0900
+++ PDCurses-2.5/pdcurses/refresh.c	2006-08-13 23:45:36.000000000 +0900
@@ -293,12 +293,14 @@
 
 /* if checking for typeahead, bail out here if any is found */
    
+#if 0
    if (SP->refrbrk && (SP->cbreak || SP->raw_inp)) 
    {
       rc = PDC_breakout();
       if(rc)
          return( OK );
    }
+#endif
 
    if (curscr->_clear)
       PDC_clr_update(curscr);
diff -rub orig/PDCurses-2.5/pdcurses/window.c PDCurses-2.5/pdcurses/window.c
--- orig/PDCurses-2.5/pdcurses/window.c	2001-01-10 17:27:36.000000000 +0900
+++ PDCurses-2.5/pdcurses/window.c	2006-08-13 23:45:36.000000000 +0900
@@ -605,6 +605,7 @@
 	new->_parent = win->_parent;
 	new->_immed = win->_immed;
 	new->_sync = win->_sync;
+	new->_bkgd = win->_bkgd;
 
 	for (i = 0; i < lins; i++)
 	{
diff -rub orig/PDCurses-2.5/win32/bccwin32.lrf PDCurses-2.5/win32/bccwin32.lrf
--- orig/PDCurses-2.5/win32/bccwin32.lrf	2001-01-10 17:30:40.000000000 +0900
+++ PDCurses-2.5/win32/bccwin32.lrf	2006-08-13 23:45:36.000000000 +0900
@@ -45,4 +45,5 @@
 -+pdcsetsc.obj &
 -+pdcutil.obj &
 -+pdcwin.obj &
+-+fepnt.obj &
 ,lib.map
diff -rub orig/PDCurses-2.5/win32/bccwin32.mak PDCurses-2.5/win32/bccwin32.mak
--- orig/PDCurses-2.5/win32/bccwin32.mak	2001-11-26 17:59:16.000000000 +0900
+++ PDCurses-2.5/win32/bccwin32.mak	2006-08-13 23:45:36.000000000 +0900
@@ -12,8 +12,8 @@
 # Change these for your environment...
 #
 ################################################################################
-PDCURSES_HOME		=c:\curses
-CC_HOME		=f:\apps\bc4
+PDCURSES_HOME		=..
+CC_HOME		=c:\app\Borland\bcc55
 ################################################################################
 # Nothing below here should required changing.
 ################################################################################
@@ -37,20 +37,21 @@
 CC		= bcc32
 
 !if $d(DEBUG)
-CFLAGS  = -N -v -y -DPDCDEBUG
-LDFLAGS = /c /v /s /l /e
+CFLAGS  = -N -v -y -DPDCDEBUG -DJAPAN -DFEPCTRL
+#LDFLAGS = /c /v /s /l /e
+LDFLAGS = /c /v /s /l /e -L"c:\app\Borland\Bcc55\lib"
 !else
-CFLAGS  =  -O
-LDFLAGS = 
+CFLAGS  =  -O -DJAPAN -DFEPCTRL
+LDFLAGS = -L"c:\app\Borland\Bcc55\lib"
 !endif
 
 CPPFLAGS	= -I$(PDCURSES_HOME) -I$(CCINCDIR)
 
 CCFLAGS		= -c -Tpe -w32 $(CFLAGS) $(CPPFLAGS)
 
-LINK		= tlink32
+LINK		= ilink32
 
-CCLIBS		=$(CCLIBDIR)\bidsf.lib+$(CCLIBDIR)\import32.lib+$(CCLIBDIR)\cw32.lib
+CCLIBS		=$(CCLIBDIR)\import32.lib+$(CCLIBDIR)\cw32.lib
 STARTUP	=$(CCLIBDIR)\c0x32.obj
 
 LIBEXE		= tlib /C /E
@@ -86,6 +87,7 @@
 color.obj     \
 delch.obj     \
 deleteln.obj  \
+fepnt.obj     \
 getch.obj     \
 getstr.obj    \
 getyx.obj     \
@@ -246,12 +248,15 @@
 	$(CC) $(CCFLAGS) -o$@ $(srcdir)\window.c
 
 
-pdcclip.obj: $(srcdir)\pdcclip.c $(PDCURSES_HEADERS)
-	$(CC) $(CCFLAGS) -o$@ $(srcdir)\pdcclip.c
+pdcclip.obj: $(osdir)\pdcclip.c $(PDCURSES_HEADERS)
+	$(CC) $(CCFLAGS) -o$@ $(osdir)\pdcclip.c
 
 pdcdebug.obj: $(srcdir)\pdcdebug.c $(PDCURSES_HEADERS)
 	$(CC) $(CCFLAGS) -o$@ $(srcdir)\pdcdebug.c
 
+fepnt.obj: $(osdir)\fepnt.c
+	$(CC) $(CCFLAGS) -o$@ $(osdir)\fepnt.c
+
 pdcdisp.obj: $(osdir)\pdcdisp.c $(PDCURSES_HEADERS)
 	$(CC) $(CCFLAGS) -o$@ $(osdir)\pdcdisp.c
 
@@ -284,22 +289,22 @@
 #------------------------------------------------------------------------
 
 firework.exe:	firework.obj $(LIBCURSES)
-	$(LINK) $(LDFLAGS) $(STARTUP)+$*,$*,,$(LIBCURSES)+$(CCLIBS);
+	$(LINK) $(LDFLAGS) $(STARTUP)+$*,$*,,$(LIBCURSES)+$(CCLIBS)
 
 newdemo.exe:	newdemo.obj $(LIBCURSES)
-	$(LINK) $(LDFLAGS) $(STARTUP)+$*,$*,,$(LIBCURSES)+$(CCLIBS);
+	$(LINK) $(LDFLAGS) $(STARTUP)+$*,$*,,$(LIBCURSES)+$(CCLIBS)
 
 ptest.exe:	ptest.obj $(LIBCURSES) $(LIBPANEL)
 	$(LINK) $(LDFLAGS) $(STARTUP)+$*,$*,,$(LIBPANEL)+$(LIBCURSES)+$(CCLIBS);
 
 testcurs.exe:	testcurs.obj $(LIBCURSES)
-	$(LINK) $(LDFLAGS) $(STARTUP)+$*,$*,,$(LIBCURSES)+$(CCLIBS);
+	$(LINK) $(LDFLAGS) $(STARTUP)+$*,$*,,$(LIBCURSES)+$(CCLIBS)
 
 tuidemo.exe:	tuidemo.obj tui.obj $(LIBCURSES)
-	$(LINK) $(LDFLAGS) $(STARTUP)+$*+tui,$*,,$(LIBCURSES)+$(CCLIBS);
+	$(LINK) $(LDFLAGS) $(STARTUP)+$*+tui,$*,,$(LIBCURSES)+$(CCLIBS)
 
 xmas.exe:	xmas.obj $(LIBCURSES)
-	$(LINK) $(LDFLAGS) $(STARTUP)+$*,$*,,$(LIBCURSES)+$(CCLIBS);
+	$(LINK) $(LDFLAGS) $(STARTUP)+$*,$*,,$(LIBCURSES)+$(CCLIBS)
 
 
 firework.obj: $(demodir)\firework.c $(PDCURSES_CURSES_H)
diff -rub orig/PDCurses-2.5/win32/mingwin32.mak PDCurses-2.5/win32/mingwin32.mak
--- orig/PDCurses-2.5/win32/mingwin32.mak	2001-01-10 17:30:46.000000000 +0900
+++ PDCurses-2.5/win32/mingwin32.mak	2006-08-13 23:47:24.000000000 +0900
@@ -12,8 +12,8 @@
 # Change these for your environment...
 #
 ################################################################################
-PDCURSES_HOME		=f:/curses
-CC_HOME		=f:/mingw32
+PDCURSES_HOME		=..
+CC_HOME		=c:/mingw
 ################################################################################
 # Nothing below here should required changing.
 ################################################################################
@@ -41,7 +41,7 @@
 	LDFLAGS =
 endif
 
-CPPFLAGS	= -I$(PDCURSES_HOME) -I$(CCINCDIR)
+CPPFLAGS	= -I$(PDCURSES_HOME) -I$(CCINCDIR) -DJAPAN
 
 CCFLAGS		= $(CFLAGS) $(CPPFLAGS)
 
diff -rub orig/PDCurses-2.5/win32/pdcdisp.c PDCurses-2.5/win32/pdcdisp.c
--- orig/PDCurses-2.5/win32/pdcdisp.c	2001-01-10 17:30:48.000000000 +0900
+++ PDCurses-2.5/win32/pdcdisp.c	2006-08-13 23:45:36.000000000 +0900
@@ -107,12 +107,14 @@
       }
       WriteConsoleOutput(hConOut, ci, bufSize, bufPos, &sr);
 
+#if 0
       if (SP->refrbrk && (SP->cbreak || SP->raw_inp)) 
       {
          rc = PDC_breakout();
          if (rc)
             break;
       }
+#endif
    }
    return( OK );
 }
@@ -476,12 +478,14 @@
    curscr->_firstch[lineno] = _NO_CHANGE;
    curscr->_lastch[lineno] = _NO_CHANGE;
    
+#if 0
    if (SP->refrbrk && (SP->cbreak || SP->raw_inp)) 
    {
       rc = PDC_breakout();
       if (rc)
          return(TRUE);
    }
+#endif
    return(FALSE);
 }
 
diff -rub orig/PDCurses-2.5/win32/pdcgetsc.c PDCurses-2.5/win32/pdcgetsc.c
--- orig/PDCurses-2.5/win32/pdcgetsc.c	2001-01-10 17:30:48.000000000 +0900
+++ PDCurses-2.5/win32/pdcgetsc.c	2006-08-13 23:45:36.000000000 +0900
@@ -247,15 +247,21 @@
 int	PDC_get_rows(void)
 {
 
+   int rows;
 #ifdef PDCDEBUG
    if (trace_on) PDC_debug("PDC_get_rows() - called\n");
 #endif
 
    GetConsoleScreenBufferInfo(hConOut, &scr);
 #if FGC0
-   return ( scr.dwSize.Y ); /* Allow the whole screen to be accessed */
+   rows = ( scr.dwSize.Y ); /* Allow the whole screen to be accessed */
 #else
-   return (scr.srWindow.Bottom - scr.srWindow.Top + 1);
+   rows = (scr.srWindow.Bottom - scr.srWindow.Top + 1);
+#endif
+#ifdef JAPAN
+   return rows-1; /* reserve the last line for IME */
+#else
+   return rows;
 #endif
 }
 
diff -rub orig/PDCurses-2.5/win32/pdckbd.c PDCurses-2.5/win32/pdckbd.c
--- orig/PDCurses-2.5/win32/pdckbd.c	2001-10-16 20:12:12.000000000 +0900
+++ PDCurses-2.5/win32/pdckbd.c	2006-08-13 23:45:36.000000000 +0900
@@ -49,6 +49,19 @@
 #ifndef RIGHTMOST_BUTTON_PRESSED
 # define RIGHTMOST_BUTTON_PRESSED 0x0002
 #endif
+
+#ifdef JAPAN
+int lynx_kanji_mode = 0; /* not needed? */
+
+static int kanji_mode = 0;
+static int kanji_cnt = 0;
+static int kanji_pos = 0;
+
+/* 実際には１文字分しか返って来ないようである */
+static unsigned char kanji_buff[80];
+
+#endif	/* JAPAN */
+
 /*
  * These variables are used to store information about the next 
  * Input Event.
@@ -468,6 +481,10 @@
    bool trap_mouse=FALSE;
    int idx=0,key=0;
    bool enhanced=FALSE;
+#ifdef JAPAN
+   DWORD read_len;
+   int code;
+#endif
 
 #ifdef PDCDEBUG
    if (trace_on) PDC_debug("PDC_get_bios_key() - called\n");
@@ -475,8 +492,67 @@
 
    while(1)
    {
+#ifdef JAPAN
+key_in:
+        if (isWin95) {
+	    if (kanji_cnt > 0) {
+		kanji_cnt--;
+		kanji_pos++;
+		code = kanji_buff[kanji_pos];
+		return code;
+	    } else {
+		kanji_pos = 0;
+	    }
+	}
+#endif
       win32_getch();
    
+#if defined(JAPAN) & defined(FEPCTRL)
+	if (isWin95) {
+	    if (fep_get_mode()) {
+		ReadConsole(hConIn, kanji_buff, 
+			    sizeof kanji_buff, &read_len, 0);
+
+		if (read_len == 0)
+		    goto key_in;
+
+		code = kanji_buff[0];
+		if (read_len == 1) {
+		    if (win32_kbhit(0))
+			win32_getch();
+		    return code;
+		}
+#ifdef TEST
+		if (code == '\r') {
+		    kanji_buff[0] = '\t';
+		    return code;
+		}
+#else
+		if (lynx_kanji_mode && code == '\r') {
+		    kanji_buff[0] = '\t';
+		    return code;
+		}
+#endif
+		kanji_buff[read_len] = '\0';
+		kanji_cnt = keyCount = read_len;
+		kanji_pos = 0;
+		code = kanji_buff[0];
+		kanji_cnt--;
+#ifdef TEST
+		if (read_len == 1) {
+		    if (code < ' ')
+			debugf("%02x\n", code);
+		    else
+			debugf("%c\n", code);
+		} else {
+		    debugf("%s", kanji_buff);
+		}
+#endif
+		return code;
+	    }
+	}
+#endif
+
       switch(save_ip.EventType)
       {
          case KEY_EVENT:
@@ -567,6 +643,7 @@
                }
                else
                {
+#ifndef JAPAN
                   idx = save_ip.Event.KeyEvent.wVirtualKeyCode;
                   if (save_ip.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED
                   && kptab[idx].shift)
@@ -579,6 +656,7 @@
                   ||   save_ip.Event.KeyEvent.dwControlKeyState & RIGHT_ALT_PRESSED)
                   &&  kptab[idx].alt)
                      return(kptab[idx].alt);
+#endif
                   return((int)(unsigned char)save_ip.Event.KeyEvent.uChar.AsciiChar);
                }
             }
@@ -916,6 +994,9 @@
    extern   WINDOW*  _getch_win_;
 
    int c=0;
+#ifdef JAPAN			/* KANJI input */
+    int code;
+#endif				/* KANJI input */
 
 #ifdef PDCDEBUG
    if (trace_on) PDC_debug("PDC_sysgetch() - called\n");
@@ -939,6 +1020,15 @@
       {
          return (c);      /* get & check next char */
       }
+#ifdef JAPAN	/* KANJI input */
+	else {
+	    code = c & 0xff;
+	    /* SJIS code ? */
+	    if ((0x80 <= code) && (code <= 0xfe))
+		return code;
+	    /* get & check next char */
+	}
+#endif		/* KANJI input */
    }
 }
 
diff -rub orig/PDCurses-2.5/win32/pdcscrn.c PDCurses-2.5/win32/pdcscrn.c
--- orig/PDCurses-2.5/win32/pdcscrn.c	2001-01-10 17:30:52.000000000 +0900
+++ PDCurses-2.5/win32/pdcscrn.c	2006-08-13 23:45:36.000000000 +0900
@@ -34,6 +34,10 @@
 static CHAR_INFO *save_ci=NULL;
 static DWORD dwConsoleMode=0;
 
+#ifdef JAPAN
+int isWin95 = 0;
+#endif
+
 /*man-start*********************************************************************
 
   PDC_scr_close()	- Internal low-level binding to close the physical screen
@@ -153,13 +157,24 @@
  SMALL_RECT rect;
  char *str=NULL;
  CONSOLE_SCREEN_BUFFER_INFO csbi;
+#ifdef JAPAN
+ OSVERSIONINFO winVersionInfo;
+#endif
 
 #ifdef PDCDEBUG
    if (trace_on) PDC_debug("PDC_scr_open() - called\n");
 #endif
 
 	hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
+/*
+	if (isatty(fileno(stdin))) {
 	hConIn = GetStdHandle(STD_INPUT_HANDLE);
+	}
+	else {
+	    hConIn = CreateFile("CONIN$", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+	}
+*/
+	hConIn = CreateFile("CONIN$", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
 
 	GetConsoleScreenBufferInfo(hConOut, &csbi);
 	GetConsoleScreenBufferInfo(hConOut, &orig_scr);
@@ -253,6 +268,20 @@
 
 	PDC_reset_prog_mode();
 
+#ifdef FEPCTRL
+    fep_init();
+#endif
+#ifdef JAPAN
+    winVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+    if (GetVersionEx (&winVersionInfo) == 0) {
+        fprintf(stderr, "can't get Windows version information.\n");
+        exit(1);
+    }
+    if (winVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
+        isWin95 = 1;
+    }
+#endif
+
 	GetNumberOfConsoleMouseButtons((LPDWORD)&numbuttons);
 	internal->num_mouse_buttons = (int)numbuttons;
 
