chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] porting parley to MS Windows ?


From: Claude Marinier
Subject: [Chicken-users] porting parley to MS Windows ?
Date: Sun, 28 Jul 2013 18:25:51 -0400 (EDT)
User-agent: Alpine 2.02 (DEB 1266 2009-07-14)

Greetings,

This is where parley uses stty.

(define (enable-raw-mode port)
  (let ((old-attrs (get-terminal-attributes port)))
    (install-exit-handler! port old-attrs)
    (stty port '(not echo icanon isig brkint icrnl inpck istrip ixon))
    (stty port '(cs8 opost))
    (set-buffering-mode! port #:none)
    old-attrs)

Creating a complete Win32 replacement for stty would be a lot of work but
replacing only the parts which parley uses would be much less work. It might look like this.

    #include <windows.h>
    HANDLE hConsolehandle;
    DWORD fdwOldMode, fdwNewMode;
    hConsoleHandle = GetStdHandle(STD_INPUT_HANDLE);
    if ( hConsoleHandle == INVALID_HANDLE_VALUE ) {
        ErrorExit("GetStdHandle"); /* or something more sensible */
    }
    if ( ! GetConsoleMode( hConsoleHandle, &fdwOldMode ) ) {
        ErrorExit("GetConsoleMode"); /* or something more sensible */
    }
    fdwNewMode = fdwOldMode &
      ~( ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT );
    if ( ! SetConsoleMode( hconsoleHandle, fdwNewMode ) ) {
        ErrorExit("GetStdHandle"); /* or something more sensible */
    }

Would the exit handler and set_buffering_mode require POSIX?

One would have to save the old mode for use by the exit handler.

Could this be put in-line? How would one handle the conditional inclusion of the Win32 code?

Just thinking out loud. I hope you don't mind.

--
Claude Marinier



reply via email to

[Prev in Thread] Current Thread [Next in Thread]