[C/C++] Farbige Konsole?

Dieses Thema im Forum "Programmierung & Entwicklung" wurde erstellt von dynastor, 13. März 2007 .

Schlagworte:
  1. 13. März 2007
    Farbige Konsole?

    Ich hab mal 'ne Frage, und zwar ist es möglich in C farbige Texte auszugeben ohne selbst 1000 Funktionen etc. schreiben zu müssen?
    Ich habe mal gegooglet, aber nichts gefunden was mir wirklich weitergeholfen hat

    freue mich über jede antwort
     
  2. 13. März 2007
    AW: Farbige Konsole?

    Mit ncurses/curses kannst du Texte farbig, dick, kursiv und unterstrichen schreiben.
     
  3. 13. März 2007
    AW: Farbige Konsole?

    Bitte bitte -> Goolge

    Windows Konsole:
    Mit dem Befehl System(http://www.codeproject.com/csharp/console_apps__colour_text.asp) oder:
    Change text color using visual c++ | DaniWeb oder
    http://www.winsite.com/bin/Info?21500000036673

    Linux (NCurses):
    Ncurses: Grundlegendes – Wikibooks, Sammlung freier Lehr-, Sach- und Fachbücher
     
  4. 13. März 2007
    AW: Farbige Konsole?

    Code:
    [COLOR="DarkGreen"]#include <windows.h>[/COLOR]
    [..]
    [COLOR="DarkGreen"]#define BLACK 0
    #define BLUE 1
    #define GREEN 2
    #define CYAN 3
    #define RED 4
    #define MAGENTA 5
    #define BROWN 6
    #define LIGHTGREY 7
    #define DARKGREY 8
    #define LIGHTBLUE 9
    #define LIGHTGREEN 10
    #define LIGHTCYAN 11
    #define LIGHTRED 12
    #define LIGHTMAGENTA 13
    #define YELLOW 14
    #define WHITE 15[/COLOR]
    
    void TextColor(int fontcolor,int backgroundcolor)
    {
     int color_attribute;
     HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);
     
     color_attribute = (backgroundcolor << 4) | fontcolor;
     SetConsoleTextAttribute(screen,color_attribute);
    }
    
    void FillConsoleColor(int fontcolor,int backgroundcolor, int X, int Y, int length)
    {
     int color_attribute;
     COORD point;
     HANDLE screen = GetStdHandle(STD_OUTPUT_HANDLE);
     
     color_attribute = (backgroundcolor << 4) | fontcolor; 
     point.X = X; point.Y = Y; 
     FillConsoleOutputAttribute(screen, color_attribute, length, point , NULL); 
    }
    
    Zwei Funktionen:
    TextColor um den die Farbe festzulegen für den nächsten Auszugebenden Text.
    FillConsoleColor um die Farbattribute auf der Konsole direkt zu ändern.

    Im allgemeinen kannst du also "SetConsoleTextAttribute" und\ oder "FillConsoleOutputAttribute" benutzen.

    Mfg

    Rushh0ur
     
  5. 14. März 2007
    AW: Farbige Konsole?

    (N)Curses gibts auch fuer Windows .
     
  6. Video Script

    Videos zum Themenbereich

    * gefundene Videos auf YouTube, anhand der Überschrift.