Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. uint32_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. uint32_t a = *attr++;
  61. fprintf(stdout, "%c%c%c%c%c%c%c%c",
  62. (c >> 24), (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff,
  63. (a >> 24), (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff);
  64. }
  65. fprintf(stdout, "ACAC");
  66. fflush(stdout);
  67. }
  68. static void raw_handle_resize(caca_t *kk)
  69. {
  70. ;
  71. }
  72. static int raw_get_event(caca_t *kk, struct caca_event *ev)
  73. {
  74. ev->type = CACA_EVENT_NONE;
  75. return 0;
  76. }
  77. /*
  78. * Driver initialisation
  79. */
  80. int raw_install(caca_t *kk)
  81. {
  82. kk->drv.driver = CACA_DRIVER_RAW;
  83. kk->drv.init_graphics = raw_init_graphics;
  84. kk->drv.end_graphics = raw_end_graphics;
  85. kk->drv.set_window_title = raw_set_window_title;
  86. kk->drv.get_window_width = raw_get_window_width;
  87. kk->drv.get_window_height = raw_get_window_height;
  88. kk->drv.display = raw_display;
  89. kk->drv.handle_resize = raw_handle_resize;
  90. kk->drv.get_event = raw_get_event;
  91. kk->drv.set_mouse = NULL;
  92. return 0;
  93. }