1 /*
2  * Copyright (C) 2002 Red Hat, Inc.
3  *
4  * This library is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published
6  * by the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 /* The interfaces in this file are subject to change at any time. */
19 
20 #pragma once
21 
22 #include <string.h>
23 
24 #include "vteunistr.h"
25 #include "vtemacros.h"
26 #include "vtedefines.hh"
27 
28 #include "attr.hh"
29 #include "cell.hh"
30 
31 G_BEGIN_DECLS
32 
33 /*
34  * VteRowAttr: A single row's attributes
35  */
36 
37 typedef struct _VteRowAttr {
38         guint8 soft_wrapped  : 1;
39         guint8 bidi_flags    : 4;
40 } VteRowAttr;
41 static_assert(sizeof (VteRowAttr) == 1, "VteRowAttr has wrong size");
42 
43 /*
44  * VteRowData: A single row's data
45  */
46 
47 typedef struct _VteRowData {
48 	VteCell *cells;
49 	guint16 len;
50 	VteRowAttr attr;
51 } VteRowData;
52 
53 
54 #define _vte_row_data_length(__row)			((__row)->len + 0)
55 
56 static inline const VteCell *
_vte_row_data_get(const VteRowData * row,gulong col)57 _vte_row_data_get (const VteRowData *row, gulong col)
58 {
59 	if (G_UNLIKELY (row->len <= col))
60 		return NULL;
61 
62 	return &row->cells[col];
63 }
64 
65 static inline VteCell *
_vte_row_data_get_writable(VteRowData * row,gulong col)66 _vte_row_data_get_writable (VteRowData *row, gulong col)
67 {
68 	if (G_UNLIKELY (row->len <= col))
69 		return NULL;
70 
71 	return &row->cells[col];
72 }
73 
74 void _vte_row_data_init (VteRowData *row);
75 void _vte_row_data_clear (VteRowData *row);
76 void _vte_row_data_fini (VteRowData *row);
77 void _vte_row_data_insert (VteRowData *row, gulong col, const VteCell *cell);
78 void _vte_row_data_append (VteRowData *row, const VteCell *cell);
79 void _vte_row_data_remove (VteRowData *row, gulong col);
80 void _vte_row_data_fill (VteRowData *row, const VteCell *cell, gulong len);
81 void _vte_row_data_shrink (VteRowData *row, gulong max_len);
82 void _vte_row_data_copy (const VteRowData *src, VteRowData *dst);
83 guint16 _vte_row_data_nonempty_length (const VteRowData *row);
84 
85 G_END_DECLS
86