Skip to content

Instantly share code, notes, and snippets.

@j000
Created June 20, 2018 13:42
Show Gist options
  • Save j000/30a8c14e7a4dc23594f6865b278440d8 to your computer and use it in GitHub Desktop.
Save j000/30a8c14e7a4dc23594f6865b278440d8 to your computer and use it in GitHub Desktop.
#define spacje " "
void prawa(int linia,char *tekst)
{
pthread_mutex_lock(&print);
/* wyczyść linijkę */
printf("\033[%u;0H" spacje spacje, linia);
/* przenieś kursor na prawą stronę */
printf("\033[%u;0H" spacje, linia);
/* wypisz nasz tekst */
printf("%s", tekst);
/* wypisz wewnętrzny bufor na konsole (trzeba, bo nie ma nigdzie \n) */
fflush(stdout);
pthread_mutex_unlock(&print);
}
void lewa(int linia, char *tekst)
{
pthread_mutex_lock(&print);
/* wyczyść linijkę */
printf("\033[%u;0H" spacje spacje, linia);
/* przenieś kursor na lewą stronę */
printf("\033[%u;0H", linia);
/* wypisz nasz tekst */
printf("%s", tekst);
/* wypisz wewnętrzny bufor na konsole (trzeba, bo nie ma nigdzie \n) */
fflush(stdout);
pthread_mutex_unlock(&print);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment