You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

colors.c 2.0 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * colors display all possible libcaca colour pairs
  3. * Copyright (c) 2003-2004 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This program is free software. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. #include "config.h"
  15. #if !defined(__KERNEL__)
  16. # include <stdio.h>
  17. #endif
  18. #include "caca.h"
  19. int main(int argc, char **argv)
  20. {
  21. caca_canvas_t *cv;
  22. caca_display_t *dp;
  23. int i, j;
  24. cv = caca_create_canvas(80, 24);
  25. if(cv == NULL)
  26. {
  27. printf("Failed to create canvas\n");
  28. return 1;
  29. }
  30. dp = caca_create_display(cv);
  31. if(dp == NULL)
  32. {
  33. printf("Failed to create display\n");
  34. return 1;
  35. }
  36. caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK);
  37. caca_clear_canvas(cv);
  38. for(i = 0; i < 16; i++)
  39. {
  40. caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK);
  41. caca_printf(cv, 3, i + (i >= 8 ? 3 : 2), "ANSI %i", i);
  42. for(j = 0; j < 16; j++)
  43. {
  44. caca_set_color_ansi(cv, i, j);
  45. caca_put_str(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
  46. "Aaホ");
  47. }
  48. }
  49. caca_set_color_ansi(cv, CACA_LIGHTGRAY, CACA_BLACK);
  50. caca_put_str(cv, 3, 20, "This is bold This is blink This is italics This is underline");
  51. caca_set_attr(cv, CACA_BOLD);
  52. caca_put_str(cv, 3 + 8, 20, "bold");
  53. caca_set_attr(cv, CACA_BLINK);
  54. caca_put_str(cv, 3 + 24, 20, "blink");
  55. caca_set_attr(cv, CACA_ITALICS);
  56. caca_put_str(cv, 3 + 41, 20, "italics");
  57. caca_set_attr(cv, CACA_UNDERLINE);
  58. caca_put_str(cv, 3 + 60, 20, "underline");
  59. caca_refresh_display(dp);
  60. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  61. caca_free_display(dp);
  62. caca_free_canvas(cv);
  63. return 0;
  64. }