Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

C# How did they create wait cursor?, In character subsystem

views
     
silverhawk
post Mar 18 2022, 03:06 PM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


This is done quite commonly in bash scripts, there are plenty of ways to do progress indicators as well. Here's a simple spinner example

CODE

#!/bin/bash
function shutdown() {
   # reset cursor
   tput cnorm
}
trap shutdown EXIT

function spinner() {
   # cursor invisible
   tput civis

   frames='-\|/'
   input=""
   i=0
   while [[ -z $input ]]; do
       read -rsn1 -t 0.1 input

       i=$(( (i+1) %4 ))
       printf "\r${frames:$i:1}"
       sleep .1
   done

   # restore cursor
   tput cnorm
}

spinner

silverhawk
post Mar 19 2022, 08:53 PM

Eyes on Target
Group Icon
Elite
4,956 posts

Joined: Jan 2003


QUOTE(FlierMate @ Mar 19 2022, 05:23 PM)
Yes, that "frames='-\|/'" is one of the popular way to do it.

When you mean progress indicator, do you mean this?
CODE

.
..
...
.
..
...
(and repeats)

*
Like a normal progress bar you see on windows when you're transferring a file. Its quite common in command line scripts now.


 

Change to:
| Lo-Fi Version
0.0174sec    0.50    6 queries    GZIP Disabled
Time is now: 18th December 2025 - 02:39 AM