Terminal control/Hiding the cursor: Difference between revisions
Content added Content deleted
m (→{{header|Tcl}}) |
|||
Line 457: | Line 457: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
<lang tcl> |
<lang tcl> |
||
proc cursorVisibility {{state normal}} { |
|||
switch -- $state { |
switch -- $state { |
||
invisible {set op civis} |
|||
visible {set op cvvis} |
|||
normal {set op cnorm} |
|||
} |
} |
||
⚫ | |||
# Should be just: “exec tput $op” but it's not actually supported on my terminal... |
|||
} |
|||
⚫ | |||
</lang> |
|||
Demo: |
|||
Demonstration code: |
|||
<lang tcl> |
<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" |
|||
⚫ | |||
after 3000 |
|||
cursor normal |
|||
puts "back to normal" |
|||
⚫ | |||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |