Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SPECIFIC] Programowanie w C/C++ pod Linuxem
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish) Polish OTW
View previous topic :: View next topic  
Author Message
Belliash
Advocate
Advocate


Joined: 24 Nov 2004
Posts: 2401
Location: Legnica, Poland

PostPosted: Tue Oct 30, 2007 8:44 pm    Post subject: [SPECIFIC] Programowanie w C/C++ pod Linuxem Reply with quote

Witam,

Zastanawiam sie od pewnego juz czasu jak moglbym w programie napisanym w C zmienic kolor czcionki (w CLI)?

pewnie moglbym wpisac:
Code:
 for (i = 31; i <= 37; i++)
   {
       printf("\033[0;%dmHello!\033[0m\n", i);
       printf("\033[1;%dmHello!\033[0m\n", i);
    }



Ale to bym musial przy kazdym printf tak...

W DOSie uzywajac borlanda moglem wpisac:
Code:
textcolor(15);
clrscr();


i co bym nie wypisal bylo biale :P
da sie cos takiego w ogole zrobic na linuksie?
_________________
Asio Software Technologies
Belliash IT Weblog
Back to top
View user's profile Send private message
no4b
Bodhisattva
Bodhisattva


Joined: 18 Jan 2004
Posts: 774
Location: Tarnów, Poland

PostPosted: Tue Oct 30, 2007 9:43 pm    Post subject: Reply with quote

Użyj ncurses.
_________________
GTK2/GNOME - The weakest link!
Back to top
View user's profile Send private message
Belliash
Advocate
Advocate


Joined: 24 Nov 2004
Posts: 2401
Location: Legnica, Poland

PostPosted: Tue Oct 30, 2007 9:46 pm    Post subject: Reply with quote

no4b wrote:
Użyj ncurses.



sek w tym ze wole bez ncurses...
_________________
Asio Software Technologies
Belliash IT Weblog
Back to top
View user's profile Send private message
13Homer
Guru
Guru


Joined: 12 Jul 2005
Posts: 461

PostPosted: Wed Oct 31, 2007 6:01 am    Post subject: Reply with quote

To napisz własną funkcję analogiczną do printf, która będzie odpowiednio ustawiała kolory korzystając ze zmiennej globalnej. Ja często tak robię, gdy muszę np. warunkowo coś wypisać: na podstawie globalnej flagi włączającej debug ustawianej z linii poleceń. To, że printf jest funkcją biblioteczną nie oznacza, że nie możesz jej w coś opakować.
_________________
Lenovo ThinkPad R61 / C2D@2.6.24 / nVidia Quatro NVS 140M / 2 GB RAM
Back to top
View user's profile Send private message
sebas86
Guru
Guru


Joined: 01 May 2005
Posts: 526
Location: Szczecinek / Szczecin

PostPosted: Wed Oct 31, 2007 7:23 am    Post subject: Reply with quote

To skoro C\C++ może napisz własną klasę color i przeciąż operator << dla cout. :)
_________________
Nieważne jaka dystrybucja, ważne, że Linux!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Polskie forum (Polish) Polish OTW All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum