How to resolve the algorithm Terminal control/Hiding the cursor step by step in the Common Lisp programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Terminal control/Hiding the cursor step by step in the Common Lisp programming language

Table of Contents

Problem Statement

The task is to hide the cursor and show it again.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Terminal control/Hiding the cursor step by step in the Common Lisp programming language

Source code in the common programming language

(defun sh (cmd)
  #+clisp (shell cmd)
  #+ecl (si:system cmd)
  #+sbcl (sb-ext:run-program "/bin/sh" (list "-c" cmd) :input nil :output *standard-output*)
  #+clozure (ccl:run-program "/bin/sh" (list "-c" cmd) :input nil :output *standard-output*))

(defun show-cursor (x)
  (if x (sh "tput cvvis") (sh "tput civis")))

(show-cursor nil)
(sleep 3)
(show-cursor t)
(sleep 3)


(defun hide-show-cursor ()
  (with-screen (scr :input-echoing nil :input-blocking t)
    (setf (cursor-visible-p scr) nil)
    (format scr "cursor-visible-p: ~A~%" (cursor-visible-p scr))
    (refresh scr)
    ;; wait for a keypress
    (get-char scr)
    (setf (cursor-visible-p scr) t)
    (format scr "cursor-visible-p: ~A" (cursor-visible-p scr))
    (refresh scr)
    (get-char scr)))


  

You may also check:How to resolve the algorithm Factorial step by step in the Little Man Computer programming language
You may also check:How to resolve the algorithm Day of the week step by step in the SQL programming language
You may also check:How to resolve the algorithm JortSort step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Stem-and-leaf plot step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm 100 doors step by step in the SheerPower 4GL programming language