[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 1006 2006-08-02 13:12: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 | # include <stdio.h> |
---|
| 23 | #endif |
---|
| 24 | |
---|
| 25 | #include "caca.h" |
---|
| 26 | #include "caca_internals.h" |
---|
| 27 | #include "cucul.h" |
---|
| 28 | #include "cucul_internals.h" |
---|
| 29 | |
---|
[811] | 30 | static int raw_init_graphics(caca_display_t *dp) |
---|
[699] | 31 | { |
---|
| 32 | return 0; |
---|
| 33 | } |
---|
| 34 | |
---|
[811] | 35 | static int raw_end_graphics(caca_display_t *dp) |
---|
[699] | 36 | { |
---|
| 37 | return 0; |
---|
| 38 | } |
---|
| 39 | |
---|
[819] | 40 | static int raw_set_display_title(caca_display_t *dp, char const *title) |
---|
[699] | 41 | { |
---|
[1006] | 42 | return -1; |
---|
[699] | 43 | } |
---|
| 44 | |
---|
[819] | 45 | static unsigned int raw_get_display_width(caca_display_t *dp) |
---|
[699] | 46 | { |
---|
| 47 | return 0; |
---|
| 48 | } |
---|
| 49 | |
---|
[819] | 50 | static unsigned int raw_get_display_height(caca_display_t *dp) |
---|
[699] | 51 | { |
---|
| 52 | return 0; |
---|
| 53 | } |
---|
| 54 | |
---|
[811] | 55 | static void raw_display(caca_display_t *dp) |
---|
[699] | 56 | { |
---|
[818] | 57 | cucul_buffer_t *buffer; |
---|
[699] | 58 | |
---|
[826] | 59 | buffer = cucul_export_canvas(dp->cv, "caca"); |
---|
[818] | 60 | fwrite(cucul_get_buffer_data(buffer), |
---|
| 61 | cucul_get_buffer_size(buffer), 1, stdout); |
---|
[699] | 62 | fflush(stdout); |
---|
[818] | 63 | cucul_free_buffer(buffer); |
---|
[699] | 64 | } |
---|
| 65 | |
---|
[811] | 66 | static void raw_handle_resize(caca_display_t *dp) |
---|
[699] | 67 | { |
---|
| 68 | ; |
---|
| 69 | } |
---|
| 70 | |
---|
[811] | 71 | static int raw_get_event(caca_display_t *dp, caca_event_t *ev) |
---|
[699] | 72 | { |
---|
| 73 | ev->type = CACA_EVENT_NONE; |
---|
| 74 | return 0; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | /* |
---|
| 78 | * Driver initialisation |
---|
| 79 | */ |
---|
| 80 | |
---|
[811] | 81 | int raw_install(caca_display_t *dp) |
---|
[699] | 82 | { |
---|
[811] | 83 | dp->drv.driver = CACA_DRIVER_RAW; |
---|
[699] | 84 | |
---|
[811] | 85 | dp->drv.init_graphics = raw_init_graphics; |
---|
| 86 | dp->drv.end_graphics = raw_end_graphics; |
---|
[819] | 87 | dp->drv.set_display_title = raw_set_display_title; |
---|
| 88 | dp->drv.get_display_width = raw_get_display_width; |
---|
| 89 | dp->drv.get_display_height = raw_get_display_height; |
---|
[811] | 90 | dp->drv.display = raw_display; |
---|
| 91 | dp->drv.handle_resize = raw_handle_resize; |
---|
| 92 | dp->drv.get_event = raw_get_event; |
---|
| 93 | dp->drv.set_mouse = NULL; |
---|
[699] | 94 | |
---|
| 95 | return 0; |
---|
| 96 | } |
---|
| 97 | |
---|