Terminal control/Hiding the cursor: Difference between revisions

From Rosetta Code
(→‎Tcl: Added implementation)
(No difference)

Revision as of 23:30, 29 November 2010

Terminal control/Hiding the cursor is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

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

PicoLisp

<lang PicoLisp>(call "tput" "civis") # Invisible (wait 1000) (call "tput" "cvvis") # Visible</lang>

Tcl

<lang tcl>proc cursor Template:State "normal" {

   switch -- $state {

"normal" {set op "cnorm"} "invisible" {set op "civis"} "visible" {set op "cvvis"}

   }
   # Should be just: “exec tput $op” but it's not actually supported on my terminal...
   exec sh -c "tput $op || true"

}</lang> Demonstration code: <lang tcl>cursor normal puts "normal cursor" after 3000 cursor invisible puts "invisible cursor" after 3000 cursor visible puts "very visible cursor" after 3000 cursor normal puts "back to normal" after 1000</lang>