|
Last change
on this file since cd1e3fc0 was d7f7a4a, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 3 years ago |
|
Replace some license headers with SPDX identifier
Headers are replaced using tools/transorm-copyright.sh only
when it can be matched verbatim with the license header used
throughout most of the codebase.
|
-
Property mode
set to
100644
|
|
File size:
1.5 KB
|
| Line | |
|---|
| 1 | /*
|
|---|
| 2 | * SPDX-FileCopyrightText: 2006 Josef Cejka
|
|---|
| 3 | * SPDX-FileCopyrightText: 2011 Petr Koupy
|
|---|
| 4 | *
|
|---|
| 5 | * SPDX-License-Identifier: BSD-3-Clause
|
|---|
| 6 | */
|
|---|
| 7 |
|
|---|
| 8 | /** @addtogroup libc
|
|---|
| 9 | * @{
|
|---|
| 10 | */
|
|---|
| 11 | /** @file
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | #ifndef _LIBC_IO_CHARFIELD_H_
|
|---|
| 15 | #define _LIBC_IO_CHARFIELD_H_
|
|---|
| 16 |
|
|---|
| 17 | #include <stdbool.h>
|
|---|
| 18 | #include <uchar.h>
|
|---|
| 19 | #include <io/color.h>
|
|---|
| 20 | #include <io/style.h>
|
|---|
| 21 | #include <io/pixel.h>
|
|---|
| 22 |
|
|---|
| 23 | typedef enum {
|
|---|
| 24 | CHAR_FLAG_NONE = 0,
|
|---|
| 25 | CHAR_FLAG_DIRTY = 1
|
|---|
| 26 | } char_flags_t;
|
|---|
| 27 |
|
|---|
| 28 | typedef enum {
|
|---|
| 29 | CHAR_ATTR_STYLE,
|
|---|
| 30 | CHAR_ATTR_INDEX,
|
|---|
| 31 | CHAR_ATTR_RGB
|
|---|
| 32 | } char_attr_type_t;
|
|---|
| 33 |
|
|---|
| 34 | typedef struct {
|
|---|
| 35 | console_color_t bgcolor;
|
|---|
| 36 | console_color_t fgcolor;
|
|---|
| 37 | console_color_attr_t attr;
|
|---|
| 38 | } char_attr_index_t;
|
|---|
| 39 |
|
|---|
| 40 | typedef struct {
|
|---|
| 41 | pixel_t bgcolor;
|
|---|
| 42 | pixel_t fgcolor;
|
|---|
| 43 | } char_attr_rgb_t;
|
|---|
| 44 |
|
|---|
| 45 | typedef union {
|
|---|
| 46 | console_style_t style;
|
|---|
| 47 | char_attr_index_t index;
|
|---|
| 48 | char_attr_rgb_t rgb;
|
|---|
| 49 | } char_attr_val_t;
|
|---|
| 50 |
|
|---|
| 51 | typedef struct {
|
|---|
| 52 | char_attr_type_t type;
|
|---|
| 53 | char_attr_val_t val;
|
|---|
| 54 | } char_attrs_t;
|
|---|
| 55 |
|
|---|
| 56 | typedef struct {
|
|---|
| 57 | char32_t ch;
|
|---|
| 58 | char_attrs_t attrs;
|
|---|
| 59 | char_flags_t flags;
|
|---|
| 60 | } charfield_t;
|
|---|
| 61 |
|
|---|
| 62 | static inline bool attrs_same(char_attrs_t a1, char_attrs_t a2)
|
|---|
| 63 | {
|
|---|
| 64 | if (a1.type != a2.type)
|
|---|
| 65 | return false;
|
|---|
| 66 |
|
|---|
| 67 | switch (a1.type) {
|
|---|
| 68 | case CHAR_ATTR_STYLE:
|
|---|
| 69 | return (a1.val.style == a2.val.style);
|
|---|
| 70 | case CHAR_ATTR_INDEX:
|
|---|
| 71 | return (a1.val.index.bgcolor == a2.val.index.bgcolor) &&
|
|---|
| 72 | (a1.val.index.fgcolor == a2.val.index.fgcolor) &&
|
|---|
| 73 | (a1.val.index.attr == a2.val.index.attr);
|
|---|
| 74 | case CHAR_ATTR_RGB:
|
|---|
| 75 | return (a1.val.rgb.bgcolor == a2.val.rgb.bgcolor) &&
|
|---|
| 76 | (a1.val.rgb.fgcolor == a2.val.rgb.fgcolor);
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | return false;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | #endif
|
|---|
| 83 |
|
|---|
| 84 | /** @}
|
|---|
| 85 | */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.