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.
 
 
 
 
 
 

75 regels
2.0 KiB

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