選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 
 

86 行
2.0 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 "cucul.h"
  20. #include "caca.h"
  21. int main(int argc, char *argv[])
  22. {
  23. char const * const *list;
  24. caca_display_t *dp;
  25. cucul_canvas_t *cv;
  26. list = caca_get_display_driver_list();
  27. dp = caca_create_display(NULL);
  28. if(dp == NULL)
  29. {
  30. printf("cannot create display\n");
  31. return -1;
  32. }
  33. cv = caca_get_canvas(dp);
  34. cucul_set_color_ansi(cv, CUCUL_WHITE, CUCUL_BLACK);
  35. while(1)
  36. {
  37. char const *driver;
  38. int i, cur = 0;
  39. cucul_put_str(cv, 1, 0, "Available drivers:");
  40. driver = caca_get_display_driver(dp);
  41. for(i = 0; list[i]; i += 2)
  42. {
  43. int match = !strcmp(list[i], driver);
  44. if(match)
  45. cur = i;
  46. cucul_draw_line(cv, 0, i + 2, 9999, i + 2, ' ');
  47. cucul_printf(cv, 2, i + 2, "%c %s (%s)",
  48. match ? '*' : ' ', list[i], list[i + 1]);
  49. }
  50. cucul_put_str(cv, 1, i + 2, "Switching driver in 5 seconds");
  51. caca_refresh_display(dp);
  52. if(caca_get_event(dp, CACA_EVENT_KEY_PRESS, NULL, 5000000))
  53. break;
  54. do
  55. {
  56. cur += 2;
  57. if(list[cur] && !strcmp(list[cur], "raw"))
  58. cur += 2;
  59. if(!list[cur])
  60. cur = 0;
  61. }
  62. while(caca_set_display_driver(dp, list[cur]));
  63. }
  64. caca_free_display(dp);
  65. return 0;
  66. }