--- htdos.c.orig Mon Oct 11 02:29:46 2004 +++ htdos.c Sat Oct 16 16:57:08 2004 @@ -167,33 +167,45 @@ } #endif -#if defined(DJGPP) && defined(DJGPP_KEYHANDLER) +#if defined(DJGPP) +/* + * Poll tcp/ip lib and yield to DPMI-host while nothing in + * keyboard buffer (head = tail) (simpler than kbhit). + * This is required to be able to finish off dead sockets, + * answer pings etc. + */ +#include +#include +#include +#include + +void djgpp_idle_loop (void) +{ + while (_farpeekw(_dos_ds, 0x41a) == _farpeekw(_dos_ds, 0x41c)) { + tcp_tick(NULL); + __dpmi_yield(); +#if defined(USE_SLANG) + if (SLang_input_pending(1)) + break; +#endif + } +} + /* PUBLIC getxkey() * Replaces libc's getxkey() with polling of tcp/ip - * library (WatTcp or Watt-32). This is required to - * be able to finish off dead sockets, answer pings etc. - * + * library (WatTcp or Watt-32). * * ON EXIT: * returns extended keypress. */ /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ -#include -#include -#include -#include int getxkey(void) { +#if defined(DJGPP_KEYHANDLER) __dpmi_regs r; - /* poll tcp/ip lib and yield to DPMI-host while nothing in - * keyboard buffer (head = tail) (simpler than kbhit). - */ - while (_farpeekw(_dos_ds, 0x41a) == _farpeekw(_dos_ds, 0x41c)) { - tcp_tick(NULL); - __dpmi_yield(); - } + djgpp_idle_loop(); r.h.ah = 0x10; __dpmi_int(0x16, &r); @@ -203,5 +215,13 @@ if (r.h.al == 0xe0) return 0x0200 | r.h.ah; return r.h.al; + +#elif defined(USE_SLANG) + djgpp_idle_loop(); + return SLkp_getkey(); +#else + /* PDcurses uses myGetChar() in LYString.c */ +#endif } -#endif /* DJGPP && DJGPP_KEYHANDLER */ +#endif /* DJGPP */ + --- htdos.h.orig Thu Jul 1 01:55:04 2004 +++ htdos.h Thu Oct 14 14:37:50 2004 @@ -42,4 +42,11 @@ #define HTDOS_short_name(fn) fn #endif +#ifdef DJGPP +/* + * Poll tcp/ip lib and yield to DPMI-host while nothing in + * keyboard buffer (head = tail) (simpler than kbhit). + */ +void djgpp_idle_loop (void); +#endif #endif /* HTDOS_H */ --- src/lystring.c.orig Mon Oct 11 02:29:46 2004 +++ src/lystring.c Sat Oct 16 17:34:20 2004 @@ -696,11 +696,7 @@ #define GetChar() ttgetc() #else #ifdef __DJGPP__ -#ifdef DJGPP_KEYHANDLER -#define GetChar getxkey -#else -#define GetChar SLkp_getkey -#endif /* DJGPP_KEYHANDLER */ +#define GetChar() getxkey() /* HTDos.c */ #else #ifdef __CYGWIN__ #define GetChar SLkp_getkey @@ -712,8 +708,12 @@ #endif /* USE_SLANG */ #if !defined(GetChar) && defined(NCURSES) +#ifdef DJGPP +#define GetChar() (djgpp_idle_loop(), wgetch(LYtopwindow())) +#else #define GetChar() wgetch(LYtopwindow()) #endif +#endif #if !defined(GetChar) && defined(PDCURSES) && defined(PDC_BUILD) && PDC_BUILD >= 2401 /* PDCurses sends back key-modifiers that we don't use, but would waste time