source: libcaca/trunk/caca/driver_raw.c @ 2299

Last change on this file since 2299 was 2299, checked in by Sam Hocevar, 12 years ago
  • Remove #include <stdint.h> etc. from "common.h". Instead, make sure that <cucul.h> will provide the C99 types, even if libcaca has been installed.
  • Rename what's left of "common.h" to "stubs.h".
  • Remove all references to erroneous <inttypes.h> from source files.
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1/*
2 *  libcaca       Colour ASCII-Art library
3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
6 *  $Id: driver_raw.c 2299 2008-04-19 12:42:50Z sam $
7 *
8 *  This library 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
15/*
16 *  This file contains the libcaca raw input and output driver
17 */
18
19#include "config.h"
20
21#if !defined(__KERNEL__)
22
23#include <stdio.h>
24#include <stdlib.h>
25
26#include "cucul.h"
27#include "caca.h"
28#include "caca_internals.h"
29
30static int raw_init_graphics(caca_display_t *dp)
31{
32    unsigned int width = cucul_get_canvas_width(dp->cv);
33    unsigned int height = cucul_get_canvas_height(dp->cv);
34    char const *geometry;
35
36#if defined(HAVE_GETENV)
37    geometry = getenv("CACA_GEOMETRY");
38    if(geometry && *geometry)
39        sscanf(geometry, "%ux%u", &width, &height);
40#endif
41
42    dp->resize.allow = 1;
43    cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 24);
44    dp->resize.allow = 0;
45
46    return 0;
47}
48
49static int raw_end_graphics(caca_display_t *dp)
50{
51    return 0;
52}
53
54static int raw_set_display_title(caca_display_t *dp, char const *title)
55{
56    return -1;
57}
58
59static unsigned int raw_get_display_width(caca_display_t const *dp)
60{
61    return 0;
62}
63
64static unsigned int raw_get_display_height(caca_display_t const *dp)
65{
66    return 0;
67}
68
69static void raw_display(caca_display_t *dp)
70{
71    void *buffer;
72    unsigned long int len;
73
74    buffer = cucul_export_memory(dp->cv, "caca", &len);
75    if(!buffer)
76        return;
77    fwrite(buffer, len, 1, stdout);
78    fflush(stdout);
79    free(buffer);
80}
81
82static void raw_handle_resize(caca_display_t *dp)
83{
84    ;
85}
86
87static int raw_get_event(caca_display_t *dp, caca_privevent_t *ev)
88{
89    ev->type = CACA_EVENT_NONE;
90    return 0;
91}
92
93/*
94 * Driver initialisation
95 */
96
97int raw_install(caca_display_t *dp)
98{
99    dp->drv.id = CACA_DRIVER_RAW;
100    dp->drv.driver = "raw";
101
102    dp->drv.init_graphics = raw_init_graphics;
103    dp->drv.end_graphics = raw_end_graphics;
104    dp->drv.set_display_title = raw_set_display_title;
105    dp->drv.get_display_width = raw_get_display_width;
106    dp->drv.get_display_height = raw_get_display_height;
107    dp->drv.display = raw_display;
108    dp->drv.handle_resize = raw_handle_resize;
109    dp->drv.get_event = raw_get_event;
110    dp->drv.set_mouse = NULL;
111    dp->drv.set_cursor = NULL;
112
113    return 0;
114}
115
116#endif /* !__KERNEL__ */
Note: See TracBrowser for help on using the repository browser.