gtktextview.h 17.3 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
2 3 4 5 6 7 8 9 10
 * gtktextview.h Copyright (C) 2000 Red Hat, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 13 14
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
Javier Jardón's avatar
Javier Jardón committed
15
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 17 18 19 20 21
 */

/*
 * Modified by the GTK+ Team and others 1997-2000.  See the AUTHORS
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
22
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 24
 */

25 26 27
#ifndef __GTK_TEXT_VIEW_H__
#define __GTK_TEXT_VIEW_H__

28
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
29 30 31
#error "Only <gtk/gtk.h> can be included directly."
#endif

32 33 34
#include <gtk/gtkcontainer.h>
#include <gtk/gtkimcontext.h>
#include <gtk/gtktextbuffer.h>
35
#include <gtk/gtkmenu.h>
36

37
G_BEGIN_DECLS
38

39
#define GTK_TYPE_TEXT_VIEW             (gtk_text_view_get_type ())
Manish Singh's avatar
Manish Singh committed
40 41 42 43 44
#define GTK_TEXT_VIEW(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_VIEW, GtkTextView))
#define GTK_TEXT_VIEW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
#define GTK_IS_TEXT_VIEW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_VIEW))
#define GTK_IS_TEXT_VIEW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_VIEW))
#define GTK_TEXT_VIEW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
45

46 47 48 49 50 51 52 53 54 55 56
/**
 * GtkTextWindowType:
 * @GTK_TEXT_WINDOW_WIDGET: Window that floats over scrolling areas.
 * @GTK_TEXT_WINDOW_TEXT: Scrollable text window.
 * @GTK_TEXT_WINDOW_LEFT: Left side border window.
 * @GTK_TEXT_WINDOW_RIGHT: Right side border window.
 * @GTK_TEXT_WINDOW_TOP: Top border window.
 * @GTK_TEXT_WINDOW_BOTTOM: Bottom border window.
 *
 * Used to reference the parts of #GtkTextView.
 */
57 58
typedef enum
{
59
  /*< private >*/
60
  GTK_TEXT_WINDOW_PRIVATE,
61
  /*< public >*/
62 63 64 65 66 67 68 69
  GTK_TEXT_WINDOW_WIDGET,
  GTK_TEXT_WINDOW_TEXT,
  GTK_TEXT_WINDOW_LEFT,
  GTK_TEXT_WINDOW_RIGHT,
  GTK_TEXT_WINDOW_TOP,
  GTK_TEXT_WINDOW_BOTTOM
} GtkTextWindowType;

70 71 72 73 74 75
/**
 * GTK_TEXT_VIEW_PRIORITY_VALIDATE:
 *
 * The priority at which the text view validates onscreen lines
 * in an idle job in the background.
 */
Havoc Pennington's avatar
Havoc Pennington committed
76 77
#define GTK_TEXT_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)

78 79 80
typedef struct _GtkTextView        GtkTextView;
typedef struct _GtkTextViewPrivate GtkTextViewPrivate;
typedef struct _GtkTextViewClass   GtkTextViewClass;
81

82 83
struct _GtkTextView
{
84 85
  GtkContainer parent_instance;

86
  GtkTextViewPrivate *priv;
87 88
};

89 90
struct _GtkTextViewClass
{
91 92
  GtkContainerClass parent_class;

93
  void (* populate_popup)           (GtkTextView    *text_view,
94
                                     GtkWidget      *popup);
95

96 97 98
  /* These are all RUN_ACTION signals for keybindings */

  /* move insertion point */
99 100 101 102
  void (* move_cursor) (GtkTextView    *text_view,
                        GtkMovementStep step,
                        gint            count,
                        gboolean        extend_selection);
103

104
  /* move the "anchor" (what Emacs calls the mark) to the cursor position */
105
  void (* set_anchor)  (GtkTextView    *text_view);
106 107

  /* Edits */
108 109 110 111 112
  void (* insert_at_cursor)      (GtkTextView *text_view,
                                  const gchar *str);
  void (* delete_from_cursor)    (GtkTextView  *text_view,
                                  GtkDeleteType type,
                                  gint          count);
113
  void (* backspace)             (GtkTextView *text_view);
114

115
  /* cut copy paste */
116 117 118
  void (* cut_clipboard)   (GtkTextView *text_view);
  void (* copy_clipboard)  (GtkTextView *text_view);
  void (* paste_clipboard) (GtkTextView *text_view);
119 120
  /* overwrite */
  void (* toggle_overwrite) (GtkTextView *text_view);
121

122 123
  GtkTextBuffer * (* create_buffer) (GtkTextView *text_view);

124 125 126 127 128 129 130 131
  /* Padding for future expansion */
  void (*_gtk_reserved1) (void);
  void (*_gtk_reserved2) (void);
  void (*_gtk_reserved3) (void);
  void (*_gtk_reserved4) (void);
  void (*_gtk_reserved5) (void);
  void (*_gtk_reserved6) (void);
  void (*_gtk_reserved7) (void);
132 133
};

