Eric Mangold wrote: First of all, i think it's better to post it to cygwin mailing list.
> I'm trying to use ttyfier to make the native win32 build of Python play > nice over a cygwin/ssh/bash shell. I can ssh in to my Windows machine and > run the Native python but it has all kinds of issues dealing with > interactive input/output. Why not use cygwin version of python? It's much better integrated with cygwin shells than native one. > I compiled ttyfier successfuly, but it unfortunately didn't solve my > problem. Running Python under tfy causes it to print the normal Python > prompt, then it just hangs and won't respond to any input. > > I figured I would email you just in case you had some idea about what > might be going wrong. I can guess that you're logging in to your cygwin machine from the unix host, right? If this is the case, then you're (almost, see below) out of luck. Ttyfier uses special feature of cygwin console, called "raw-mode input". tfy.exe sends special command to console application, which makes console pass each your keypress, encoded, to tfy.exe. It then parses it and send to the application it's running. If you ssh from xterm on unix machine to cygwin host, run tfy.exe, then your xterm continues sending "cooked" keypresses, instead of "raw" ones, and tfy ignores them. So to be able to use tfy.exe, your console application must be 'ttyfier-compatible', that is, it must support raw mode of input, which tfy.exe can understand. If you've been compiling latest sources of ttyfier, you may have noticed file x11_trans.c inside. This is experimental module to parse raw input from specially patched xterm (I'm attaching my old patch to xterm sources). So, to run your python application from unix machine via ssh you have 2 options: 1. Run cygwin version of python. 2. a. Apply attached patch to xterm sources, and compile special version of xterm. b. Build tfy using wide-character version of libncurses (libncursesw), so that tfy can correctly display pseudo-graphic characters in unicode xterm window. Which one is easier, is up to you. I must admit that since i've moved from windows to linux several years ago, i have not much motivation to push raw-mode patches to xterm or rxvt. egor.
diff -rup2 xterm.org/Imakefile xterm/Imakefile --- xterm.org/Imakefile Tue Aug 20 11:05:57 2002 +++ xterm/Imakefile Thu Aug 22 16:58:44 2002 @@ -104,4 +104,7 @@ module.o: ; $(CC) -c defines $(CFLAGS) m XRFDEPLIBS = XftClientDepLibs $(DEPXRENDERLIB) #endif +#if RawKeyboardSupport + RAW_KBD_OPTION = -DOPT_RAW_KEYBOARD +#endif MAIN_DEFINES = $(UTMPDEF) $(TTYGROUPDEF) $(PUCCPTYDDEF) $(NOPOSIXTERMIOS) \ @@ -110,5 +113,5 @@ module.o: ; $(CC) -c defines $(CFLAGS) m MISC_DEFINES = /* -DALLOWLOGGING -DALLOWLOGFILEEXEC */ XKB_DEFINES = XkbClientDefines - DEFINES = -I. $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION) $(XRFDEF) + DEFINES = -I. $(XKB_DEFINES) $(TERMCAPDEFINES) $(FEATURE_DEFINES) $(SCROLLBAR_RIGHT) $(UTF8_OPTION) $(XRFDEF) $(RAW_KBD_OPTION) #ifdef OS2Architecture diff -rup2 xterm.org/charproc.c xterm/charproc.c --- xterm.org/charproc.c Tue Aug 20 11:05:57 2002 +++ xterm/charproc.c Thu Aug 22 17:18:45 2002 @@ -3371,4 +3371,9 @@ dpmodes( break; #endif +#if OPT_RAW_KEYBOARD + case 2000: + set_raw_keyboard_mode(term, func == bitset); + break; +#endif } } diff -rup2 xterm.org/input.c xterm/input.c --- xterm.org/input.c Tue Aug 20 11:05:57 2002 +++ xterm/input.c Thu Aug 22 17:11:31 2002 @@ -1219,2 +1219,22 @@ xtermcapKeycode(char *params, unsigned * } #endif + +#ifdef OPT_RAW_KEYBOARD +void +handleRawKeyboardEvent (Widget w, XtPointer client_data, XEvent *event, Boolean *continue_to_dispatch) +{ + char raw_buf [50]; + char *p; + if (term->keyboard.raw_mode) { + sprintf (raw_buf, "\033{%d;%d;%dK", event->xany.type, + event->xkey.state, event->xkey.keycode); + for (p = raw_buf; *p; p++) + unparseputc (*p, term->screen.respond); + *continue_to_dispatch = FALSE; + } else if (event->xany.type == KeyRelease) { + *continue_to_dispatch = FALSE; + } else { + *continue_to_dispatch = TRUE; + } +} +#endif diff -rup2 xterm.org/main.c xterm/main.c --- xterm.org/main.c Tue Aug 20 11:05:57 2002 +++ xterm/main.c Thu Aug 22 17:12:21 2002 @@ -1975,4 +1975,14 @@ main (int argc, char *argv[]) init_keyboard_type(keyboardIsVT220, resource.sunKeyboard); #endif +#if OPT_RAW_KEYBOARD + set_raw_keyboard_mode (term, FALSE); + + XtInsertEventHandler ((Widget) term, + KeyPressMask | KeyReleaseMask, + FALSE, + &(handleRawKeyboardEvent), + NULL, + XtListHead); +#endif screen = &term->screen; diff -rup2 xterm.org/ptyx.h xterm/ptyx.h --- xterm.org/ptyx.h Tue Aug 20 11:05:57 2002 +++ xterm/ptyx.h Tue Aug 20 11:08:40 2002 @@ -1322,4 +1322,7 @@ typedef struct int reset_DECBKM; /* reset should set DECBKM */ #endif +#ifdef OPT_RAW_KEYBOARD + int raw_mode; +#endif } TKeyboard; diff -rup2 xterm.org/util.c xterm/util.c --- xterm.org/util.c Tue Aug 20 11:05:57 2002 +++ xterm/util.c Thu Aug 22 17:05:48 2002 @@ -2166,2 +2166,10 @@ void init_keyboard_type(xtermKeyboardTyp } } + +#ifdef OPT_RAW_KEYBOARD +void +set_raw_keyboard_mode(XtermWidget term, Bool set) +{ + term->keyboard.raw_mode = set; +} +#endif diff -rup2 xterm.org/xterm.h xterm/xterm.h --- xterm.org/xterm.h Tue Aug 20 11:05:57 2002 +++ xterm/xterm.h Thu Aug 22 17:09:33 2002 @@ -852,4 +852,9 @@ int visual_width(PAIRED_CHARS(Char *str, #endif +#if OPT_RAW_KEYBOARD +extern void handleRawKeyboardEvent(Widget w, XtPointer client_data, XEvent *event, Boolean *continue_to_dispatch); +extern void set_raw_keyboard_mode (XtermWidget term, Bool set); +#endif + #ifdef __cplusplus }
-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/