colored console/de: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | - | ||
| 2 | - | ||
| 3 | - | ||
| 4 | - | ||
| 5 | - | ||
| 6 | - | ||
| 1 | + | Zurück zur [[Console/de|Konsolenseite]].\ | |
| 7 | 2 | ||
| 8 | - | ||
| 9 | - | ||
| 10 | - | ||
| 11 | - | ||
| 3 | + | =Farbige Konsolenausgabe= Dieser Artikel dient der Konsolen- / Terminalprogrammierung unter Windows und Linux.\ | |
| 12 | 4 | ||
| 13 | - | ||
| 14 | - | ||
| 15 | - | ||
| 5 | + | Die Konsole kennt 16 Farbkonstanten von 0 (=Schwarz) bis 15 (=Weiss).\ | |
| 6 | + | Die genaue Anzeige der Farbwerte hängt von verschiedenen Faktoren ab:\ | |
| 7 | + | * der Grafikkarte | |
| 16 | 8 | ||
| 17 | - | ||
| 9 | + | - dem Grafiktreiber | |
| 10 | + | - dem Betriebssystem | |
| 18 | 11 | ||
| 19 | - | ||
| 20 | - | ||
| 21 | - | ||
| 22 | - | ||
| 23 | - | ||
| 24 | - | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - | ||
| 29 | - | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - | ||
| 36 | - | ||
| 37 | - | ||
| 38 | - | ||
| 39 | - | ||
| 12 | + | und kann somit von Computer zu Computer etwas anders ausfallen.\ | |
| 13 | + | {\| class="wikitable sortable" ! Farbe !! Farbkonstante !! Dezimalwert \|- \|Schwarz \|Black \| 0 \|- \|Blau \|Blue \| 1 \|- \|Grün \|Green \| 2 \|- \|Türkis \|Cyan \| 3 \|- \|Rot \|Red \| 4 \|- \|Weinrot \|Magenta \| 5 \|- \|Braun \|Brown \| 6 \|- \|Hellgrau \|LightGray \| 7 \|- \|Dunkelgrau \|DarkGray \| 8 \|- \|Hellblau \|LightBlue \| 9 \|- \|Hellgrün \|LightGreen \|10 \|- \|Helltürkis \|LightCyan \|11 \|- \|Hellrot \|LightRed \|12 \|- \|Hellweinrot \|LightMagenta \|13 \|- \|Gelb \|Yellow \|14 \|- \|Weiss \|White \|15 \|}\ | |
| 14 | + | Beispiel für den Einsatz von farbiger Schrift:\ | |
| 40 | 15 | ||
| 41 | - | ||
| 16 | + | ``` pascal | |
| 42 | 17 | program project1; | |
| 43 | - | ||
| 44 | - | ||
| 45 | - | ||
| 46 | - | ||
| 47 | - | ||
| 48 | - | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - | ||
| 52 | - | ||
| 53 | - | ||
| 54 | - | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - | ||
| 58 | - | ||
| 59 | - | ||
| 60 | - | ||
| 61 | - | ||
| 62 | - | ||
| 63 | - | ||
| 64 | - | ||
| 65 | - | ||
| 66 | - | ||
| 67 | - | ||
| 68 | - | ||
| 69 | - | ||
| 70 | 18 | ||
| 71 | - | ||
| 72 | - | ||
| 19 | + | {$mode objfpc}{$H+} | |
| 20 | + | {$IMPLICITEXCEPTIONS OFF} | |
| 73 | 21 | ||
| 22 | + | uses | |
| 23 | + | Crt; | |
| 24 | + | ||
| 25 | + | begin | |
| 26 | + | ||
| 27 | + | // Setzt die Vordergrundfarbe | |
| 28 | + | TextColor(LightBlue); | |
| 29 | + | write('H'); | |
| 30 | + | TextColor(Green); | |
| 31 | + | write('a'); | |
| 32 | + | TextColor(Cyan); | |
| 33 | + | write('l'); | |
| 34 | + | TextColor(Red); | |
| 35 | + | write('l'); | |
| 36 | + | TextColor(Magenta); | |
| 37 | + | write('o'); | |
| 38 | + | ||
| 39 | + | // Dieser Abschnitt wird unter einigen Linux-, einigen Windowsversionen | |
| 40 | + | // und DOS benötigt, da nicht bei allen Versionen nach der letzten Ausgabe | |
| 41 | + | // der Prompt automatisch auf die Standard Farbe zurück gesetzt wird. | |
| 42 | + | TextColor(LightGray); | |
| 43 | + | end. | |
| 74 | 44 | ``` | |
| 45 | + | ||
| 46 | + | Beispiel für den Einsatz von farbigem Hintergrund:\ | |
| 47 | + | ||
| 48 | + | ``` pascal | |
| 75 | 49 | program project1; | |
| 76 | - | ||
| 77 | - | ||
| 78 | - | ||
| 79 | - | ||
| 80 | - | ||
| 81 | - | ||
| 82 | - | ||
| 83 | - | ||
| 84 | - | ||
| 85 | - | ||
| 86 | - | ||
| 87 | - | ||
| 88 | - | ||
| 89 | - | ||
| 90 | - | ||
| 91 | - | ||
| 92 | - | ||
| 93 | - | ||
| 94 | - | ||
| 95 | - | ||
| 96 | - | ||
| 97 | - | ||
| 98 | - | ||
| 99 | - | ||
| 100 | - | ||
| 50 | + | ||
| 51 | + | {$mode objfpc}{$H+} | |
| 52 | + | {$IMPLICITEXCEPTIONS OFF} | |
| 53 | + | ||
| 54 | + | uses | |
| 55 | + | Crt; | |
| 56 | + | ||
| 57 | + | begin | |
| 58 | + | ||
| 59 | + | // Setzt die Hintergrundfarbe | |
| 60 | + | TextBackground(Yellow); | |
| 61 | + | // Setzt die Vordergrundfarbe | |
| 62 | + | TextColor(LightBlue); | |
| 63 | + | // Der Zeilenumbruch sorgt dafür, dass die folgende Zeile | |
| 64 | + | // vollständig in Farbe ausgegeben wird. | |
| 65 | + | writeLn('Hallo Welt'); | |
| 66 | + | TextColor(Red); | |
| 67 | + | write('Hallo Welt'); | |
| 68 | + | ||
| 69 | + | // Dieser Abschnitt wird unter einigen Linux-, einigen Windowsversionen | |
| 70 | + | // und DOS benötigt, da nicht bei allen Versionen nach der letzten Ausgabe | |
| 71 | + | // der Prompt automatisch auf die Standard Farbe zurück gesetzt wird. | |
| 72 | + | TextBackground(Black); | |
| 73 | + | TextColor(LightGray); | |
| 74 | + | end. | |
| 101 | 75 | ``` | |
| 102 | 76 | ||
| 103 | 77 | --- | |
| 104 | - | ||
| 78 | + | *From the Free Pascal wiki, page "colored console/de", as it stood on 2020-02-11 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