134
GDK_AVAILABLE_IN_ALL
Manish Singh's avatar
Manish Singh committed
135
GType          gtk_text_view_get_type              (void) G_GNUC_CONST;
136
GDK_AVAILABLE_IN_ALL
137
GtkWidget *    gtk_text_view_new                   (void);
138
GDK_AVAILABLE_IN_ALL
139
GtkWidget *    gtk_text_view_new_with_buffer       (GtkTextBuffer *buffer);
140
GDK_AVAILABLE_IN_ALL
141
void           gtk_text_view_set_buffer            (GtkTextView   *text_view,
142
                                                    GtkTextBuffer *buffer);
143
GDK_AVAILABLE_IN_ALL
144
GtkTextBuffer *gtk_text_view_get_buffer            (GtkTextView   *text_view);
145
GDK_AVAILABLE_IN_ALL
146 147 148 149 150 151
gboolean       gtk_text_view_scroll_to_iter        (GtkTextView   *text_view,
                                                    GtkTextIter   *iter,
                                                    gdouble        within_margin,
                                                    gboolean       use_align,
                                                    gdouble        xalign,
                                                    gdouble        yalign);
152
GDK_AVAILABLE_IN_ALL
153
void           gtk_text_view_scroll_to_mark        (GtkTextView   *text_view,
154
                                                    GtkTextMark   *mark,
155 156 157 158
                                                    gdouble        within_margin,
                                                    gboolean       use_align,
                                                    gdouble        xalign,
                                                    gdouble        yalign);
159
GDK_AVAILABLE_IN_ALL
160
void           gtk_text_view_scroll_mark_onscreen  (GtkTextView   *text_view,
161
                                                    GtkTextMark   *mark);
162
GDK_AVAILABLE_IN_ALL
163
gboolean       gtk_text_view_move_mark_onscreen    (GtkTextView   *text_view,
164
                                                    GtkTextMark   *mark);
165
GDK_AVAILABLE_IN_ALL
166 167
gboolean       gtk_text_view_place_cursor_onscreen (GtkTextView   *text_view);

168
GDK_AVAILABLE_IN_ALL
169
void           gtk_text_view_get_visible_rect      (GtkTextView   *text_view,
170
                                                    GdkRectangle  *visible_rect);
171
GDK_AVAILABLE_IN_ALL
172 173
void           gtk_text_view_set_cursor_visible    (GtkTextView   *text_view,
                                                    gboolean       setting);
174
GDK_AVAILABLE_IN_ALL
175 176
gboolean       gtk_text_view_get_cursor_visible    (GtkTextView   *text_view);

177
GDK_AVAILABLE_IN_ALL
178 179 180 181
void           gtk_text_view_get_cursor_locations  (GtkTextView       *text_view,
                                                    const GtkTextIter *iter,
                                                    GdkRectangle      *strong,
                                                    GdkRectangle      *weak);
182
GDK_AVAILABLE_IN_ALL
183 184 185
void           gtk_text_view_get_iter_location     (GtkTextView   *text_view,
                                                    const GtkTextIter *iter,
                                                    GdkRectangle  *location);
186
GDK_AVAILABLE_IN_ALL
187
void           gtk_text_view_get_iter_at_location  (GtkTextView   *text_view,
188 189 190
                                                    GtkTextIter   *iter,
                                                    gint           x,
                                                    gint           y);
191
GDK_AVAILABLE_IN_ALL
192 193 194 195 196
void           gtk_text_view_get_iter_at_position  (GtkTextView   *text_view,
                                                    GtkTextIter   *iter,
						    gint          *trailing,
                                                    gint           x,
                                                    gint           y);
197
GDK_AVAILABLE_IN_ALL
Havoc Pennington's avatar
Havoc Pennington committed
198 199 200 201
void           gtk_text_view_get_line_yrange       (GtkTextView       *text_view,
                                                    const GtkTextIter *iter,
                                                    gint              *y,
                                                    gint              *height);
202

203
GDK_AVAILABLE_IN_ALL
Havoc Pennington's avatar
Havoc Pennington committed
204 205 206 207
void           gtk_text_view_get_line_at_y         (GtkTextView       *text_view,
                                                    GtkTextIter       *target_iter,
                                                    gint               y,
                                                    gint              *line_top);
208

