Terminal control/Hiding the cursor: Difference between revisions
m
syntax highlighting fixup automation
(Added solution for Action!) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 6:
=={{header|Action!}}==
<
BYTE RTCLOK=$14
frames==+RTCLOK
Line 24:
CRSINH=0 PutE() ;put the new line character to force show the cursor
Wait(50)
RETURN</
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Hiding_the_cursor.png Screenshot from Atari 8-bit computer]
Line 30:
=={{header|Ada}}==
{{libheader|ANSIAda}}
<
with Ansi;
Line 46:
delay 2.000;
New_Line;
end Hiding;</
=={{header|Arturo}}==
<
print "hiding the cursor"
Line 56:
cursor true
print "showing the cursor"</
=={{header|AutoHotkey}}==
Keep in mind that AHK is not built for the command line, so we must call the WinAPI directly.
<
hConsole := DllCall("GetStdHandle", UInt, STDOUT := -11)
Line 75:
FileAppend, `nCursor shown, CONOUT$
MsgBox</
=={{header|BaCon}}==
<
CURSOR OFF
CURSOR ON</
=={{header|BASIC}}==
Line 86:
{{works with|FreeBASIC}}
<
LOCATE , , 0
'wait for a keypress...
SLEEP
'show the cursor:
LOCATE , , 1</
==={{header|Applesoft BASIC}}===
<syntaxhighlight lang
=={{header|BBC BASIC}}==
32-bit BBC BASICs:
<
WAIT 400
ON : REM Show the cursor again</
All BBC BASICs:
<
T%=TIME+400:REPEAT UNTIL TIME>T%
VDU 23,1,1;0;0;0; : REM Show the cursor again</
=={{header|Befunge}}==
Assuming a terminal with support for ANSI escape sequences, this hides the cursor, waits for the user to press ''Enter'', and then shows the cursor again.
<
"retnE sserP">:#,_v>
"h52?["39*,,,,,,@ >~</
=={{header|C}}==
<syntaxhighlight lang="c">
/* Please note that curs_set is terminal dependent. */
Line 132:
return 0;
}
</syntaxhighlight>
=={{header|C sharp|C#}}==
{{works with|Mono|1.2}}
{{works with|Visual C sharp|Visual C#|2003}}
<
{
Console.Write("At the end of this line you will see the cursor, process will sleep for 5 seconds.");
Line 145:
Console.Write("At the end of this line you will not see the cursor, process will sleep for 5 seconds.");
System.Threading.Thread.Sleep(5000);
}</
=={{header|C++}}==
<
#include <Windows.h>
int main()
Line 160:
SetConsoleCursorInfo(out, &cursorInfo); // Apply changes
}
</syntaxhighlight>
=={{header|Common Lisp}}==
<
(defun sh (cmd)
#+clisp (shell cmd)
Line 177:
(show-cursor t)
(sleep 3)
</syntaxhighlight>
==={{header|ncurses}}===
To interface the ncurses C library from Lisp, the ''croatoan'' library is used.
<
(with-screen (scr :input-echoing nil :input-blocking t)
(setf (cursor-visible-p scr) nil)
Line 191:
(format scr "cursor-visible-p: ~A" (cursor-visible-p scr))
(refresh scr)
(get-char scr)))</
=={{header|FunL}}==
<
import console.*
hide()
sleep( 2 Second )
show()</
=={{header|Furor}}==
Hide:
<syntaxhighlight lang="furor">
cursoroff
</syntaxhighlight>
Show:
<syntaxhighlight lang="furor">
cursoron
</syntaxhighlight>
=={{header|Go}}==
===External command===
<
import (
Line 232:
cmd.Stdout = os.Stdout
return cmd.Run()
}</
===Escape code===
(Not sure if this is ANSI, but it worked for me.)
<
import (
Line 247:
fmt.Print("\033[?25h")
time.Sleep(3 * time.Second)
}</
===Ncurses===
{{libheader|Curses}}
<
import (
Line 269:
gc.Cursor(1)
s.GetChar()
}</
=={{header|J}}==
With the definitions of [[Terminal_control/Coloured_text#J]]
<
usleep(4e6) NB. wait 4 seconds
smoutput SHOWCURSOR
</syntaxhighlight>
=={{header|Julia}}==
{{trans|Perl}}
<
print("$ESC[?25l") # hide the cursor
print("Enter anything, press RETURN: ") # prompt shown
Line 287:
sleep(3)
println()
</syntaxhighlight>
=={{header|Kotlin}}==
{{Works with|Ubuntu|14.04}}
<
fun main(args: Array<String>) {
Line 298:
print("\u001B[?25h") // display cursor
Thread.sleep(2000) // wait 2 more seconds before exiting
}</
=={{header|Lasso}}==
<
local(
Line 317:
// wait for 4 seconds to give time discover the cursor is back
sleep(4000)</
=={{header|Locomotive Basic}}==
<
20 FOR l = 1 TO 2000: REM delay
30 NEXT l
40 CURSOR 1: REM show cursor</
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
Pause[2]
Run["tput cvvis"] (* Cursor Visible *)</
=={{header|Nemerle}}==
<
using System.Threading.Thread;
Line 343:
}
}
}</
=={{header|Nim}}==
<
echo "Cursor hidden. Press a key to show the cursor and exit."
Line 353:
discard getCh()
stdout.showCursor()
</syntaxhighlight>
=={{header|Perl}}==
<
print "Enter anything, press RETURN: "; # prompt shown
$input = <>; # but no cursor
print "\e[0H\e[0J\e[?25h"; # reset, visible again</
=={{header|Phix}}==
<!--<
<span style="color: #7060A8;">cursor</span><span style="color: #0000FF;">(</span><span style="color: #004600;">NO_CURSOR</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">sleep</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">cursor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">UNDERLINE_CURSOR</span><span style="color: #0000FF;">)</span>
<!--</
=={{header|PicoLisp}}==
<
(wait 1000)
(call "tput" "cvvis") # Visible</
=={{header|PureBasic}}==
<
If OpenConsole()
Line 387:
EndIf
ForEver
EndIf </
Tested with <b>PB v5.60</b>
<
ConsoleCursor(0)
EndProcedure
Line 414:
ShowCursor(-0.5)
Print("press [Enter] to continue ... ") : Input()
EndIf</
=={{header|Python}}==
With print:
<
print("\x1b[?25h") # shown
</syntaxhighlight>
With curses:
<
import time
Line 433:
time.sleep(2)
curses.endwin()
</syntaxhighlight>
=={{header|Quackery}}==
Line 442:
On some platforms the cursor visibility will not change until the output buffer is flushed by for example a cr/lf.
<
[ $ &print("\x1b[?25h",end='')& python ] is show ( --> )</
=={{header|R}}==
Line 450:
{{trans|Python}}
<
Sys.sleep(2)
cat("\x1b[?25h") # Show</
=={{header|Racket}}==
<
#lang racket
(void (system "tput civis")) (sleep 2) (void (system "tput cvvis"))
</syntaxhighlight>
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku"
run 'tput', 'civis';
sleep 5;
run 'tput', 'cvvis';</
=={{header|REXX}}==
{{works with|Regina REXX}}
<
z=rxfuncadd('sysloadfuncs', "regutil", 'sysloadfuncs') /*add a function lib.*/
if z\==0 then do /*test the return cod*/
Line 488:
call syscurstate 'on' /*(unhide) the displaying of the cursor*/
say 'showing of the cursor is now on' /*inform that the cursor is now showing*/
/*stick a fork in it, we're all done. */</
'''output'''
<pre>
Line 497:
=={{header|Ring}}==
<
# Project : Terminal control/Hiding the cursor
Line 507:
? "Show Cursor using tput utility"
system("tput cnorm") # Normal
</syntaxhighlight>
=={{header|Ruby}}==
<
include Curses
Line 523:
ensure
close_screen
end</
=={{header|Scala}}==
<
print("\u001B[?25l") // hide cursor
Thread.sleep(2000) // wait 2 seconds before redisplaying cursor
print("\u001B[?25h") // display cursor
Thread.sleep(2000) // wait 2 more seconds before exiting
}</
=={{header|Tcl}}==
<
proc cursorVisibility {{state normal}} {
switch -- $state {
Line 543:
exec -- >@stdout tput $op
}
</syntaxhighlight>
Demo:
<
foreach x {visible invisible normal} {
cursorVisibility $x
Line 553:
puts {}
}
</syntaxhighlight>
=={{header|UNIX Shell}}==
<
sleep 5 # Sleep for 5 seconds
tput cnorm # Show the cursor</
=={{header|Wren}}==
{{trans|Go}}
<
System.print("\e[?25l")
Timer.sleep(3000)
System.print("\e[?25h")
Timer.sleep(3000)</
=={{header|XPL0}}==
<
proc ShowCur(On); \Turn flashing cursor on or off
Line 585:
if ChIn(1) then []; \wait for keystroke
ShowCur(true); \turn on flashing cursor
]</
=={{header|zkl}}==
{{trans|Go}}
Hide the cursor for three seconds on an ANSI terminal
<
Atomic.sleep(3);
print("\e[?25h");</
{{omit from|ACL2}}
|