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.1 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "cucul.h"
  19. #include "caca.h"
  20. int main(int argc, char **argv)
  21. {
  22. cucul_canvas_t *cv;
  23. caca_display_t *dp;
  24. int i, j;
  25. cv = cucul_create_canvas(80, 24);
  26. if(cv == NULL)
  27. {
  28. printf("Failed to create canvas\n");
  29. return 1;
  30. }
  31. dp = caca_create_display(cv);
  32. if(dp == NULL)
  33. {
  34. printf("Failed to create display\n");
  35. return 1;
  36. }
  37. cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
  38. cucul_clear_canvas(cv);
  39. for(i = 0; i < 16; i++)
  40. {
  41. cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
  42. cucul_printf(cv, 3, i + (i >= 8 ? 3 : 2), "ANSI %i", i);
  43. for(j = 0; j < 16; j++)
  44. {
  45. cucul_set_color_ansi(cv, i, j);
  46. cucul_put_str(cv, (j >= 8 ? 13 : 12) + j * 4, i + (i >= 8 ? 3 : 2),
  47. "Aaホ");
  48. }
  49. }
  50. cucul_set_color_ansi(cv, CUCUL_LIGHTGRAY, CUCUL_BLACK);
  51. cucul_put_str(cv, 3, 20, "This is bold This is blink This is italics This is underline");
  52. cucul_set_attr(cv, CUCUL_BOLD);
  53. cucul_put_str(cv, 3 + 8, 20, "bold");
  54. cucul_set_attr(cv, CUCUL_BLINK);
  55. cucul_put_str(cv, 3 + 24, 20, "blink");
  56. cucul_set_attr(cv, CUCUL_ITALICS);
  57. cucul_put_str(cv, 3 + 41, 20, "italics");
  58. cucul_set_attr(cv, CUCUL_UNDERLINE);
  59. cucul_put_str(cv, 3 + 60, 20, "underline");
  60. caca_refresh_display(dp);
  61. caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, -1);
  62. caca_free_display(dp);
  63. cucul_free_canvas(cv);
  64. return 0;
  65. }