1 | /* |
---|
2 | * libcaca Colour ASCII-Art library |
---|
3 | * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org> |
---|
4 | * All Rights Reserved |
---|
5 | * |
---|
6 | * This library is free software; you can redistribute it and/or |
---|
7 | * modify it under the terms of the Do What The Fuck You Want To |
---|
8 | * Public License, Version 2, as published by Sam Hocevar. See |
---|
9 | * http://sam.zoy.org/wtfpl/COPYING for more details. |
---|
10 | */ |
---|
11 | |
---|
12 | /** \file driver_raw.c |
---|
13 | * \version \$Id: driver_raw.c 699 2006-03-27 18:07:18Z sam $ |
---|
14 | * \author Sam Hocevar <sam@zoy.org> |
---|
15 | * \brief raw driver |
---|
16 | * |
---|
17 | * This file contains the libcaca raw input and output driver |
---|
18 | */ |
---|
19 | |
---|
20 | #include "config.h" |
---|
21 | |
---|
22 | #if !defined(__KERNEL__) |
---|
23 | # include <stdio.h> |
---|
24 | #endif |
---|
25 | |
---|
26 | #include "caca.h" |
---|
27 | #include "caca_internals.h" |
---|
28 | #include "cucul.h" |
---|
29 | #include "cucul_internals.h" |
---|
30 | |
---|
31 | static int raw_init_graphics(caca_t *kk) |
---|
32 | { |
---|
33 | return 0; |
---|
34 | } |
---|
35 | |
---|
36 | static int raw_end_graphics(caca_t *kk) |
---|
37 | { |
---|
38 | return 0; |
---|
39 | } |
---|
40 | |
---|
41 | static int raw_set_window_title(caca_t *kk, char const *title) |
---|
42 | { |
---|
43 | return 0; |
---|
44 | } |
---|
45 | |
---|
46 | static unsigned int raw_get_window_width(caca_t *kk) |
---|
47 | { |
---|
48 | return 0; |
---|
49 | } |
---|
50 | |
---|
51 | static unsigned int raw_get_window_height(caca_t *kk) |
---|
52 | { |
---|
53 | return 0; |
---|
54 | } |
---|
55 | |
---|
56 | static void raw_display(caca_t *kk) |
---|
57 | { |
---|
58 | uint8_t *attr = kk->qq->attr; |
---|
59 | uint32_t *chars = kk->qq->chars; |
---|
60 | int n; |
---|
61 | |
---|
62 | fprintf(stdout, "CACA %i %i\n", kk->qq->width, kk->qq->height); |
---|
63 | for(n = kk->qq->height * kk->qq->width; n--; ) |
---|
64 | { |
---|
65 | uint32_t c = *chars++; |
---|
66 | uint8_t a = *attr++; |
---|
67 | |
---|
68 | fprintf(stdout, "%c%c%c%c %c", (c >> 24), (c >> 16) & 0xff, |
---|
69 | (c >> 8) & 0xff, c & 0xff, a); |
---|
70 | } |
---|
71 | fprintf(stdout, "ACAC\n"); |
---|
72 | fflush(stdout); |
---|
73 | } |
---|
74 | |
---|
75 | static void raw_handle_resize(caca_t *kk) |
---|
76 | { |
---|
77 | ; |
---|
78 | } |
---|
79 | |
---|
80 | static int raw_get_event(caca_t *kk, struct caca_event *ev) |
---|
81 | { |
---|
82 | ev->type = CACA_EVENT_NONE; |
---|
83 | return 0; |
---|
84 | } |
---|
85 | |
---|
86 | /* |
---|
87 | * Driver initialisation |
---|
88 | */ |
---|
89 | |
---|
90 | int raw_install(caca_t *kk) |
---|
91 | { |
---|
92 | kk->drv.driver = CACA_DRIVER_RAW; |
---|
93 | |
---|
94 | kk->drv.init_graphics = raw_init_graphics; |
---|
95 | kk->drv.end_graphics = raw_end_graphics; |
---|
96 | kk->drv.set_window_title = raw_set_window_title; |
---|
97 | kk->drv.get_window_width = raw_get_window_width; |
---|
98 | kk->drv.get_window_height = raw_get_window_height; |
---|
99 | kk->drv.display = raw_display; |
---|
100 | kk->drv.handle_resize = raw_handle_resize; |
---|
101 | kk->drv.get_event = raw_get_event; |
---|
102 | kk->drv.set_mouse = NULL; |
---|
103 | |
---|
104 | return 0; |
---|
105 | } |
---|
106 | |
---|