209
GDK_AVAILABLE_IN_ALL
210 211 212 213 214 215
void gtk_text_view_buffer_to_window_coords (GtkTextView       *text_view,
                                            GtkTextWindowType  win,
                                            gint               buffer_x,
                                            gint               buffer_y,
                                            gint              *window_x,
                                            gint              *window_y);
216
GDK_AVAILABLE_IN_ALL
217 218 219 220 221 222 223
void gtk_text_view_window_to_buffer_coords (GtkTextView       *text_view,
                                            GtkTextWindowType  win,
                                            gint               window_x,
                                            gint               window_y,
                                            gint              *buffer_x,
                                            gint              *buffer_y);

224
GDK_DEPRECATED_IN_3_0_FOR(gtk_scrollable_get_hadjustment)
225
GtkAdjustment*   gtk_text_view_get_hadjustment (GtkTextView   *text_view);
226
GDK_DEPRECATED_IN_3_0_FOR(gtk_scrollable_get_vadjustment)
227
GtkAdjustment*   gtk_text_view_get_vadjustment (GtkTextView   *text_view);
228

229
GDK_AVAILABLE_IN_ALL
230 231
GdkWindow*        gtk_text_view_get_window      (GtkTextView       *text_view,
                                                 GtkTextWindowType  win);
232
GDK_AVAILABLE_IN_ALL
233 234 235
GtkTextWindowType gtk_text_view_get_window_type (GtkTextView       *text_view,
                                                 GdkWindow         *window);

236
GDK_AVAILABLE_IN_ALL
Havoc Pennington's avatar
Havoc Pennington committed
237 238 239
void gtk_text_view_set_border_window_size (GtkTextView       *text_view,
                                           GtkTextWindowType  type,
                                           gint               size);
240
GDK_AVAILABLE_IN_ALL
241 242
gint gtk_text_view_get_border_window_size (GtkTextView       *text_view,
					   GtkTextWindowType  type);
Havoc Pennington's avatar
Havoc Pennington committed
243

244
GDK_AVAILABLE_IN_ALL
245 246
gboolean gtk_text_view_forward_display_line           (GtkTextView       *text_view,
                                                       GtkTextIter       *iter);
247
GDK_AVAILABLE_IN_ALL
248 249
gboolean gtk_text_view_backward_display_line          (GtkTextView       *text_view,
                                                       GtkTextIter       *iter);
250
GDK_AVAILABLE_IN_ALL
251 252
gboolean gtk_text_view_forward_display_line_end       (GtkTextView       *text_view,
                                                       GtkTextIter       *iter);
253
GDK_AVAILABLE_IN_ALL
254 255
gboolean gtk_text_view_backward_display_line_start    (GtkTextView       *text_view,
                                                       GtkTextIter       *iter);
256
GDK_AVAILABLE_IN_ALL
257 258
gboolean gtk_text_view_starts_display_line            (GtkTextView       *text_view,
                                                       const GtkTextIter *iter);
259
GDK_AVAILABLE_IN_ALL
260 261 262
gboolean gtk_text_view_move_visually                  (GtkTextView       *text_view,
                                                       GtkTextIter       *iter,
                                                       gint               count);
263

264
GDK_AVAILABLE_IN_ALL
265
gboolean        gtk_text_view_im_context_filter_keypress        (GtkTextView       *text_view,
266
                                                                 GdkEventKey       *event);
267
GDK_AVAILABLE_IN_ALL
268 269
void            gtk_text_view_reset_im_context                  (GtkTextView       *text_view);

270
/* Adding child widgets */
271
GDK_AVAILABLE_IN_ALL
272 273 274 275
void gtk_text_view_add_child_at_anchor (GtkTextView          *text_view,
                                        GtkWidget            *child,
                                        GtkTextChildAnchor   *anchor);

276
GDK_AVAILABLE_IN_ALL
277 278 279 280 281 282 283
void gtk_text_view_add_child_in_window (GtkTextView          *text_view,
                                        GtkWidget            *child,
                                        GtkTextWindowType     which_window,
                                        /* window coordinates */
                                        gint                  xpos,
                                        gint                  ypos);

284
GDK_AVAILABLE_IN_ALL
285 286 287 288 289 290
void gtk_text_view_move_child          (GtkTextView          *text_view,
                                        GtkWidget            *child,
                                        /* window coordinates */
                                        gint                  xpos,
                                        gint                  ypos);

291 292
/* Default style settings (fallbacks if no tag affects the property) */

293
GDK_AVAILABLE_IN_ALL
294 295
void             gtk_text_view_set_wrap_mode          (GtkTextView      *text_view,
                                                       GtkWrapMode       wrap_mode);
