How is the rotation slash made in emerge ? ( / ) He writes: Calculating dependencies /

And the slash rotates. How is this done? I want to repeat.

  • Probably every time the same line is reprinted, only one character changes: -, \, |, / - Deadkenny
  • Yes. But all this is done in one place ... - user26699
  • I think consistently, in the same position, with a slight delay, output the characters / - \ | - avp
  • 2
    @egordorichev can, when outputting to the console, control the carriage using the symbol '\ r' printf ("hello"); printf ("\ rbye"); - Deadkenny
  • Thank! Redo the answer, please! - user26699

3 answers 3

I'm pretty sure that they (emerge) do it this way (and not \ r and output the entire line, which would cause some ripples on the screen)

You can try and play around with a delay (usleep)

 #include <stdio.h> int main (int ac, char *av[]) { int i, j; char *s = "/-\\|"; fputs("test ", stdout); fflush(stdout); for (i = 0; i < 100; i++) for (j = 0; j < 4; j++) { printf("\b%c", s[j]); fflush(stdout); // символ \b -- BACKSPACE -- шаг назад usleep(100000); } } 
  • Thank you very much! Exactly what is needed! - user26699

If only one character needs to be retyped - just typing \ b - moves the cursor back 1 position.

    Probably every time the same line is reprinted, only one character changes: -, \, |, / -

    when outputting to the console, you can control the carriage using the '\ r' character

     printf("hello"); printf("\rbye");