From cefb7fb871c4684794fddebe7915206b1226686f Mon Sep 17 00:00:00 2001 From: Ben Wiley Sittler Date: Tue, 4 Nov 2008 05:21:34 +0000 Subject: [PATCH] phpized --- caca-php/examples/unicode.php | 160 ++++++++++++++++------------------ 1 file changed, 73 insertions(+), 87 deletions(-) mode change 100644 => 100755 caca-php/examples/unicode.php diff --git a/caca-php/examples/unicode.php b/caca-php/examples/unicode.php old mode 100644 new mode 100755 index 2d01a3a..9578f5d --- a/caca-php/examples/unicode.php +++ b/caca-php/examples/unicode.php @@ -1,5 +1,11 @@ +#!/usr/bin/php5 + + * + * This file is a Php port of "examples/unicode.c" + * which is: * Copyright (c) 2006 Sam Hocevar * All Rights Reserved * @@ -12,92 +18,72 @@ * http://sam.zoy.org/wtfpl/COPYING for more details. */ -#include "config.h" - -#if !defined(__KERNEL__) -# include -#endif - -#include "caca.h" - -int main(int argc, char *argv[]) +$cv = caca_create_canvas(0, 0); +if(! $cv) { - caca_canvas_t *cv; - caca_display_t *dp; - - cv = caca_create_canvas(0, 0); - if(cv == NULL) - { - printf("Can't created canvas\n"); - return -1; - } - dp = caca_create_display(cv); - if(dp == NULL) - { - printf("Can't create display\n"); - return -1; - } - caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE); - caca_put_str(cv, 1, 1, "Basic Unicode support"); - - caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT); - caca_put_str(cv, 1, 2, "This is ASCII: | abc DEF 123 !@# |"); - caca_put_str(cv, 1, 3, "This is Unicode: | äßç δεφ ☺♥♀ ╞╬╗ |"); - caca_put_str(cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |"); - - caca_put_str(cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere."); - - caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE); - caca_put_str(cv, 1, 7, "Gradient glyphs"); - - caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT); - caca_put_str(cv, 31, 8, " 0%"); - caca_put_str(cv, 31, 9, " 25%"); - caca_put_str(cv, 31, 10, " 50%"); - caca_put_str(cv, 31, 11, " 75%"); - caca_put_str(cv, 31, 12, "100%"); - - caca_set_color_ansi(cv, CACA_LIGHTRED, CACA_LIGHTGREEN); - caca_put_str(cv, 1, 8, " "); - caca_put_str(cv, 1, 9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"); - caca_put_str(cv, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); - caca_put_str(cv, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"); - caca_put_str(cv, 1, 12, "█████████████████████████████"); - - caca_set_color_ansi(cv, CACA_LIGHTGREEN, CACA_LIGHTRED); - caca_put_str(cv, 36, 8, "█████████████████████████████"); - caca_put_str(cv, 36, 9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"); - caca_put_str(cv, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); - caca_put_str(cv, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"); - caca_put_str(cv, 36, 12, " "); - - caca_set_color_ansi(cv, CACA_WHITE, CACA_BLUE); - caca_put_str(cv, 1, 14, "Double width characters"); - - caca_set_color_ansi(cv, CACA_LIGHTRED, CACA_TRANSPARENT); - caca_put_str(cv, 1, 15, "| ドラゴン ボーレ |"); - caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT); - caca_put_str(cv, 1, 16, "| ()()()() ()()() |"); - caca_set_color_ansi(cv, CACA_YELLOW, CACA_TRANSPARENT); - caca_put_str(cv, 1, 17, "| ドラゴン"); - caca_put_str(cv, 12, 17, "ボーレ |"); - - caca_set_color_ansi(cv, CACA_DEFAULT, CACA_TRANSPARENT); - caca_put_str(cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere."); - - caca_put_str(cv, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼"); - caca_put_str(cv, 1, 21, "more CP437: α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■"); - caca_put_str(cv, 1, 22, "drawing blocks: ███ ▓▓▓ ▒▒▒ ░░░ ▀ ▄ ▌ ▐ █ ▖ ▗ ▘ ▝ ▚ ▞ ▙ ▛ ▜ ▟ ─ │ ┌ ┐ └ ┘ ├ ┤"); - caca_put_str(cv, 1, 23, "more drawing: ┬ ┴ ┼ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬"); - caca_put_str(cv, 1, 24, "misc Unicode: ● ☭ ☮ ☯ ♔ ♛ ♙ ♞ ⚒ ⚓ ⚠"); - - caca_refresh_display(dp); - - caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1); - - caca_free_display(dp); - caca_free_canvas(cv); - - return 0; + die("Can't created canvas\n"); } - +$dp = caca_create_display($cv); +if(! $dp) +{ + die("Can't create display\n"); +} +caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE); +caca_put_str($cv, 1, 1, "Basic Unicode support"); + +caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); +caca_put_str($cv, 1, 2, "This is ASCII: | abc DEF 123 !@# |"); +caca_put_str($cv, 1, 3, "This is Unicode: | äßç δεφ ☺♥♀ ╞╬╗ |"); +caca_put_str($cv, 1, 4, "And this is, too: | ἀβϛ ΔЗҒ ᚴᛒᛯ ♩♔✈ |"); + +caca_put_str($cv, 1, 5, "If the three lines do not have the same length, there is a bug somewhere."); + +caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE); +caca_put_str($cv, 1, 7, "Gradient glyphs"); + +caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); +caca_put_str($cv, 31, 8, " 0%"); +caca_put_str($cv, 31, 9, " 25%"); +caca_put_str($cv, 31, 10, " 50%"); +caca_put_str($cv, 31, 11, " 75%"); +caca_put_str($cv, 31, 12, "100%"); + +caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_LIGHTGREEN); +caca_put_str($cv, 1, 8, " "); +caca_put_str($cv, 1, 9, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"); +caca_put_str($cv, 1, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); +caca_put_str($cv, 1, 11, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"); +caca_put_str($cv, 1, 12, "█████████████████████████████"); + +caca_set_color_ansi($cv, CACA_LIGHTGREEN, CACA_LIGHTRED); +caca_put_str($cv, 36, 8, "█████████████████████████████"); +caca_put_str($cv, 36, 9, "▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓"); +caca_put_str($cv, 36, 10, "▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒"); +caca_put_str($cv, 36, 11, "░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"); +caca_put_str($cv, 36, 12, " "); + +caca_set_color_ansi($cv, CACA_WHITE, CACA_BLUE); +caca_put_str($cv, 1, 14, "Double width characters"); + +caca_set_color_ansi($cv, CACA_LIGHTRED, CACA_TRANSPARENT); +caca_put_str($cv, 1, 15, "| ドラゴン ボーレ |"); +caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); +caca_put_str($cv, 1, 16, "| ()()()() ()()() |"); +caca_set_color_ansi($cv, CACA_YELLOW, CACA_TRANSPARENT); +caca_put_str($cv, 1, 17, "| ドラゴン"); +caca_put_str($cv, 12, 17, "ボーレ |"); + +caca_set_color_ansi($cv, CACA_DEFAULT, CACA_TRANSPARENT); +caca_put_str($cv, 1, 18, "If the three lines do not have the same length, there is a bug somewhere."); + +caca_put_str($cv, 1, 20, "CP437 glyphs: ☺ ☻ ♥ ♦ ♣ ♠ • ◘ ○ ◙ ♂ ♀ ♪ ♫ ☼ ► ◄ ↕ ‼ ¶ § ▬ ↨ ↑ ↓ → ← ∟ ↔ ▲ ▼"); +caca_put_str($cv, 1, 21, "more CP437: α ß Γ π Σ σ µ τ Φ Θ Ω δ ∞ φ ε ∩ ≡ ± ≥ ≤ ⌠ ⌡ ÷ ≈ ° ∙ · √ ⁿ ² ■"); +caca_put_str($cv, 1, 22, "drawing blocks: ███ ▓▓▓ ▒▒▒ ░░░ ▀ ▄ ▌ ▐ █ ▖ ▗ ▘ ▝ ▚ ▞ ▙ ▛ ▜ ▟ ─ │ ┌ ┐ └ ┘ ├ ┤"); +caca_put_str($cv, 1, 23, "more drawing: ┬ ┴ ┼ ═ ║ ╒ ╓ ╔ ╕ ╖ ╗ ╘ ╙ ╚ ╛ ╜ ╝ ╞ ╟ ╠ ╡ ╢ ╣ ╤ ╥ ╦ ╧ ╨ ╩ ╪ ╫ ╬"); +caca_put_str($cv, 1, 24, "misc Unicode: ● ☭ ☮ ☯ ♔ ♛ ♙ ♞ ⚒ ⚓ ⚠"); + +caca_refresh_display($dp); + +caca_get_event($dp, CACA_EVENT_KEY_PRESS, -1); + +?>