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ů.
 
 
 
 
 
 

115 řádky
2.4 KiB

  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Do What The Fuck You Want To
  8. * Public License, Version 2, as published by Sam Hocevar. See
  9. * http://sam.zoy.org/wtfpl/COPYING for more details.
  10. */
  11. /** \file driver_raw.c
  12. * \version \$Id$
  13. * \author Sam Hocevar <sam@zoy.org>
  14. * \brief raw driver
  15. *
  16. * This file contains the libcaca raw input and output driver
  17. */
  18. #include "config.h"
  19. #if !defined(__KERNEL__)
  20. # include <stdio.h>
  21. #endif
  22. #include "caca.h"
  23. #include "caca_internals.h"
  24. #include "cucul.h"
  25. #include "cucul_internals.h"
  26. static int raw_init_graphics(caca_t *kk)
  27. {
  28. return 0;
  29. }
  30. static int raw_end_graphics(caca_t *kk)
  31. {
  32. return 0;
  33. }
  34. static int raw_set_window_title(caca_t *kk, char const *title)
  35. {
  36. return 0;
  37. }
  38. static unsigned int raw_get_window_width(caca_t *kk)
  39. {
  40. return 0;
  41. }
  42. static unsigned int raw_get_window_height(caca_t *kk)
  43. {
  44. return 0;
  45. }
  46. static void raw_display(caca_t *kk)
  47. {
  48. uint8_t *attr = kk->qq->attr;
  49. uint32_t *chars = kk->qq->chars;
  50. uint32_t w, h;
  51. unsigned int n;
  52. w = kk->qq->width;
  53. h = kk->qq->height;
  54. fprintf(stdout, "CACA%c%c%c%c%c%c%c%c",
  55. (w >> 24), (w >> 16) & 0xff, (w >> 8) & 0xff, w & 0xff,
  56. (h >> 24), (h >> 16) & 0xff, (h >> 8) & 0xff, h & 0xff);
  57. for(n = kk->qq->height * kk->qq->width; n--; )
  58. {
  59. uint32_t c = *chars++;
  60. uint8_t a = *attr++;
  61. fprintf(stdout, "%c%c%c%c%c", (c >> 24), (c >> 16) & 0xff,
  62. (c >> 8) & 0xff, c & 0xff, a);
  63. }
  64. fprintf(stdout, "ACAC");
  65. fflush(stdout);
  66. }
  67. static void raw_handle_resize(caca_t *kk)
  68. {
  69. ;
  70. }
  71. static int raw_get_event(caca_t *kk, struct caca_event *ev)
  72. {
  73. ev->type = CACA_EVENT_NONE;
  74. return 0;
  75. }
  76. /*
  77. * Driver initialisation
  78. */
  79. int raw_install(caca_t *kk)
  80. {
  81. kk->drv.driver = CACA_DRIVER_RAW;
  82. kk->drv.init_graphics = raw_init_graphics;
  83. kk->drv.end_graphics = raw_end_graphics;
  84. kk->drv.set_window_title = raw_set_window_title;
  85. kk->drv.get_window_width = raw_get_window_width;
  86. kk->drv.get_window_height = raw_get_window_height;
  87. kk->drv.display = raw_display;
  88. kk->drv.handle_resize = raw_handle_resize;
  89. kk->drv.get_event = raw_get_event;
  90. kk->drv.set_mouse = NULL;
  91. return 0;
  92. }