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__
38 #if (HAVE_WCTYPE_H && HAVE_WCHAR_H)
46 #include <gtk/gtkadjustment.h>
47 #include <gtk/gtkeditable.h>
51 #endif /* __cplusplus */
54 #define GTK_TYPE_STEXT (gtk_stext_get_type ())
55 #define GTK_STEXT(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_STEXT, GtkSText))
56 #define GTK_STEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_STEXT, GtkSTextClass))
57 #define GTK_IS_STEXT(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_STEXT))
58 #define GTK_IS_STEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_STEXT))
60 typedef struct _GtkSTextFont GtkSTextFont;
61 typedef struct _GtkSPropertyMark GtkSPropertyMark;
62 typedef struct _GtkSText GtkSText;
63 typedef struct _GtkSTextClass GtkSTextClass;
67 GTK_STEXT_CURSOR_LINE,
68 GTK_STEXT_CURSOR_BLOCK
71 struct _GtkSPropertyMark
73 /* Position in list. */
76 /* Offset into that property. */
94 GdkPixmap* line_wrap_bitmap;
95 GdkPixmap* line_arrow_bitmap;
97 /* GAPPED TEXT SEGMENT */
99 /* The text, a single segment of text a'la emacs, with a gap
100 * where insertion occurs. */
101 union { GdkWChar *wc; guchar *ch; } text;
102 /* The allocated length of the text segment. */
104 /* The gap position, index into address where a char
105 * should be inserted. */
107 /* The gap size, s.t. *(text + gap_position + gap_size) is
108 * the first valid character following the gap. */
110 /* The last character position, index into address where a
111 * character should be appeneded. Thus, text_end - gap_size
112 * is the length of the actual data. */
114 /* LINE START CACHE */
116 /* A cache of line-start information. Data is a LineParam*. */
117 GList *line_start_cache;
118 /* Index to the start of the first visible line. */
119 guint first_line_start_index;
120 /* The number of pixels cut off of the top line. */
121 guint first_cut_pixels;
122 /* First visible horizontal pixel. */
123 guint first_onscreen_hor_pixel;
124 /* First visible vertical pixel. */
125 guint first_onscreen_ver_pixel;
129 /* True iff this buffer is wrapping lines, otherwise it is using a
130 * horizontal scrollbar. */
133 /* If a fontset is supplied for the widget, use_wchar become true,
134 * and we use GdkWchar as the encoding of text. */
137 /* Frozen, don't do updates. @@@ fixme */
139 /* TEXT PROPERTIES */
141 /* A doubly-linked-list containing TextProperty objects. */
142 GList *text_properties;
143 /* The end of this list. */
144 GList *text_properties_end;
145 /* The first node before or on the point along with its offset to
146 * the point and the buffer's current point. This is the only
147 * PropertyMark whose index is guaranteed to remain correct
148 * following a buffer insertion or deletion. */
149 GtkSPropertyMark point;
153 union { GdkWChar *wc; guchar *ch; } scratch_buffer;
154 guint scratch_buffer_len;
162 gint cursor_pos_x; /* Position of cursor. */
163 gint cursor_pos_y; /* Baseline of line cursor is drawn on. */
164 GtkSPropertyMark cursor_mark; /* Where it is in the buffer. */
165 GdkWChar cursor_char; /* Character to redraw. */
166 gchar cursor_char_offset; /* Distance from baseline of the font. */
167 gint cursor_virtual_x; /* Where it would be if it could be. */
168 gint cursor_drawn_level; /* How many people have undrawn. */
177 gint default_tab_width;
179 GtkSTextFont *current_font; /* Text font for current style */
181 /* Timer used for auto-scrolling off ends */
184 guint button; /* currently pressed mouse button */
185 GdkGC *bg_gc; /* gc for drawing background pixmap */
188 * properties added for different cursor
190 gboolean cursor_visible; /* whether cursor is visible */
191 gboolean cursor_timer_on; /* blinking enabled */
192 guint cursor_off_ms; /* cursor off time */
193 guint cursor_on_ms; /* cursor on time */
194 gboolean cursor_state_on; /* state */
195 guint32 cursor_timer_id; /* blinking timer */
196 guint32 cursor_idle_time_timer_id; /* timer id */
198 GtkSTextCursorType cursor_type;
201 * properties added for rmargin
203 gint wrap_rmargin; /* right margin */
206 * properties added for persist column position when
207 * using up and down key */
211 struct _GtkSTextClass
213 GtkEditableClass parent_class;
215 void (*set_scroll_adjustments) (GtkSText *text,
216 GtkAdjustment *hadjustment,
217 GtkAdjustment *vadjustment);
221 GtkType gtk_stext_get_type (void);
222 GtkWidget* gtk_stext_new (GtkAdjustment *hadj,
223 GtkAdjustment *vadj);
224 void gtk_stext_set_editable (GtkSText *text,
226 void gtk_stext_set_word_wrap (GtkSText *text,
228 void gtk_stext_set_line_wrap (GtkSText *text,
230 void gtk_stext_set_adjustments (GtkSText *text,
232 GtkAdjustment *vadj);
233 void gtk_stext_set_point (GtkSText *text,
235 guint gtk_stext_get_point (GtkSText *text);
236 guint gtk_stext_get_length (GtkSText *text);
237 void gtk_stext_freeze (GtkSText *text);
238 void gtk_stext_thaw (GtkSText *text);
239 void gtk_stext_insert (GtkSText *text,
245 gint gtk_stext_backward_delete (GtkSText *text,
247 gint gtk_stext_forward_delete (GtkSText *text,
252 void gtk_stext_set_blink (GtkSText *text,
253 gboolean blinking_on);
254 void gtk_stext_set_cursor_type (GtkSText *text,
255 GtkSTextCursorType cursor_type);
256 void gtk_stext_compact_buffer (GtkSText *text);
258 /* these are normally not exported! */
259 void gtk_stext_move_forward_character (GtkSText *text);
260 void gtk_stext_move_backward_character (GtkSText *text);
261 void gtk_stext_move_forward_word (GtkSText *text);
262 void gtk_stext_move_backward_word (GtkSText *text);
263 void gtk_stext_move_beginning_of_line (GtkSText *text);
264 void gtk_stext_move_end_of_line (GtkSText *text);
265 void gtk_stext_move_next_line (GtkSText *text);
266 void gtk_stext_move_previous_line (GtkSText *text);
267 void gtk_stext_delete_forward_character (GtkSText *text);
268 void gtk_stext_delete_backward_character (GtkSText *text);
269 void gtk_stext_delete_forward_word (GtkSText *text);
270 void gtk_stext_delete_backward_word (GtkSText *text);
271 void gtk_stext_delete_line (GtkSText *text);
272 void gtk_stext_delete_to_line_end (GtkSText *text);
275 /* Set the rmargin for the stext. if rmargin is 0, then reset to old
277 void gtk_stext_set_wrap_rmargin (GtkSText *text, gint rmargin);
279 /* gtk stext functions */
280 gboolean gtk_stext_match_string (GtkSText *text,
285 guint gtk_stext_str_compare_n (GtkSText *text,
290 guint gtk_stext_str_compare (GtkSText *text,
294 gint gtkut_stext_find (GtkSText *text,
298 gboolean gtk_stext_is_uri_string (GtkSText *text,
301 void gtkut_stext_clear (GtkSText *text);
304 #define GTK_STEXT_INDEX(t, index) (((t)->use_wchar) \
305 ? ((index) < (t)->gap_position ? (t)->text.wc[index] : \
306 (t)->text.wc[(index)+(t)->gap_size]) \
307 : ((index) < (t)->gap_position ? (t)->text.ch[index] : \
308 (t)->text.ch[(index)+(t)->gap_size]))
312 #endif /* __cplusplus */
315 #endif /* __GTK_STEXT_H__ */