SB-POSIX:READ

steve gonedes <[email protected]>
Newsgroups gmane.lisp.steel-bank.general
Message-ID <[email protected]>
I finally found the issue with reading 4 uint_32t with all sbcl.

I forgot to set the size of the byte to 8 and forgot the VMIN and VTIME.

this is from my termios...

the set-keyboard-mode is a linux ioctl. makes sure we are using utf8, 
same with IUTF8.

    ((:cbreak-off :CANNON-OFF)
        (terminfo::debugging-motion-macros "CBREAK Mode disabled")
        (terminfo::set-keyboard-mode (screen-ifd curscr) 
terminfo::K_UNICODE)
        ;; set non-cannon mode, no echo, no flush on signal
        ;; set cannon mode, no echo, no flush on signal
        (setf (sb-posix:termios-Lflag termios)
              (logand (sb-posix:termios-Lflag termios) (lognot 
sb-posix:icanon)))
        ;; set read time/bytes
        (setf (aref (sb-posix:termios-cc termios) sb-posix:vmin) 4)
        (setf (aref (sb-posix:termios-cc termios) sb-posix:vtime) 1)

        ;; set ignore nl/cr
        (setf (sb-posix::termios-iflag termios)
              (logior (sb-posix:termios-iflag termios) sb-posix:icrnl))
        ;; turn on input to UTF8 mode when available
        (when (boundp 'terminfo::IUTF8)
          (setf (sb-posix::termios-iflag termios)
                (logior (sb-posix:termios-iflag termios) terminfo::IUTF8)))


i added the attachment for a simple read-key function. It is all in 
LISP! termios and everything; thanx sbcl!


if anyone has any more info I would appreciate it...

_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help
input-tem.lisp (text/x-common-lisp, 1.3 KB)
;;;; -*- mode: lisp-mode; package: CL-USER; -*-
;;;; May 08, 2024 Wednesday 16:16 -0400
;;;; input

(in-package :terminfo)
(require :sb-posix)

;; this is what I have so far. No C!

(defparameter
    input-buffer (sb-alien:make-alien (array (unsigned 8) 4))
  "Input buffer for read key.")

(defun clear-input-buffer ()
  (loop for idx from 3 downto 0
        do (setf (deref (deref input-buffer) idx) 0)))

(defmacro ddref (ar idx)
;; this did the trick...
  `(deref (deref ,ar) ,idx))

(defun input-to-vector (buf)
  (vector (ddref buf 0)
          (ddref buf 1)
          (ddref buf 2)
          (ddref buf 3)))

(clear-input-buffer)
;;(ddref input-buffer 2)


(defun read-key ()
  (let ((bytes 0)
        (ifd (screen-ifd (current-screen))))
    (clear-input-buffer)
    (setq bytes (sb-posix:read ifd
                               input-buffer
                               4))
    (values bytes
            (input-to-vector input-buffer))))


(defun read-key-raw ()
  (let ((bytes 0)
        (ifd (screen-ifd (current-screen))))
    (clear-input-buffer)
    (unwind-protect
         (tty-device-termios-set :packet)
      (setq bytes (sb-posix:read ifd
                                 input-buffer
                                 4))
      (tty-device-termios-set :reset))
    (values bytes
            (input-to-vector input-buffer))))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.