• SBCL and OS interface

    From steve@21:1/5 to All on Sun Jul 11 20:37:06 2021
    The following partial functions work with sbcl using the SB-POSIX
    interface. I still cannot understand how the ffi works; thank you SBCL people...


    (defun tty-open-device (tty &key (debugging-p t))
    (tty-close)
    (let ((stdscr (or *current-screen* (setq *current-screen* (make-screen)))))
    (setq tty (namestring tty))
    (let* ((ofd (sb-posix:open tty sb-posix:o-wronly (logior sb-posix:o-noctty sb-posix:o-nonblock)))
    (ifd (sb-posix:open tty sb-posix:o-rdonly (logior sb-posix:o-noctty sb-posix:o-nonblock)))
    ;; this needs to be fixed for input
    (output (sb-sys:make-fd-stream ofd :buffering :none :output t :input nil :external-format :ascii))
    (input (sb-sys:make-fd-stream ofd :buffering :none :output nil :input t :external-format :ascii))
    )

    [ ... ]


    #|

    ;; Old Flags New Flags
    ;; ------------------------
    ;; I_flags; 25862 => 25606
    ;; O_flags; 5 => 5
    ;; C_flags; 1215 => 1215
    ;; L_flags; 35387 => 35377

    |#
    (defconstant ECHOCTL #o0001000)

    (defun tty-set ()
    (let ((termios (screen-termios-new (current-screen))))

    ;; set cannon mode/no echo
    (setf (sb-posix:termios-lflag termios)
    (logand (sb-posix:termios-lflag termios)
    (lognot (logior sb-posix:icanon sb-posix:echo sb-posix:noflsh
    ECHOCTL))))
    ;; set ignore nl/cr
    (setf (sb-posix:termios-iflag termios)
    (logand (sb-posix:termios-iflag termios) (lognot sb-posix:ICRNL)))

    (setf (aref (sb-posix:termios-cc termios) sb-posix:vmin) 18)
    (setf (aref (sb-posix:termios-cc termios) sb-posix:vtime) 1)
    (sb-posix:tcsetattr (screen-ifd (current-screen)) sb-posix:tcsaflush termios)
    (force-output (screen-output (current-screen)))
    (current-screen)))


    [ ... ]



    I have been waiting for years to dump some of that c code! Thank you!!! again!!!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)