1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
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 GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #ifndef __GTK_TEXT_H__
19 #define __GTK_TEXT_H__
23 #include <gtk/gtkadjustment.h>
24 #include <gtk/gtkwidget.h>
29 #endif /* __cplusplus */
32 #define GTK_TEXT(obj) GTK_CHECK_CAST (obj, gtk_text_get_type (), GtkText)
33 #define GTK_TEXT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_text_get_type (), GtkTextClass)
34 #define GTK_IS_TEXT(obj) GTK_CHECK_TYPE (obj, gtk_text_get_type ())
37 typedef struct _GtkPropertyMark GtkPropertyMark;
38 typedef struct _GtkText GtkText;
39 typedef struct _GtkTextClass GtkTextClass;
41 typedef void (*GtkTextFunction) (GtkText *text);
43 struct _GtkPropertyMark
45 /* Position in list. */
48 /* Offset into that property. */
66 GdkPixmap* line_wrap_bitmap;
67 GdkPixmap* line_arrow_bitmap;
69 /* GAPPED TEXT SEGMENT */
71 /* The text, a single segment of text a'la emacs, with a gap
72 * where insertion occurs. */
74 /* The allocated length of the text segment. */
76 /* The gap position, index into address where a char
77 * should be inserted. */
79 /* The gap size, s.t. *(text + gap_position + gap_size) is
80 * the first valid character following the gap. */
82 /* The last character position, index into address where a
83 * character should be appeneded. Thus, text_end - gap_size
84 * is the length of the actual data. */
86 /* LINE START CACHE */
88 /* A cache of line-start information. Data is a LineParam*. */
89 GList *line_start_cache;
90 /* Index to the start of the first visible line. */
91 guint first_line_start_index;
92 /* The number of pixels cut off of the top line. */
93 guint first_cut_pixels;
94 /* First visible horizontal pixel. */
95 guint first_onscreen_hor_pixel;
96 /* First visible vertical pixel. */
97 guint first_onscreen_ver_pixel;
101 /* True iff the cursor has been placed yet. */
102 guint has_cursor : 1;
103 /* True iff this buffer is editable. (Allowing a cursor to be placed). */
104 guint is_editable : 1;
105 /* True iff this buffer is wrapping lines, otherwise it is using a
106 * horizontal scrollbar. */
108 /* Frozen, don't do updates. @@@ fixme */
110 /* Whether a selection. */
111 guint has_selection : 1;
112 /* Whether the selection is in the clipboard. */
113 guint own_selection : 1;
114 /* Whether it has been realized yet. */
116 /* TEXT PROPERTIES */
118 /* A doubly-linked-list containing TextProperty objects. */
119 GList *text_properties;
120 /* The end of this list. */
121 GList *text_properties_end;
122 /* The first node before or on the point along with its offset to
123 * the point and the buffer's current point. This is the only
124 * PropertyMark whose index is guaranteed to remain correct
125 * following a buffer insertion or deletion. */
126 GtkPropertyMark point;
130 guchar* scratch_buffer;
131 guint scratch_buffer_len;
139 gint cursor_pos_x; /* Position of cursor. */
140 gint cursor_pos_y; /* Baseline of line cursor is drawn on. */
141 GtkPropertyMark cursor_mark; /* Where it is in the buffer. */
142 gchar cursor_char; /* Character to redraw. */
143 gchar cursor_char_offset; /* Distance from baseline of the font. */
144 gint cursor_virtual_x; /* Where it would be if it could be. */
145 gint cursor_drawn_level; /* How many people have undrawn. */
154 gint default_tab_width;
158 GtkTextFunction control_keys[26];
159 GtkTextFunction alt_keys[26];
161 /* Selection nonsense. */
163 guint selection_start;
164 guint selection_stop;
169 GtkWidgetClass parent_class;
173 guint gtk_text_get_type (void);
174 GtkWidget* gtk_text_new (GtkAdjustment *hadj,
175 GtkAdjustment *vadj);
176 void gtk_text_set_editable (GtkText *text,
178 void gtk_text_set_adjustments (GtkText *text,
180 GtkAdjustment *vadj);
181 void gtk_text_set_point (GtkText *text,
183 guint gtk_text_get_point (GtkText *text);
184 guint gtk_text_get_length (GtkText *text);
185 void gtk_text_freeze (GtkText *text);
186 void gtk_text_thaw (GtkText *text);
187 void gtk_text_insert (GtkText *text,
193 gint gtk_text_backward_delete (GtkText *text,
195 gint gtk_text_foreward_delete (GtkText *text,
201 #endif /* __cplusplus */
204 #endif /* __GTK_TEXT_H__ */