Terminal control/Hiding the cursor: Difference between revisions

Content added Content deleted
Line 457: Line 457:


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


=={{header|UNIX Shell}}==
=={{header|UNIX Shell}}==