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

Last change on this file since 1233 was 1233, checked in by Sam Hocevar, 14 years ago
  • Allow to create the initial canvas with a zero size. Either the application resizes it later, or the driver changes it to fit the display.
  • Property svn:keywords set to Id
File size: 2.4 KB
RevLine 
[699]1/*
2 *  libcaca       Colour ASCII-Art library
3 *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
4 *                All Rights Reserved
5 *
[769]6 *  $Id: driver_raw.c 1233 2006-10-26 08:16:43Z sam $
7 *
[699]8 *  This library is free software; you can redistribute it and/or
9 *  modify it under the terms of the Do What The Fuck You Want To
10 *  Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
[769]14/*
[699]15 *  This file contains the libcaca raw input and output driver
16 */
17
18#include "config.h"
[859]19#include "common.h"
[699]20
21#if !defined(__KERNEL__)
22
[1054]23#include <stdio.h>
[1233]24#include <stdlib.h>
[1054]25
[699]26#include "caca.h"
27#include "caca_internals.h"
28#include "cucul.h"
29#include "cucul_internals.h"
30
[811]31static int raw_init_graphics(caca_display_t *dp)
[699]32{
[1233]33    unsigned int width = dp->cv->width, height = dp->cv->height;
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    _cucul_set_canvas_size(dp->cv, width ? width : 80, height ? height : 24);
43
[699]44    return 0;
45}
46
[811]47static int raw_end_graphics(caca_display_t *dp)
[699]48{
49    return 0;
50}
51
[819]52static int raw_set_display_title(caca_display_t *dp, char const *title)
[699]53{
[1006]54    return -1;
[699]55}
56
[819]57static unsigned int raw_get_display_width(caca_display_t *dp)
[699]58{
59    return 0;
60}
61
[819]62static unsigned int raw_get_display_height(caca_display_t *dp)
[699]63{
64    return 0;
65}
66
[811]67static void raw_display(caca_display_t *dp)
[699]68{
[818]69    cucul_buffer_t *buffer;
[699]70
[826]71    buffer = cucul_export_canvas(dp->cv, "caca");
[818]72    fwrite(cucul_get_buffer_data(buffer),
73           cucul_get_buffer_size(buffer), 1, stdout);
[699]74    fflush(stdout);
[818]75    cucul_free_buffer(buffer);
[699]76}
77
[811]78static void raw_handle_resize(caca_display_t *dp)
[699]79{
80    ;
81}
82
[811]83static int raw_get_event(caca_display_t *dp, caca_event_t *ev)
[699]84{
85    ev->type = CACA_EVENT_NONE;
86    return 0;
87}
88
89/*
90 * Driver initialisation
91 */
92
[811]93int raw_install(caca_display_t *dp)
[699]94{
[811]95    dp->drv.driver = CACA_DRIVER_RAW;
[699]96
[811]97    dp->drv.init_graphics = raw_init_graphics;
98    dp->drv.end_graphics = raw_end_graphics;
[819]99    dp->drv.set_display_title = raw_set_display_title;
100    dp->drv.get_display_width = raw_get_display_width;
101    dp->drv.get_display_height = raw_get_display_height;
[811]102    dp->drv.display = raw_display;
103    dp->drv.handle_resize = raw_handle_resize;
104    dp->drv.get_event = raw_get_event;
105    dp->drv.set_mouse = NULL;
[699]106
107    return 0;
108}
109
[1054]110#endif /* !__KERNEL__ */
Note: See TracBrowser for help on using the repository browser.