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.
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
;
55 typedef enum _GtkSTextCursorType GtkSTextCursorType
;
57 enum _GtkSTextCursorType
63 struct _GtkSPropertyMark
65 /* Position in list. */
68 /* Offset into that property. */
86 GdkPixmap
* line_wrap_bitmap
;
87 GdkPixmap
* line_arrow_bitmap
;
89 /* GAPPED TEXT SEGMENT */
91 /* The text, a single segment of text a'la emacs, with a gap
92 * where insertion occurs. */
93 union { GdkWChar
*wc
; guchar
*ch
; } text
;
94 /* The allocated length of the text segment. */
96 /* The gap position, index into address where a char
97 * should be inserted. */
99 /* The gap size, s.t. *(text + gap_position + gap_size) is
100 * the first valid character following the gap. */
102 /* The last character position, index into address where a
103 * character should be appeneded. Thus, text_end - gap_size
104 * is the length of the actual data. */
106 /* LINE START CACHE */
108 /* A cache of line-start information. Data is a LineParam*. */
109 GList
*line_start_cache
;
110 /* Index to the start of the first visible line. */
111 guint first_line_start_index
;
112 /* The number of pixels cut off of the top line. */
113 guint first_cut_pixels
;
114 /* First visible horizontal pixel. */
115 guint first_onscreen_hor_pixel
;
116 /* First visible vertical pixel. */
117 guint first_onscreen_ver_pixel
;
121 /* True iff this buffer is wrapping lines, otherwise it is using a
122 * horizontal scrollbar. */
125 /* If a fontset is supplied for the widget, use_wchar become true,
126 * and we use GdkWchar as the encoding of text. */
129 /* Frozen, don't do updates. @@@ fixme */
131 /* TEXT PROPERTIES */
133 /* A doubly-linked-list containing TextProperty objects. */
134 GList
*text_properties
;
135 /* The end of this list. */
136 GList
*text_properties_end
;
137 /* The first node before or on the point along with its offset to
138 * the point and the buffer's current point. This is the only
139 * PropertyMark whose index is guaranteed to remain correct
140 * following a buffer insertion or deletion. */
141 GtkSPropertyMark point
;
145 union { GdkWChar
*wc
; guchar
*ch
; } scratch_buffer
;
146 guint scratch_buffer_len
;
154 gint cursor_pos_x
; /* Position of cursor. */
155 gint cursor_pos_y
; /* Baseline of line cursor is drawn on. */
156 GtkSPropertyMark cursor_mark
; /* Where it is in the buffer. */
157 GdkWChar cursor_char
; /* Character to redraw. */
158 gchar cursor_char_offset
; /* Distance from baseline of the font. */
159 gint cursor_virtual_x
; /* Where it would be if it could be. */
160 gint cursor_drawn_level
; /* How many people have undrawn. */
169 gint default_tab_width
;
171 GtkSTextFont
*current_font
; /* Text font for current style */
173 /* Timer used for auto-scrolling off ends */
176 guint button
; /* currently pressed mouse button */
177 GdkGC
*bg_gc
; /* gc for drawing background pixmap */
180 * properties added for different cursor
182 gboolean cursor_visible
; /* whether cursor is visible */
183 gboolean cursor_timer_on
; /* blinking enabled */
184 guint cursor_off_ms
, cursor_on_ms
; /* cursor off / on time */
185 gboolean cursor_state_on
; /* state */
186 guint32 cursor_timer_id
; /* blinking timer */
187 guint32 cursor_idle_time_timer_id
; /* timer id */
189 GtkSTextCursorType cursor_type
;
192 * properties added for rmargin
194 gint wrap_rmargin
; /* right margin */
197 * properties added for persist column position when
198 * using up and down key */
202 struct _GtkSTextClass
204 GtkEditableClass parent_class
;
206 void (*set_scroll_adjustments
) (GtkSText
*text
,
207 GtkAdjustment
*hadjustment
,
208 GtkAdjustment
*vadjustment
);
212 GtkType
gtk_stext_get_type (void);
213 GtkWidget
* gtk_stext_new (GtkAdjustment
*hadj
,
214 GtkAdjustment
*vadj
);
215 void gtk_stext_set_editable (GtkSText
*text
,
217 void gtk_stext_set_word_wrap (GtkSText
*text
,
219 void gtk_stext_set_line_wrap (GtkSText
*text
,
221 void gtk_stext_set_adjustments (GtkSText
*text
,
223 GtkAdjustment
*vadj
);
224 void gtk_stext_set_point (GtkSText
*text
,
226 guint
gtk_stext_get_point (GtkSText
*text
);
227 guint
gtk_stext_get_length (GtkSText
*text
);
228 void gtk_stext_freeze (GtkSText
*text
);
229 void gtk_stext_thaw (GtkSText
*text
);
230 void gtk_stext_insert (GtkSText
*text
,
236 gint
gtk_stext_backward_delete (GtkSText
*text
,
238 gint
gtk_stext_forward_delete (GtkSText
*text
,
243 void gtk_stext_set_blink (GtkSText
*text
, gboolean blinking_on
);
245 /* Set the rmargin for the stext. if rmargin is 0, then reset to old
247 void gtk_stext_set_wrap_rmargin (GtkSText
*text
, gint rmargin
);
249 void gtk_stext_set_cursor_type (GtkSText
*text
, GtkSTextCursorType cursor_type
);
251 #define GTK_STEXT_INDEX(t, index) (((t)->use_wchar) \
252 ? ((index) < (t)->gap_position ? (t)->text.wc[index] : \
253 (t)->text.wc[(index)+(t)->gap_size]) \
254 : ((index) < (t)->gap_position ? (t)->text.ch[index] : \
255 (t)->text.ch[(index)+(t)->gap_size]))
259 #endif /* __cplusplus */
262 #endif /* __GTK_STEXT_H__ */