Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

85 řádky
1.9 KiB

  1. /*
  2. * driver libcaca Unicode rendering test program
  3. * Copyright (c) 2007 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 <string.h>
  17. # include <stdio.h>
  18. #endif
  19. #include "caca.h"
  20. int main(int argc, char *argv[])
  21. {
  22. char const * const *list;
  23. caca_display_t *dp;
  24. caca_canvas_t *cv;
  25. list = caca_get_display_driver_list();
  26. dp = caca_create_display(NULL);
  27. if(dp == NULL)
  28. {
  29. printf("cannot create display\n");
  30. return -1;
  31. }
  32. cv = caca_get_canvas(dp);
  33. caca_set_color_ansi(cv, CACA_WHITE, CACA_BLACK);
  34. while(1)
  35. {
  36. char const *driver;
  37. int i, cur = 0;
  38. caca_put_str(cv, 1, 0, "Available drivers:");
  39. driver = caca_get_display_driver(dp);
  40. for(i = 0; list[i]; i += 2)
  41. {
  42. int match = !strcmp(list[i], driver);
  43. if(match)
  44. cur = i;
  45. caca_draw_line(cv, 0, i + 2, 9999, i + 2, ' ');
  46. caca_printf(cv, 2, i + 2, "%c %s (%s)",
  47. match ? '*' : ' ', list[i], list[i + 1]);
  48. }
  49. caca_put_str(cv, 1, i + 2, "Switching driver in 5 seconds");
  50. caca_refresh_display(dp);
  51. if(caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 5000000))
  52. break;
  53. do
  54. {
  55. cur += 2;
  56. if(list[cur] && !strcmp(list[cur], "raw"))
  57. cur += 2;
  58. if(!list[cur])
  59. cur = 0;
  60. }
  61. while(caca_set_display_driver(dp, list[cur]));
  62. }
  63. caca_free_display(dp);
  64. return 0;
  65. }