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 859 2006-04-24 20:35:59Z sam $ |
---|
7 | * |
---|
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 | |
---|
14 | /* |
---|
15 | * This file contains the libcaca raw input and output driver |
---|
16 | */ |
---|
17 | |
---|
18 | #include "config.h" |
---|
19 | #include "common.h" |
---|
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 | |
---|
30 | static int raw_init_graphics(caca_display_t *dp) |
---|
31 | { |
---|
32 | return 0; |
---|
33 | } |
---|
34 | |
---|
35 | static int raw_end_graphics(caca_display_t *dp) |
---|
36 | { |
---|
37 | return 0; |
---|
38 | } |
---|
39 | |
---|
40 | static int raw_set_display_title(caca_display_t *dp, char const *title) |
---|
41 | { |
---|
42 | return 0; |
---|
43 | } |
---|
44 | |
---|
45 | static unsigned int raw_get_display_width(caca_display_t *dp) |
---|
46 | { |
---|
47 | return 0; |
---|
48 | } |
---|
49 | |
---|
50 | static unsigned int raw_get_display_height(caca_display_t *dp) |
---|
51 | { |
---|
52 | return 0; |
---|
53 | } |
---|
54 | |
---|
55 | static void raw_display(caca_display_t *dp) |
---|
56 | { |
---|
57 | cucul_buffer_t *buffer; |
---|
58 | |
---|
59 | buffer = cucul_export_canvas(dp->cv, "caca"); |
---|
60 | fwrite(cucul_get_buffer_data(buffer), |
---|
61 | cucul_get_buffer_size(buffer), 1, stdout); |
---|
62 | fflush(stdout); |
---|
63 | cucul_free_buffer(buffer); |
---|
64 | } |
---|
65 | |
---|
66 | static void raw_handle_resize(caca_display_t *dp) |
---|
67 | { |
---|
68 | ; |
---|
69 | } |
---|
70 | |
---|
71 | static int raw_get_event(caca_display_t *dp, caca_event_t *ev) |
---|
72 | { |
---|
73 | ev->type = CACA_EVENT_NONE; |
---|
74 | return 0; |
---|
75 | } |
---|
76 | |
---|
77 | /* |
---|
78 | * Driver initialisation |
---|
79 | */ |
---|
80 | |
---|
81 | int raw_install(caca_display_t *dp) |
---|
82 | { |
---|
83 | dp->drv.driver = CACA_DRIVER_RAW; |
---|
84 | |
---|
85 | dp->drv.init_graphics = raw_init_graphics; |
---|
86 | dp->drv.end_graphics = raw_end_graphics; |
---|
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; |
---|
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; |
---|
94 | |
---|
95 | return 0; |
---|
96 | } |
---|
97 | |
---|