8cbc4a65500bce42b5b792fd11d92be59dd8acc4
[platform/upstream/kmscon.git] / src / console.h
1 /*
2  * kmscon - Console Management
3  *
4  * Copyright (c) 2011 David Herrmann <dh.herrmann@googlemail.com>
5  * Copyright (c) 2011 University of Tuebingen
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files
9  * (the "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included
16  * in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
22  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26
27 /*
28  * Console Management
29  * The console management uses OpenGL, cairo and pango to draw a console to a
30  * framebuffer. It is independent of the other subsystems and can also be used
31  * in other applications.
32  *
33  * This console does not emulate any terminal at all. This subsystem just
34  * provides functions to draw a console to a framebuffer and modifying the state
35  * of it.
36  */
37
38 #include <cairo.h>
39 #include <inttypes.h>
40 #include <stdlib.h>
41
42 struct kmscon_char;
43 struct kmscon_font;
44 struct kmscon_console;
45
46 /* single printable characters */
47
48 int kmscon_char_new(struct kmscon_char **out);
49 int kmscon_char_new_u8(struct kmscon_char **out, const char *str, size_t len);
50 int kmscon_char_dup(struct kmscon_char **out, const struct kmscon_char *orig);
51 void kmscon_char_free(struct kmscon_char *ch);
52
53 int kmscon_char_set(struct kmscon_char *ch, const struct kmscon_char *orig);
54 int kmscon_char_set_u8(struct kmscon_char *ch, const char *str, size_t len);
55 const char *kmscon_char_get_u8(const struct kmscon_char *ch);
56 size_t kmscon_char_get_len(const struct kmscon_char *ch);
57 int kmscon_char_append_u8(struct kmscon_char *ch, const char *str, size_t len);
58
59 /* font objects with cached glyphs */
60
61 int kmscon_font_new(struct kmscon_font **out, uint32_t height);
62 void kmscon_font_ref(struct kmscon_font *font);
63 void kmscon_font_unref(struct kmscon_font *font);
64
65 int kmscon_font_draw(struct kmscon_font *font, const struct kmscon_char *ch,
66                                         cairo_t *cr, uint32_t x, uint32_t y);
67
68 /* console objects */
69
70 int kmscon_console_new(struct kmscon_console **out);
71 void kmscon_console_ref(struct kmscon_console *con);
72 void kmscon_console_unref(struct kmscon_console *con);
73
74 int kmscon_console_set_res(struct kmscon_console *con, uint32_t x, uint32_t y);
75 void kmscon_console_draw(struct kmscon_console *con);
76 void kmscon_console_map(struct kmscon_console *con);
77
78 int kmscon_console_resize(struct kmscon_console *con, uint32_t x, uint32_t y);
79
80 void kmscon_console_cursor_get(struct kmscon_console *con, uint32_t *x,
81                                                                 uint32_t *y);
82 void kmscon_console_cursor_move(struct kmscon_console *con, int32_t x,
83                                                                 int32_t y);
84 void kmscon_console_cursor_goto(struct kmscon_console *con, uint32_t x,
85                                                                 uint32_t y);
86
87 int kmscon_console_write(struct kmscon_console *con,
88                                                 const struct kmscon_char *ch);