Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2012 Sam Hocevar <sam@hocevar.net>
  4. * All Rights Reserved
  5. *
  6. * This library 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. /*
  13. * This file contains the libcaca raw input and output driver
  14. */
  15. #include "config.h"
  16. #if !defined(__KERNEL__)
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include "caca.h"
  20. #include "caca_internals.h"
  21. static int raw_init_graphics(caca_display_t *dp)
  22. {
  23. int width = caca_get_canvas_width(dp->cv);
  24. int height = caca_get_canvas_height(dp->cv);
  25. char const *geometry;
  26. #if defined(HAVE_GETENV)
  27. geometry = getenv("CACA_GEOMETRY");
  28. if(geometry && *geometry)
  29. sscanf(geometry, "%ux%u", &width, &height);
  30. #endif
  31. dp->resize.allow = 1;
  32. caca_set_canvas_size(dp->cv, width ? width : 80, height ? height : 24);
  33. dp->resize.allow = 0;
  34. return 0;
  35. }
  36. static int raw_end_graphics(caca_display_t *dp)
  37. {
  38. return 0;
  39. }
  40. static int raw_set_display_title(caca_display_t *dp, char const *title)
  41. {
  42. return -1;
  43. }
  44. static int raw_get_display_width(caca_display_t const *dp)
  45. {
  46. return 0;
  47. }
  48. static int raw_get_display_height(caca_display_t const *dp)
  49. {
  50. return 0;
  51. }
  52. static void raw_display(caca_display_t *dp)
  53. {
  54. void *buffer;
  55. size_t len;
  56. buffer = caca_export_canvas_to_memory(dp->cv, "caca", &len);
  57. if(!buffer)
  58. return;
  59. fwrite(buffer, len, 1, stdout);
  60. fflush(stdout);
  61. free(buffer);
  62. }
  63. static void raw_handle_resize(caca_display_t *dp)
  64. {
  65. ;
  66. }
  67. static int raw_get_event(caca_display_t *dp, caca_privevent_t *ev)
  68. {
  69. ev->type = CACA_EVENT_NONE;
  70. return 0;
  71. }
  72. /*
  73. * Driver initialisation
  74. */
  75. int raw_install(caca_display_t *dp)
  76. {
  77. dp->drv.id = CACA_DRIVER_RAW;
  78. dp->drv.driver = "raw";
  79. dp->drv.init_graphics = raw_init_graphics;
  80. dp->drv.end_graphics = raw_end_graphics;
  81. dp->drv.set_display_title = raw_set_display_title;
  82. dp->drv.get_display_width = raw_get_display_width;
  83. dp->drv.get_display_height = raw_get_display_height;
  84. dp->drv.display = raw_display;
  85. dp->drv.handle_resize = raw_handle_resize;
  86. dp->drv.get_event = raw_get_event;
  87. dp->drv.set_mouse = NULL;
  88. dp->drv.set_cursor = NULL;
  89. return 0;
  90. }
  91. #endif /* !__KERNEL__ */