Terminal control/Positional read: Difference between revisions

Add an example for Common Lisp using ncurses
m (→‎{{header|Raku}}: Fix code: Perl 6 --> Raku)
(Add an example for Common Lisp using ncurses)
Line 110:
return 0;
}</lang>
 
=={{header|Common Lisp}}==
==={{header|ncurses}}===
To interface the ncurses C library from Lisp, the ''croatoan'' library is used.
<lang lisp>(defun positional-read ()
(with-screen (scr :input-blocking t :input-echoing nil :cursor-visible nil)
;; print random characters in a 10x20 grid
(loop for i from 0 to 9 do
(loop for j from 0 to 19 do
(add-char scr (+ 33 (random 94)) :y i :x j)))
;; highlight char to extract at row 6 column 3
(change-attributes scr 1 (list :reverse) :y 5 :x 2)
(refresh scr)
;; wait for keypress
(get-char scr)
;; extract char from row 6 column 3
(let ((char (extract-char scr :y 5 :x 2)))
;; then print it out again
(move scr 11 0)
(format scr "extracted char: ~A" char))
(refresh scr)
(get-char scr)))</lang>
 
=={{header|Go}}==
69

edits