Terminal control/Hiding the cursor: Difference between revisions

(Add PHP)
Line 276:
usleep(4e6) NB. wait 4 seconds
smoutput SHOWCURSOR
</syntaxhighlight>
 
=={{header|jq}}==
{{works with|jq}}
Also works with gojq, the Go implementation.
 
'''Invocation''': jq -nrR -f hiding-the-cursor.jq
<syntaxhighlight lang="jq">
# Be busy for at least the given number of seconds,
# and emit the actual number of seconds that have elapsed.
def sleep($seconds):
now
| . as $now
| until( . - $now >= $seconds; now)
| . - $now ;
 
def demo:
def ESC: "\u001B";
def reset: "\(ESC)[0H\(ESC)[0J\(ESC)[?25h";
 
reset,
"Now you see it ...",
(sleep(2) | empty),
"\(ESC)[?25l", # hide the cursor
"... now you don't.",
"Press RETURN to reset the screen and cursor.",
(first(inputs) | empty),
reset;
 
demo
</syntaxhighlight>
 
2,460

edits