vterowdata.hh 2.22 KB
Newer Older
1 2 3
/*
 * Copyright (C) 2002 Red Hat, Inc.
 *
4 5 6 7
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
8
 *
9 10
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
13
 *
14 15 16
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17 18 19 20
 */

/* The interfaces in this file are subject to change at any time. */

21
#pragma once
22

23 24
#include <string.h>

25
#include "vteunistr.h"
26
#include "vtemacros.h"
27
#include "vtedefines.hh"
28 29

#include "attr.hh"
30
#include "cell.hh"
31 32 33 34 35 36 37 38 39 40

G_BEGIN_DECLS

/*
 * VteRowAttr: A single row's attributes
 */

typedef struct _VteRowAttr {
	guint8 soft_wrapped: 1;
} VteRowAttr;
41
static_assert(sizeof (VteRowAttr) == 1, "VteRowAttr has wrong size");
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

/*
 * VteRowData: A single row's data
 */

typedef struct _VteRowData {
	VteCell *cells;
	guint16 len;
	VteRowAttr attr;
} VteRowData;


#define _vte_row_data_length(__row)			((__row)->len + 0)

static inline const VteCell *
57
_vte_row_data_get (const VteRowData *row, gulong col)
58 59 60 61 62 63 64 65
{
	if (G_UNLIKELY (row->len <= col))
		return NULL;

	return &row->cells[col];
}

static inline VteCell *
66
_vte_row_data_get_writable (VteRowData *row, gulong col)
67 68 69 70 71 72 73
{
	if (G_UNLIKELY (row->len <= col))
		return NULL;

	return &row->cells[col];
}

74 75 76
void _vte_row_data_init (VteRowData *row);
void _vte_row_data_clear (VteRowData *row);
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 80 81
void _vte_row_data_remove (VteRowData *row, gulong col);
void _vte_row_data_fill (VteRowData *row, const VteCell *cell, gulong len);
void _vte_row_data_shrink (VteRowData *row, gulong max_len);
82
guint16 _vte_row_data_nonempty_length (const VteRowData *row);
83 84

G_END_DECLS