File: sparse_buffer.h

package info (click to toggle)
anjuta 2%3A3.34.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 72,196 kB
  • sloc: ansic: 207,444; sh: 47,499; cpp: 11,461; makefile: 3,588; yacc: 2,821; perl: 2,094; lex: 1,546; xml: 904; python: 149; sql: 99; java: 10
file content (145 lines) | stat: -rw-r--r-- 5,242 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
    sparse_buffer.h
    Copyright (C) 2006 Sebastien Granjoux

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef _SPARSE_BUFFER_H
#define _SPARSE_BUFFER_H

#include <gtk/gtk.h>

#define DMA_SPARSE_BUFFER_TYPE              (dma_sparse_buffer_get_type ())
#define DMA_SPARSE_BUFFER(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), DMA_SPARSE_BUFFER_TYPE, DmaSparseBuffer))
#define DMA_SPARSE_BUFFER_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass),  DMA_SPARSE_BUFFER_TYPE, DmaSparseBufferClass))
#define DMA_IS_SPARSE_BUFFER(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DMA_SPARSE_BUFFER_TYPE))
#define DMA_IS_SPARSE_BUFFER_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass),  DMA_SPARSE_BUFFER_TYPE))
#define DMA_GET_SPARSE_BUFFER_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj),  DMA_SPARSE_BUFFER_TYPE, DmaSparseBufferClass))

typedef struct _DmaSparseBuffer DmaSparseBuffer;
typedef struct _DmaSparseBufferClass DmaSparseBufferClass;

typedef struct _DmaSparseBufferNode DmaSparseBufferNode;
typedef struct _DmaSparseIter DmaSparseIter;
typedef struct _DmaSparseBufferTransport DmaSparseBufferTransport;

GType dma_sparse_buffer_get_type (void);

DmaSparseBuffer *dma_sparse_buffer_new (guint lower, guint upper);
void dma_sparse_buffer_free (DmaSparseBuffer *buffer);

void dma_sparse_buffer_insert (DmaSparseBuffer *buffer, DmaSparseBufferNode *node);
void dma_sparse_buffer_remove (DmaSparseBuffer *buffer, DmaSparseBufferNode *node);
void dma_sparse_buffer_remove_all (DmaSparseBuffer *buffer);
DmaSparseBufferNode *dma_sparse_buffer_lookup (DmaSparseBuffer *self, guint address);
DmaSparseBufferNode *dma_sparse_buffer_first (DmaSparseBuffer *self);

guint dma_sparse_buffer_get_lower (const DmaSparseBuffer *buffer);
guint dma_sparse_buffer_get_upper (const DmaSparseBuffer *buffer);

void dma_sparse_buffer_changed (const DmaSparseBuffer *buffer);

void dma_sparse_buffer_add_mark (DmaSparseBuffer *buffer, guint address, gint mark);
void dma_sparse_buffer_remove_mark (DmaSparseBuffer *buffer, guint address, gint mark);
void dma_sparse_buffer_remove_all_mark (DmaSparseBuffer *buffer, gint mark);
gint dma_sparse_buffer_get_marks (DmaSparseBuffer *buffer, guint address);

void dma_sparse_buffer_get_iterator_at_address (DmaSparseBuffer *buffer, DmaSparseIter *iter, guint address);
void dma_sparse_buffer_get_iterator_near_address (DmaSparseBuffer *buffer, DmaSparseIter *iter, guint address);
void dma_sparse_iter_copy (DmaSparseIter *dst, const DmaSparseIter *src);
void dma_sparse_iter_move_at (DmaSparseIter *iter, guint address);
void dma_sparse_iter_move_near (DmaSparseIter *iter, guint address);
void dma_sparse_iter_refresh (DmaSparseIter *iter);
void dma_sparse_iter_round (DmaSparseIter *iter, gboolean round_up);
void dma_sparse_iter_insert_lines (DmaSparseIter *iter, GtkTextIter *dst, guint count);
gboolean dma_sparse_iter_forward_lines (DmaSparseIter *iter, gint count);
gulong dma_sparse_iter_get_address (DmaSparseIter *iter);

DmaSparseBufferTransport* dma_sparse_buffer_alloc_transport (DmaSparseBuffer *buffer, guint lines, guint chars);
void dma_sparse_buffer_free_transport (DmaSparseBufferTransport *trans);

struct _DmaSparseBuffer
{
	GObject parent;
	
	guint lower;
	guint upper;

	struct
	{
		DmaSparseBufferNode *head;
		DmaSparseBufferNode *tail;
	} cache;
	DmaSparseBufferNode *head;
	
	gint stamp;
	DmaSparseBufferTransport *pending;
	
	GHashTable* mark;
};

struct _DmaSparseBufferClass
{
	GObjectClass parent;
	
	void (*changed) (const DmaSparseBuffer *buffer);	
	
	void (*insert_line) (DmaSparseIter *iter, GtkTextIter *dst);
	gboolean (*refresh_iter) (DmaSparseIter *iter);
	void (*round_iter) (DmaSparseIter *iter, gboolean round_up);
	gboolean (*forward_line) (DmaSparseIter *iter);
	gboolean (*backward_line) (DmaSparseIter *iter);
	gulong (*get_address) (DmaSparseIter *iter);
};

struct _DmaSparseBufferNode
{
	struct
	{
		DmaSparseBufferNode *prev;
		DmaSparseBufferNode *next;
	} cache;
	DmaSparseBufferNode *prev;
	DmaSparseBufferNode *next;
	
	guint lower;		/* Lowest address of block */
	guint upper;		/* Highest address in the block (avoid overflow) */
};

struct _DmaSparseIter
{
	DmaSparseBuffer *buffer;
	gint stamp;
	DmaSparseBufferNode *node;
	gulong base;
	glong offset;
	gint line;
};

struct _DmaSparseBufferTransport
{
	DmaSparseBuffer *buffer;
	gulong start;
	gulong length;
	guint lines;
	guint chars;
	guint stamp;
	gint tag;
	DmaSparseBufferTransport *next;
};

#endif /* _SPARSE_BUFFER_H */