296
GDK_AVAILABLE_IN_ALL
297
GtkWrapMode      gtk_text_view_get_wrap_mode          (GtkTextView      *text_view);
298
GDK_AVAILABLE_IN_ALL
299 300
void             gtk_text_view_set_editable           (GtkTextView      *text_view,
                                                       gboolean          setting);
301
GDK_AVAILABLE_IN_ALL
302
gboolean         gtk_text_view_get_editable           (GtkTextView      *text_view);
303
GDK_AVAILABLE_IN_ALL
304 305
void             gtk_text_view_set_overwrite          (GtkTextView      *text_view,
						       gboolean          overwrite);
306
GDK_AVAILABLE_IN_ALL
307
gboolean         gtk_text_view_get_overwrite          (GtkTextView      *text_view);
308
GDK_AVAILABLE_IN_ALL
309 310
void		 gtk_text_view_set_accepts_tab        (GtkTextView	*text_view,
						       gboolean		 accepts_tab);
311
GDK_AVAILABLE_IN_ALL
312
gboolean	 gtk_text_view_get_accepts_tab        (GtkTextView	*text_view);
313
GDK_AVAILABLE_IN_ALL
314 315
void             gtk_text_view_set_pixels_above_lines (GtkTextView      *text_view,
                                                       gint              pixels_above_lines);
316
GDK_AVAILABLE_IN_ALL
317
gint             gtk_text_view_get_pixels_above_lines (GtkTextView      *text_view);
318
GDK_AVAILABLE_IN_ALL
319 320
void             gtk_text_view_set_pixels_below_lines (GtkTextView      *text_view,
                                                       gint              pixels_below_lines);
321
GDK_AVAILABLE_IN_ALL
322
gint             gtk_text_view_get_pixels_below_lines (GtkTextView      *text_view);
323
GDK_AVAILABLE_IN_ALL
324 325
void             gtk_text_view_set_pixels_inside_wrap (GtkTextView      *text_view,
                                                       gint              pixels_inside_wrap);
326
GDK_AVAILABLE_IN_ALL
327
gint             gtk_text_view_get_pixels_inside_wrap (GtkTextView      *text_view);
328
GDK_AVAILABLE_IN_ALL
329 330
void             gtk_text_view_set_justification      (GtkTextView      *text_view,
                                                       GtkJustification  justification);
331
GDK_AVAILABLE_IN_ALL
332
GtkJustification gtk_text_view_get_justification      (GtkTextView      *text_view);
333
GDK_AVAILABLE_IN_ALL
334 335
void             gtk_text_view_set_left_margin        (GtkTextView      *text_view,
                                                       gint              left_margin);
336
GDK_AVAILABLE_IN_ALL
337
gint             gtk_text_view_get_left_margin        (GtkTextView      *text_view);
338
GDK_AVAILABLE_IN_ALL
339 340
void             gtk_text_view_set_right_margin       (GtkTextView      *text_view,
                                                       gint              right_margin);
341
GDK_AVAILABLE_IN_ALL
342
gint             gtk_text_view_get_right_margin       (GtkTextView      *text_view);
343
GDK_AVAILABLE_IN_ALL
344 345
void             gtk_text_view_set_indent             (GtkTextView      *text_view,
                                                       gint              indent);
346
GDK_AVAILABLE_IN_ALL
347
gint             gtk_text_view_get_indent             (GtkTextView      *text_view);
348
GDK_AVAILABLE_IN_ALL
349 350
void             gtk_text_view_set_tabs               (GtkTextView      *text_view,
                                                       PangoTabArray    *tabs);
351
GDK_AVAILABLE_IN_ALL
352 353
PangoTabArray*   gtk_text_view_get_tabs               (GtkTextView      *text_view);

Havoc Pennington's avatar
Havoc Pennington committed
354
/* note that the return value of this changes with the theme */
355
GDK_AVAILABLE_IN_ALL
Havoc Pennington's avatar
Havoc Pennington committed
356
GtkTextAttributes* gtk_text_view_get_default_attributes (GtkTextView    *text_view);
357

358 359 360 361 362 363 364 365 366 367 368 369 370
GDK_AVAILABLE_IN_3_6
void             gtk_text_view_set_input_purpose      (GtkTextView      *text_view,
                                                       GtkInputPurpose   purpose);
GDK_AVAILABLE_IN_3_6
GtkInputPurpose  gtk_text_view_get_input_purpose      (GtkTextView      *text_view);

GDK_AVAILABLE_IN_3_6
void             gtk_text_view_set_input_hints        (GtkTextView      *text_view,
                                                       GtkInputHints     hints);
GDK_AVAILABLE_IN_3_6
GtkInputHints    gtk_text_view_get_input_hints        (GtkTextView      *text_view);


371
G_END_DECLS
372

373
#endif /* __GTK_TEXT_VIEW_H__ */