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.
 
 
 
 
 
 

83 rivejä
1.9 KiB

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