Terminal control/Hiding the cursor: Difference between revisions

m
Line 457:
 
=={{header|Tcl}}==
<lang tcl>proc cursor {{state "normal"}} {
proc cursorVisibility {{state normal}} {
switch -- $state {
"normal" invisible {set op "cnorm"civis}
"invisible"visible {set op "civis"cvvis}
"visible"normal {set op "cvvis"cnorm}
}
exec sh -c- >@stdout "tput $op || true"
# Should be just: “exec tput $op” but it's not actually supported on my terminal...
}
exec sh -c "tput $op || true"
}</lang>
Demo:
Demonstration code:
<lang tcl>cursor normal
foreach x {visible invisible normal} {
puts "normal cursor"
cursorVisibility $x
after 3000
puts -nonewline "$x cursor -> "
cursor invisible
flush stdout
puts "invisible cursor"
after 3000
puts {}
cursor visible
}
puts "very visible cursor"
after 1000</lang>
after 3000
cursor normal
puts "back to normal"
after 1000</lang>
 
=={{header|UNIX Shell}}==
Anonymous user