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
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #ifndef __GTK_STEXT_H__
28 #define __GTK_STEXT_H__
32 #include <gtk/gtkadjustment.h>
33 #include <gtk/gtkeditable.h>
37 #endif /* __cplusplus */
40 #define GTK_TYPE_STEXT (gtk_stext_get_type ())
41 #define GTK_STEXT(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_STEXT, GtkSText))
42 #define GTK_STEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_STEXT, GtkSTextClass))
43 #define GTK_IS_STEXT(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_STEXT))
44 #define GTK_IS_STEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STEXT))
46 typedef struct _GtkSTextFont GtkSTextFont;
47 typedef struct _GtkSPropertyMark GtkSPropertyMark;
48 typedef struct _GtkSText GtkSText;
49 typedef struct _GtkSTextClass GtkSTextClass;
53 GTK_STEXT_CURSOR_LINE,
54 GTK_STEXT_CURSOR_BLOCK
57 struct _GtkSPropertyMark
59 /* Position in list. */
62 /* Offset into that property. */
80 GdkPixmap* line_wrap_bitmap;
81 GdkPixmap* line_arrow_bitmap;
83 /* GAPPED TEXT SEGMENT */
85 /* The text, a single segment of text a'la emacs, with a gap
86 * where insertion occurs. */
87 union { GdkWChar *wc; guchar *ch; } text;
88 /* The allocated length of the text segment. */
90 /* The gap position, index into address where a char
91 * should be inserted. */
93 /* The gap size, s.t. *(text + gap_position + gap_size) is
94 * the first valid character following the gap. */
96 /* The last character position, index into address where a
97 * character should be appeneded. Thus, text_end - gap_size
98 * is the length of the actual data. */
100 /* LINE START CACHE */
102 /* A cache of line-start information. Data is a LineParam*. */
103 GList *line_start_cache;
104 /* Index to the start of the first visible line. */
105 guint first_line_start_index;
106 /* The number of pixels cut off of the top line. */
107 guint first_cut_pixels;
108 /* First visible horizontal pixel. */
109 guint first_onscreen_hor_pixel;
110 /* First visible vertical pixel. */
111 guint first_onscreen_ver_pixel;
115 /* True iff this buffer is wrapping lines, otherwise it is using a
116 * horizontal scrollbar. */
119 /* If a fontset is supplied for the widget, use_wchar become true,
120 * and we use GdkWchar as the encoding of text. */
123 /* Frozen, don't do updates. @@@ fixme */
125 /* TEXT PROPERTIES */
127 /* A doubly-linked-list containing TextProperty objects. */
128 GList *text_properties;
129 /* The end of this list. */
130 GList *text_properties_end;
131 /* The first node before or on the point along with its offset to
132 * the point and the buffer's current point. This is the only
133 * PropertyMark whose index is guaranteed to remain correct
134 * following a buffer insertion or deletion. */
135 GtkSPropertyMark point;
139 union { GdkWChar *wc; guchar *ch; } scratch_buffer;
140 guint scratch_buffer_len;
148 gint cursor_pos_x; /* Position of cursor. */
149 gint cursor_pos_y; /* Baseline of line cursor is drawn on. */
150 GtkSPropertyMark cursor_mark; /* Where it is in the buffer. */
151 GdkWChar cursor_char; /* Character to redraw. */
152 gchar cursor_char_offset; /* Distance from baseline of the font. */
153 gint cursor_virtual_x; /* Where it would be if it could be. */
154 gint cursor_drawn_level; /* How many people have undrawn. */
163 gint default_tab_width;
165 GtkSTextFont *current_font; /* Text font for current style */
167 /* Timer used for auto-scrolling off ends */
170 guint button; /* currently pressed mouse button */
171 GdkGC *bg_gc; /* gc for drawing background pixmap */
174 * properties added for different cursor
176 gboolean cursor_visible; /* whether cursor is visible */
177 gboolean cursor_timer_on; /* blinking enabled */
178 guint cursor_off_ms; /* cursor off time */
179 guint cursor_on_ms; /* cursor on time */
180 gboolean cursor_state_on; /* state */
181 guint32 cursor_timer_id; /* blinking timer */
182 guint32 cursor_idle_time_timer_id; /* timer id */
184 GtkSTextCursorType cursor_type;
187 * properties added for rmargin
189 gint wrap_rmargin; /* right margin */
192 * properties added for persist column position when
193 * using up and down key */
197 struct _GtkSTextClass
199 GtkEditableClass parent_class;
201 void (*set_scroll_adjustments) (GtkSText *text,
202 GtkAdjustment *hadjustment,
203 GtkAdjustment *vadjustment);
207 GtkType gtk_stext_get_type (void);
208 GtkWidget* gtk_stext_new (GtkAdjustment *hadj,
209 GtkAdjustment *vadj);
210 void gtk_stext_set_editable (GtkSText *text,
212 void gtk_stext_set_word_wrap (GtkSText *text,
214 void gtk_stext_set_line_wrap (GtkSText *text,
216 void gtk_stext_set_adjustments (GtkSText *text,
218 GtkAdjustment *vadj);
219 void gtk_stext_set_point (GtkSText *text,
221 guint gtk_stext_get_point (GtkSText *text);
222 guint gtk_stext_get_length (GtkSText *text);
223 void gtk_stext_freeze (GtkSText *text);
224 void gtk_stext_thaw (GtkSText *text);
225 void gtk_stext_insert (GtkSText *text,
231 gint gtk_stext_backward_delete (GtkSText *text,
233 gint gtk_stext_forward_delete (GtkSText *text,
238 void gtk_stext_set_blink (GtkSText *text,
239 gboolean blinking_on);
240 void gtk_stext_set_cursor_type (GtkSText *text,
241 GtkSTextCursorType cursor_type);
242 void gtk_stext_compact_buffer (GtkSText *text);
244 /* Set the rmargin for the stext. if rmargin is 0, then reset to old
246 void gtk_stext_set_wrap_rmargin (GtkSText *text, gint rmargin);
249 #define GTK_STEXT_INDEX(t, index) (((t)->use_wchar) \
250 ? ((index) < (t)->gap_position ? (t)->text.wc[index] : \
251 (t)->text.wc[(index)+(t)->gap_size]) \
252 : ((index) < (t)->gap_position ? (t)->text.ch[index] : \
253 (t)->text.ch[(index)+(t)->gap_size]))
257 #endif /* __cplusplus */
260 #endif /* __GTK_STEXT_H__ */