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/.
28 * Modified by the Sylpheed Team and others 2001-2002.
31 #ifndef __GTK_STEXT_H__
32 #define __GTK_STEXT_H__
36 #include <gtk/gtkadjustment.h>
37 #include <gtk/gtkeditable.h>
41 #endif /* __cplusplus */
44 #define GTK_TYPE_STEXT (gtk_stext_get_type ())
45 #define GTK_STEXT(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_STEXT, GtkSText))
46 #define GTK_STEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_STEXT, GtkSTextClass))
47 #define GTK_IS_STEXT(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_STEXT))
48 #define GTK_IS_STEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STEXT))
50 typedef struct _GtkSTextFont GtkSTextFont;
51 typedef struct _GtkSPropertyMark GtkSPropertyMark;
52 typedef struct _GtkSText GtkSText;
53 typedef struct _GtkSTextClass GtkSTextClass;
57 GTK_STEXT_CURSOR_LINE,
58 GTK_STEXT_CURSOR_BLOCK
61 struct _GtkSPropertyMark
63 /* Position in list. */
66 /* Offset into that property. */
84 GdkPixmap* line_wrap_bitmap;
85 GdkPixmap* line_arrow_bitmap;
87 /* GAPPED TEXT SEGMENT */
89 /* The text, a single segment of text a'la emacs, with a gap
90 * where insertion occurs. */
91 union { GdkWChar *wc; guchar *ch; } text;
92 /* The allocated length of the text segment. */
94 /* The gap position, index into address where a char
95 * should be inserted. */
97 /* The gap size, s.t. *(text + gap_position + gap_size) is
98 * the first valid character following the gap. */
100 /* The last character position, index into address where a
101 * character should be appeneded. Thus, text_end - gap_size
102 * is the length of the actual data. */
104 /* LINE START CACHE */
106 /* A cache of line-start information. Data is a LineParam*. */
107 GList *line_start_cache;
108 /* Index to the start of the first visible line. */
109 guint first_line_start_index;
110 /* The number of pixels cut off of the top line. */
111 guint first_cut_pixels;
112 /* First visible horizontal pixel. */
113 guint first_onscreen_hor_pixel;
114 /* First visible vertical pixel. */
115 guint first_onscreen_ver_pixel;
119 /* True iff this buffer is wrapping lines, otherwise it is using a
120 * horizontal scrollbar. */
123 /* If a fontset is supplied for the widget, use_wchar become true,
124 * and we use GdkWchar as the encoding of text. */
127 /* Frozen, don't do updates. @@@ fixme */
129 /* TEXT PROPERTIES */
131 /* A doubly-linked-list containing TextProperty objects. */
132 GList *text_properties;
133 /* The end of this list. */
134 GList *text_properties_end;
135 /* The first node before or on the point along with its offset to
136 * the point and the buffer's current point. This is the only
137 * PropertyMark whose index is guaranteed to remain correct
138 * following a buffer insertion or deletion. */
139 GtkSPropertyMark point;
143 union { GdkWChar *wc; guchar *ch; } scratch_buffer;
144 guint scratch_buffer_len;
152 gint cursor_pos_x; /* Position of cursor. */
153 gint cursor_pos_y; /* Baseline of line cursor is drawn on. */
154 GtkSPropertyMark cursor_mark; /* Where it is in the buffer. */
155 GdkWChar cursor_char; /* Character to redraw. */
156 gchar cursor_char_offset; /* Distance from baseline of the font. */
157 gint cursor_virtual_x; /* Where it would be if it could be. */
158 gint cursor_drawn_level; /* How many people have undrawn. */
167 gint default_tab_width;
169 GtkSTextFont *current_font; /* Text font for current style */
171 /* Timer used for auto-scrolling off ends */
174 guint button; /* currently pressed mouse button */
175 GdkGC *bg_gc; /* gc for drawing background pixmap */
178 * properties added for different cursor
180 gboolean cursor_visible; /* whether cursor is visible */
181 gboolean cursor_timer_on; /* blinking enabled */
182 guint cursor_off_ms; /* cursor off time */
183 guint cursor_on_ms; /* cursor on time */
184 gboolean cursor_state_on; /* state */
185 guint32 cursor_timer_id; /* blinking timer */
186 guint32 cursor_idle_time_timer_id; /* timer id */
188 GtkSTextCursorType cursor_type;
191 * properties added for rmargin
193 gint wrap_rmargin; /* right margin */
196 * properties added for persist column position when
197 * using up and down key */
201 struct _GtkSTextClass
203 GtkEditableClass parent_class;
205 void (*set_scroll_adjustments) (GtkSText *text,
206 GtkAdjustment *hadjustment,
207 GtkAdjustment *vadjustment);
211 GtkType gtk_stext_get_type (void);
212 GtkWidget* gtk_stext_new (GtkAdjustment *hadj,
213 GtkAdjustment *vadj);
214 void gtk_stext_set_editable (GtkSText *text,
216 void gtk_stext_set_word_wrap (GtkSText *text,
218 void gtk_stext_set_line_wrap (GtkSText *text,
220 void gtk_stext_set_adjustments (GtkSText *text,
222 GtkAdjustment *vadj);
223 void gtk_stext_set_point (GtkSText *text,
225 guint gtk_stext_get_point (GtkSText *text);
226 guint gtk_stext_get_length (GtkSText *text);
227 void gtk_stext_freeze (GtkSText *text);
228 void gtk_stext_thaw (GtkSText *text);
229 void gtk_stext_insert (GtkSText *text,
235 gint gtk_stext_backward_delete (GtkSText *text,
237 gint gtk_stext_forward_delete (GtkSText *text,
242 void gtk_stext_set_blink (GtkSText *text,
243 gboolean blinking_on);
244 void gtk_stext_set_cursor_type (GtkSText *text,
245 GtkSTextCursorType cursor_type);
246 void gtk_stext_compact_buffer (GtkSText *text);
248 /* these are normally not exported! */
249 void gtk_stext_move_forward_character (GtkSText *text);
250 void gtk_stext_move_backward_character (GtkSText *text);
251 void gtk_stext_move_forward_word (GtkSText *text);
252 void gtk_stext_move_backward_word (GtkSText *text);
253 void gtk_stext_move_beginning_of_line (GtkSText *text);
254 void gtk_stext_move_end_of_line (GtkSText *text);
255 void gtk_stext_move_next_line (GtkSText *text);
256 void gtk_stext_move_previous_line (GtkSText *text);
257 void gtk_stext_delete_forward_character (GtkSText *text);
258 void gtk_stext_delete_backward_character (GtkSText *text);
259 void gtk_stext_delete_forward_word (GtkSText *text);
260 void gtk_stext_delete_backward_word (GtkSText *text);
261 void gtk_stext_delete_line (GtkSText *text);
262 void gtk_stext_delete_to_line_end (GtkSText *text);
265 /* Set the rmargin for the stext. if rmargin is 0, then reset to old
267 void gtk_stext_set_wrap_rmargin (GtkSText *text, gint rmargin);
270 #define GTK_STEXT_INDEX(t, index) (((t)->use_wchar) \
271 ? ((index) < (t)->gap_position ? (t)->text.wc[index] : \
272 (t)->text.wc[(index)+(t)->gap_size]) \
273 : ((index) < (t)->gap_position ? (t)->text.ch[index] : \
274 (t)->text.ch[(index)+(t)->gap_size]))
278 #endif /* __cplusplus */
281 #endif /* __GTK_STEXT_H__ */