| 1 | /* GTK - The GIMP Toolkit |
| 2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
| 3 | * |
| 4 | * This library is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU Lesser 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. |
| 8 | * |
| 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 | * Lesser General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU Lesser 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. |
| 18 | */ |
| 19 | |
| 20 | /* |
| 21 | * Modified by the GTK+ Team and others 1997-2000. 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/. |
| 25 | */ |
| 26 | |
| 27 | #ifdef GTK_ENABLE_BROKEN |
| 28 | |
| 29 | #ifndef __GTK_TEXT_H__ |
| 30 | #define __GTK_TEXT_H__ |
| 31 | |
| 32 | |
| 33 | #include <gtk/gtkoldeditable.h> |
| 34 | |
| 35 | |
| 36 | G_BEGIN_DECLS |
| 37 | |
| 38 | #define GTK_TYPE_TEXT (gtk_text_get_type ()) |
| 39 | #define GTK_TEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT, GtkText)) |
| 40 | #define GTK_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT, GtkTextClass)) |
| 41 | #define GTK_IS_TEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT)) |
| 42 | #define GTK_IS_TEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT)) |
| 43 | #define GTK_TEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT, GtkTextClass)) |
| 44 | |
| 45 | |
| 46 | typedef struct _GtkTextFont GtkTextFont; |
| 47 | typedef struct _GtkPropertyMark GtkPropertyMark; |
| 48 | typedef struct _GtkText GtkText; |
| 49 | typedef struct _GtkTextClass GtkTextClass; |
| 50 | |
| 51 | struct _GtkPropertyMark |
| 52 | { |
| 53 | /* Position in list. */ |
| 54 | GList* property; |
| 55 | |
| 56 | /* Offset into that property. */ |
| 57 | guint offset; |
| 58 | |
| 59 | /* Current index. */ |
| 60 | guint index; |
| 61 | }; |
| 62 | |
| 63 | struct _GtkText |
| 64 | { |
| 65 | GtkOldEditable old_editable; |
| 66 | |
| 67 | GdkWindow *text_area; |
| 68 | |
| 69 | GtkAdjustment *hadj; |
| 70 | GtkAdjustment *vadj; |
| 71 | |
| 72 | GdkGC *gc; |
| 73 | |
| 74 | GdkPixmap* line_wrap_bitmap; |
| 75 | GdkPixmap* line_arrow_bitmap; |
| 76 | |
| 77 | /* GAPPED TEXT SEGMENT */ |
| 78 | |
| 79 | /* The text, a single segment of text a'la emacs, with a gap |
| 80 | * where insertion occurs. */ |
| 81 | union { GdkWChar *wc; guchar *ch; } text; |
| 82 | /* The allocated length of the text segment. */ |
| 83 | guint text_len; |
| 84 | /* The gap position, index into address where a char |
| 85 | * should be inserted. */ |
| 86 | guint gap_position; |
| 87 | /* The gap size, s.t. *(text + gap_position + gap_size) is |
| 88 | * the first valid character following the gap. */ |
| 89 | guint gap_size; |
| 90 | /* The last character position, index into address where a |
| 91 | * character should be appeneded. Thus, text_end - gap_size |
| 92 | * is the length of the actual data. */ |
| 93 | guint text_end; |
| 94 | /* LINE START CACHE */ |
| 95 | |
| 96 | /* A cache of line-start information. Data is a LineParam*. */ |
| 97 | GList *line_start_cache; |
| 98 | /* Index to the start of the first visible line. */ |
| 99 | guint first_line_start_index; |
| 100 | /* The number of pixels cut off of the top line. */ |
| 101 | guint first_cut_pixels; |
| 102 | /* First visible horizontal pixel. */ |
| 103 | guint first_onscreen_hor_pixel; |
| 104 | /* First visible vertical pixel. */ |
| 105 | guint first_onscreen_ver_pixel; |
| 106 | |
| 107 | /* FLAGS */ |
| 108 | |
| 109 | /* True iff this buffer is wrapping lines, otherwise it is using a |
| 110 | * horizontal scrollbar. */ |
| 111 | guint line_wrap : 1; |
| 112 | guint word_wrap : 1; |
| 113 | /* If a fontset is supplied for the widget, use_wchar become true, |
| 114 | * and we use GdkWchar as the encoding of text. */ |
| 115 | guint use_wchar : 1; |
| 116 | |
| 117 | /* Frozen, don't do updates. @@@ fixme */ |
| 118 | guint freeze_count; |
| 119 | /* TEXT PROPERTIES */ |
| 120 | |
| 121 | /* A doubly-linked-list containing TextProperty objects. */ |
| 122 | GList *text_properties; |
| 123 | /* The end of this list. */ |
| 124 | GList *text_properties_end; |
| 125 | /* The first node before or on the point along with its offset to |
| 126 | * the point and the buffer's current point. This is the only |
| 127 | * PropertyMark whose index is guaranteed to remain correct |
| 128 | * following a buffer insertion or deletion. */ |
| 129 | GtkPropertyMark point; |
| 130 | |
| 131 | /* SCRATCH AREA */ |
| 132 | |
| 133 | union { GdkWChar *wc; guchar *ch; } scratch_buffer; |
| 134 | guint scratch_buffer_len; |
| 135 | |
| 136 | /* SCROLLING */ |
| 137 | |
| 138 | gint last_ver_value; |
| 139 | |
| 140 | /* CURSOR */ |
| 141 | |
| 142 | gint cursor_pos_x; /* Position of cursor. */ |
| 143 | gint cursor_pos_y; /* Baseline of line cursor is drawn on. */ |
| 144 | GtkPropertyMark cursor_mark; /* Where it is in the buffer. */ |
| 145 | GdkWChar cursor_char; /* Character to redraw. */ |
| 146 | gchar cursor_char_offset; /* Distance from baseline of the font. */ |
| 147 | gint cursor_virtual_x; /* Where it would be if it could be. */ |
| 148 | gint cursor_drawn_level; /* How many people have undrawn. */ |
| 149 | |
| 150 | /* Current Line */ |
| 151 | |
| 152 | GList *current_line; |
| 153 | |
| 154 | /* Tab Stops */ |
| 155 | |
| 156 | GList *tab_stops; |
| 157 | gint default_tab_width; |
| 158 | |
| 159 | GtkTextFont *current_font; /* Text font for current style */ |
| 160 | |
| 161 | /* Timer used for auto-scrolling off ends */ |
| 162 | gint timer; |
| 163 | |
| 164 | guint button; /* currently pressed mouse button */ |
| 165 | GdkGC *bg_gc; /* gc for drawing background pixmap */ |
| 166 | }; |
| 167 | |
| 168 | struct _GtkTextClass |
| 169 | { |
| 170 | GtkOldEditableClass parent_class; |
| 171 | |
| 172 | void (*set_scroll_adjustments) (GtkText *text, |
| 173 | GtkAdjustment *hadjustment, |
| 174 | GtkAdjustment *vadjustment); |
| 175 | }; |
| 176 | |
| 177 | |
| 178 | GType gtk_text_get_type (void) G_GNUC_CONST; |
| 179 | GtkWidget* gtk_text_new (GtkAdjustment *hadj, |
| 180 | GtkAdjustment *vadj); |
| 181 | void gtk_text_set_editable (GtkText *text, |
| 182 | gboolean editable); |
| 183 | void gtk_text_set_word_wrap (GtkText *text, |
| 184 | gboolean word_wrap); |
| 185 | void gtk_text_set_line_wrap (GtkText *text, |
| 186 | gboolean line_wrap); |
| 187 | void gtk_text_set_adjustments (GtkText *text, |
| 188 | GtkAdjustment *hadj, |
| 189 | GtkAdjustment *vadj); |
| 190 | void gtk_text_set_point (GtkText *text, |
| 191 | guint index); |
| 192 | guint gtk_text_get_point (GtkText *text); |
| 193 | guint gtk_text_get_length (GtkText *text); |
| 194 | void gtk_text_freeze (GtkText *text); |
| 195 | void gtk_text_thaw (GtkText *text); |
| 196 | void gtk_text_insert (GtkText *text, |
| 197 | GdkFont *font, |
| 198 | const GdkColor *fore, |
| 199 | const GdkColor *back, |
| 200 | const char *chars, |
| 201 | gint length); |
| 202 | gboolean gtk_text_backward_delete (GtkText *text, |
| 203 | guint nchars); |
| 204 | gboolean gtk_text_forward_delete (GtkText *text, |
| 205 | guint nchars); |
| 206 | |
| 207 | #define GTK_TEXT_INDEX(t, index) (((t)->use_wchar) \ |
| 208 | ? ((index) < (t)->gap_position ? (t)->text.wc[index] : \ |
| 209 | (t)->text.wc[(index)+(t)->gap_size]) \ |
| 210 | : ((index) < (t)->gap_position ? (t)->text.ch[index] : \ |
| 211 | (t)->text.ch[(index)+(t)->gap_size])) |
| 212 | |
| 213 | G_END_DECLS |
| 214 | |
| 215 | #endif /* __GTK_TEXT_H__ */ |
| 216 | |
| 217 | #endif /* GTK_ENABLE_BROKEN */ |
| 218 | |