source: mainline/uspace/lib/c/include/io/chargrid.h@ c8752175

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c8752175 was 6d5e378, checked in by Martin Decky <martin@…>, 13 years ago

cherrypick GUI implementation (originally by Petr Koupy), with several major changes

  • for character-oriented devices a new output server and output protocol was created based on the original fb server
  • DDF visualizer drivers are pixel-oriented only
  • console and compositor can coexist in the same build
  • terminal widget is self-sufficient, no strange console nesting is needed
  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 * Copyright (c) 2011 Martin Decky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup libc
30 * @{
31 */
32/**
33 * @file
34 */
35
36#ifndef LIBC_IO_CHARGRID_H_
37#define LIBC_IO_CHARGRID_H_
38
39#include <sys/types.h>
40#include <io/charfield.h>
41
42typedef enum {
43 CHARGRID_FLAG_NONE = 0,
44 CHARGRID_FLAG_SHARED = 1
45} chargrid_flag_t;
46
47typedef struct {
48 size_t size; /**< Structure size */
49 chargrid_flag_t flags; /**< Screenbuffer flags */
50
51 sysarg_t cols; /**< Number of columns */
52 sysarg_t rows; /**< Number of rows */
53
54 sysarg_t col; /**< Current column */
55 sysarg_t row; /**< Current row */
56 bool cursor_visible; /**< Cursor visibility */
57
58 char_attrs_t attrs; /**< Current attributes */
59
60 sysarg_t top_row; /**< The first row in the cyclic buffer */
61 charfield_t data[]; /**< Screen contents (cyclic buffer) */
62} chargrid_t;
63
64static inline charfield_t *chargrid_charfield_at(chargrid_t *chargrid,
65 sysarg_t col, sysarg_t row)
66{
67 return chargrid->data +
68 ((row + chargrid->top_row) % chargrid->rows) * chargrid->cols +
69 col;
70}
71
72extern chargrid_t *chargrid_create(sysarg_t, sysarg_t,
73 chargrid_flag_t);
74extern void chargrid_destroy(chargrid_t *);
75
76extern bool chargrid_cursor_at(chargrid_t *, sysarg_t, sysarg_t);
77
78extern sysarg_t chargrid_get_top_row(chargrid_t *);
79
80extern sysarg_t chargrid_putchar(chargrid_t *, wchar_t, bool);
81extern sysarg_t chargrid_newline(chargrid_t *);
82extern sysarg_t chargrid_tabstop(chargrid_t *, sysarg_t);
83extern sysarg_t chargrid_backspace(chargrid_t *);
84
85extern void chargrid_clear(chargrid_t *);
86extern void chargrid_clear_row(chargrid_t *, sysarg_t);
87
88extern void chargrid_set_cursor(chargrid_t *, sysarg_t, sysarg_t);
89extern void chargrid_set_cursor_visibility(chargrid_t *, bool);
90extern bool chargrid_get_cursor_visibility(chargrid_t *);
91
92extern void chargrid_get_cursor(chargrid_t *, sysarg_t *, sysarg_t *);
93
94extern void chargrid_set_style(chargrid_t *, console_style_t);
95extern void chargrid_set_color(chargrid_t *, console_color_t,
96 console_color_t, console_color_attr_t);
97extern void chargrid_set_rgb_color(chargrid_t *, pixel_t, pixel_t);
98
99#endif
100
101/** @}
102 */
Note: See TracBrowser for help on using the repository browser.