1/* GTK - The GIMP Toolkit
2 * gtktextview.h Copyright (C) 2000 Red Hat, Inc.
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, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23 */
24
25#ifndef __GTK_TEXT_VIEW_H__
26#define __GTK_TEXT_VIEW_H__
27
28#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
29#error "Only <gtk/gtk.h> can be included directly."
30#endif
31
32#include <gtk/gtkcontainer.h>
33#include <gtk/gtkimcontext.h>
34#include <gtk/gtktextbuffer.h>
35#include <gtk/gtkmenu.h>
36
37G_BEGIN_DECLS
38
39#define GTK_TYPE_TEXT_VIEW (gtk_text_view_get_type ())
40#define GTK_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_TEXT_VIEW, GtkTextView))
41#define GTK_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
42#define GTK_IS_TEXT_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_TEXT_VIEW))
43#define GTK_IS_TEXT_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_VIEW))
44#define GTK_TEXT_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
45
46/**
47 * GtkTextWindowType:
48 * @GTK_TEXT_WINDOW_WIDGET: Window that floats over scrolling areas.
49 * @GTK_TEXT_WINDOW_TEXT: Scrollable text window.
50 * @GTK_TEXT_WINDOW_LEFT: Left side border window.
51 * @GTK_TEXT_WINDOW_RIGHT: Right side border window.
52 * @GTK_TEXT_WINDOW_TOP: Top border window.
53 * @GTK_TEXT_WINDOW_BOTTOM: Bottom border window.
54 *
55 * Used to reference the parts of #GtkTextView.
56 */
57typedef enum
58{
59 /*< private >*/
60 GTK_TEXT_WINDOW_PRIVATE,
61 /*< public >*/
62 GTK_TEXT_WINDOW_WIDGET,
63 GTK_TEXT_WINDOW_TEXT,
64 GTK_TEXT_WINDOW_LEFT,
65 GTK_TEXT_WINDOW_RIGHT,
66 GTK_TEXT_WINDOW_TOP,
67 GTK_TEXT_WINDOW_BOTTOM
68} GtkTextWindowType;
69
70/**
71 * GtkTextViewLayer:
72 * @GTK_TEXT_VIEW_LAYER_BELOW: Old deprecated layer, use %GTK_TEXT_VIEW_LAYER_BELOW_TEXT instead
73 * @GTK_TEXT_VIEW_LAYER_ABOVE: Old deprecated layer, use %GTK_TEXT_VIEW_LAYER_ABOVE_TEXT instead
74 * @GTK_TEXT_VIEW_LAYER_BELOW_TEXT: The layer rendered below the text (but above the background). Since: 3.20
75 * @GTK_TEXT_VIEW_LAYER_ABOVE_TEXT: The layer rendered above the text. Since: 3.20
76 *
77 * Used to reference the layers of #GtkTextView for the purpose of customized
78 * drawing with the ::draw_layer vfunc.
79 */
80typedef enum
81{
82 GTK_TEXT_VIEW_LAYER_BELOW,
83 GTK_TEXT_VIEW_LAYER_ABOVE,
84 GTK_TEXT_VIEW_LAYER_BELOW_TEXT,
85 GTK_TEXT_VIEW_LAYER_ABOVE_TEXT
86} GtkTextViewLayer;
87
88/**
89 * GtkTextExtendSelection:
90 * @GTK_TEXT_EXTEND_SELECTION_WORD: Selects the current word. It is triggered by
91 * a double-click for example.
92 * @GTK_TEXT_EXTEND_SELECTION_LINE: Selects the current line. It is triggered by
93 * a triple-click for example.
94 *
95 * Granularity types that extend the text selection. Use the
96 * #GtkTextView::extend-selection signal to customize the selection.
97 *
98 * Since: 3.16
99 */
100typedef enum
101{
102 GTK_TEXT_EXTEND_SELECTION_WORD,
103 GTK_TEXT_EXTEND_SELECTION_LINE
104} GtkTextExtendSelection;
105
106/**
107 * GTK_TEXT_VIEW_PRIORITY_VALIDATE:
108 *
109 * The priority at which the text view validates onscreen lines
110 * in an idle job in the background.
111 */
112#define GTK_TEXT_VIEW_PRIORITY_VALIDATE (GDK_PRIORITY_REDRAW + 5)
113
114typedef struct _GtkTextView GtkTextView;
115typedef struct _GtkTextViewPrivate GtkTextViewPrivate;
116typedef struct _GtkTextViewClass GtkTextViewClass;
117
118struct _GtkTextView
119{
120 GtkContainer parent_instance;
121
122 /*< private >*/
123
124 GtkTextViewPrivate *priv;
125};
126
127/**
128 * GtkTextViewClass:
129 * @parent_class: The object class structure needs to be the first
130 * @populate_popup: The class handler for the #GtkTextView::populate-popup
131 * signal.
132 * @move_cursor: The class handler for the #GtkTextView::move-cursor
133 * keybinding signal.
134 * @set_anchor: The class handler for the #GtkTextView::set-anchor
135 * keybinding signal.
136 * @insert_at_cursor: The class handler for the #GtkTextView::insert-at-cursor
137 * keybinding signal.
138 * @delete_from_cursor: The class handler for the #GtkTextView::delete-from-cursor
139 * keybinding signal.
140 * @backspace: The class handler for the #GtkTextView::backspace
141 * keybinding signal.
142 * @cut_clipboard: The class handler for the #GtkTextView::cut-clipboard
143 * keybinding signal
144 * @copy_clipboard: The class handler for the #GtkTextview::copy-clipboard
145 * keybinding signal.
146 * @paste_clipboard: The class handler for the #GtkTextView::paste-clipboard
147 * keybinding signal.
148 * @toggle_overwrite: The class handler for the #GtkTextView::toggle-overwrite
149 * keybinding signal.
150 * @create_buffer: The create_buffer vfunc is called to create a #GtkTextBuffer
151 * for the text view. The default implementation is to just call
152 * gtk_text_buffer_new(). Since: 3.10
153 * @draw_layer: The draw_layer vfunc is called before and after the text
154 * view is drawing its own text. Applications can override this vfunc
155 * in a subclass to draw customized content underneath or above the
156 * text. In the %GTK_TEXT_VIEW_LAYER_BELOW_TEXT and %GTK_TEXT_VIEW_LAYER_ABOVE_TEXT
157 * the drawing is done in the buffer coordinate space, but the older (deprecated)
158 * layers %GTK_TEXT_VIEW_LAYER_BELOW and %GTK_TEXT_VIEW_LAYER_ABOVE work in viewport
159 * coordinates, which makes them unnecessarily hard to use. Since: 3.14
160 * @extend_selection: The class handler for the #GtkTextView::extend-selection
161 * signal. Since 3.16
162 */
163struct _GtkTextViewClass
164{
165 GtkContainerClass parent_class;
166
167 /*< public >*/
168
169 void (* populate_popup) (GtkTextView *text_view,
170 GtkWidget *popup);
171 void (* move_cursor) (GtkTextView *text_view,
172 GtkMovementStep step,
173 gint count,
174 gboolean extend_selection);
175 void (* set_anchor) (GtkTextView *text_view);
176 void (* insert_at_cursor) (GtkTextView *text_view,
177 const gchar *str);
178 void (* delete_from_cursor) (GtkTextView *text_view,
179 GtkDeleteType type,
180 gint count);
181 void (* backspace) (GtkTextView *text_view);
182 void (* cut_clipboard) (GtkTextView *text_view);
183 void (* copy_clipboard) (GtkTextView *text_view);
184 void (* paste_clipboard) (GtkTextView *text_view);
185 void (* toggle_overwrite) (GtkTextView *text_view);
186 GtkTextBuffer * (* create_buffer) (GtkTextView *text_view);
187 void (* draw_layer) (GtkTextView *text_view,
188 GtkTextViewLayer layer,
189 cairo_t *cr);
190 gboolean (* extend_selection) (GtkTextView *text_view,
191 GtkTextExtendSelection granularity,
192 const GtkTextIter *location,
193 GtkTextIter *start,
194 GtkTextIter *end);
195
196 /*< private >*/
197
198 /* Padding for future expansion */
199 void (*_gtk_reserved1) (void);
200 void (*_gtk_reserved2) (void);
201 void (*_gtk_reserved3) (void);
202 void (*_gtk_reserved4) (void);
203 void (*_gtk_reserved5) (void);
204};
205
206GDK_AVAILABLE_IN_ALL
207GType gtk_text_view_get_type (void) G_GNUC_CONST;
208GDK_AVAILABLE_IN_ALL
209GtkWidget * gtk_text_view_new (void);
210GDK_AVAILABLE_IN_ALL
211GtkWidget * gtk_text_view_new_with_buffer (GtkTextBuffer *buffer);
212GDK_AVAILABLE_IN_ALL
213void gtk_text_view_set_buffer (GtkTextView *text_view,
214 GtkTextBuffer *buffer);
215GDK_AVAILABLE_IN_ALL
216GtkTextBuffer *gtk_text_view_get_buffer (GtkTextView *text_view);
217GDK_AVAILABLE_IN_ALL
218gboolean gtk_text_view_scroll_to_iter (GtkTextView *text_view,
219 GtkTextIter *iter,
220 gdouble within_margin,
221 gboolean use_align,
222 gdouble xalign,
223 gdouble yalign);
224GDK_AVAILABLE_IN_ALL
225void gtk_text_view_scroll_to_mark (GtkTextView *text_view,
226 GtkTextMark *mark,
227 gdouble within_margin,
228 gboolean use_align,
229 gdouble xalign,
230 gdouble yalign);
231GDK_AVAILABLE_IN_ALL
232void gtk_text_view_scroll_mark_onscreen (GtkTextView *text_view,
233 GtkTextMark *mark);
234GDK_AVAILABLE_IN_ALL
235gboolean gtk_text_view_move_mark_onscreen (GtkTextView *text_view,
236 GtkTextMark *mark);
237GDK_AVAILABLE_IN_ALL
238gboolean gtk_text_view_place_cursor_onscreen (GtkTextView *text_view);
239
240GDK_AVAILABLE_IN_ALL
241void gtk_text_view_get_visible_rect (GtkTextView *text_view,
242 GdkRectangle *visible_rect);
243GDK_AVAILABLE_IN_ALL
244void gtk_text_view_set_cursor_visible (GtkTextView *text_view,
245 gboolean setting);
246GDK_AVAILABLE_IN_ALL
247gboolean gtk_text_view_get_cursor_visible (GtkTextView *text_view);
248
249GDK_AVAILABLE_IN_3_20
250void gtk_text_view_reset_cursor_blink (GtkTextView *text_view);
251
252GDK_AVAILABLE_IN_ALL
253void gtk_text_view_get_cursor_locations (GtkTextView *text_view,
254 const GtkTextIter *iter,
255 GdkRectangle *strong,
256 GdkRectangle *weak);
257GDK_AVAILABLE_IN_ALL
258void gtk_text_view_get_iter_location (GtkTextView *text_view,
259 const GtkTextIter *iter,
260 GdkRectangle *location);
261GDK_AVAILABLE_IN_ALL
262gboolean gtk_text_view_get_iter_at_location (GtkTextView *text_view,
263 GtkTextIter *iter,
264 gint x,
265 gint y);
266GDK_AVAILABLE_IN_ALL
267gboolean gtk_text_view_get_iter_at_position (GtkTextView *text_view,
268 GtkTextIter *iter,
269 gint *trailing,
270 gint x,
271 gint y);
272GDK_AVAILABLE_IN_ALL
273void gtk_text_view_get_line_yrange (GtkTextView *text_view,
274 const GtkTextIter *iter,
275 gint *y,
276 gint *height);
277
278GDK_AVAILABLE_IN_ALL
279void gtk_text_view_get_line_at_y (GtkTextView *text_view,
280 GtkTextIter *target_iter,
281 gint y,
282 gint *line_top);
283
284GDK_AVAILABLE_IN_ALL
285void gtk_text_view_buffer_to_window_coords (GtkTextView *text_view,
286 GtkTextWindowType win,
287 gint buffer_x,
288 gint buffer_y,
289 gint *window_x,
290 gint *window_y);
291GDK_AVAILABLE_IN_ALL
292void gtk_text_view_window_to_buffer_coords (GtkTextView *text_view,
293 GtkTextWindowType win,
294 gint window_x,
295 gint window_y,
296 gint *buffer_x,
297 gint *buffer_y);
298
299GDK_DEPRECATED_IN_3_0_FOR(gtk_scrollable_get_hadjustment)
300GtkAdjustment* gtk_text_view_get_hadjustment (GtkTextView *text_view);
301GDK_DEPRECATED_IN_3_0_FOR(gtk_scrollable_get_vadjustment)
302GtkAdjustment* gtk_text_view_get_vadjustment (GtkTextView *text_view);
303
304GDK_AVAILABLE_IN_ALL
305GdkWindow* gtk_text_view_get_window (GtkTextView *text_view,
306 GtkTextWindowType win);
307GDK_AVAILABLE_IN_ALL
308GtkTextWindowType gtk_text_view_get_window_type (GtkTextView *text_view,
309 GdkWindow *window);
310
311GDK_AVAILABLE_IN_ALL
312void gtk_text_view_set_border_window_size (GtkTextView *text_view,
313 GtkTextWindowType type,
314 gint size);
315GDK_AVAILABLE_IN_ALL
316gint gtk_text_view_get_border_window_size (GtkTextView *text_view,
317 GtkTextWindowType type);
318
319GDK_AVAILABLE_IN_ALL
320gboolean gtk_text_view_forward_display_line (GtkTextView *text_view,
321 GtkTextIter *iter);
322GDK_AVAILABLE_IN_ALL
323gboolean gtk_text_view_backward_display_line (GtkTextView *text_view,
324 GtkTextIter *iter);
325GDK_AVAILABLE_IN_ALL
326gboolean gtk_text_view_forward_display_line_end (GtkTextView *text_view,
327 GtkTextIter *iter);
328GDK_AVAILABLE_IN_ALL
329gboolean gtk_text_view_backward_display_line_start (GtkTextView *text_view,
330 GtkTextIter *iter);
331GDK_AVAILABLE_IN_ALL
332gboolean gtk_text_view_starts_display_line (GtkTextView *text_view,
333 const GtkTextIter *iter);
334GDK_AVAILABLE_IN_ALL
335gboolean gtk_text_view_move_visually (GtkTextView *text_view,
336 GtkTextIter *iter,
337 gint count);
338
339GDK_AVAILABLE_IN_ALL
340gboolean gtk_text_view_im_context_filter_keypress (GtkTextView *text_view,
341 GdkEventKey *event);
342GDK_AVAILABLE_IN_ALL
343void gtk_text_view_reset_im_context (GtkTextView *text_view);
344
345/* Adding child widgets */
346GDK_AVAILABLE_IN_ALL
347void gtk_text_view_add_child_at_anchor (GtkTextView *text_view,
348 GtkWidget *child,
349 GtkTextChildAnchor *anchor);
350
351GDK_AVAILABLE_IN_ALL
352void gtk_text_view_add_child_in_window (GtkTextView *text_view,
353 GtkWidget *child,
354 GtkTextWindowType which_window,
355 /* window coordinates */
356 gint xpos,
357 gint ypos);
358
359GDK_AVAILABLE_IN_ALL
360void gtk_text_view_move_child (GtkTextView *text_view,
361 GtkWidget *child,
362 /* window coordinates */
363 gint xpos,
364 gint ypos);
365
366/* Default style settings (fallbacks if no tag affects the property) */
367
368GDK_AVAILABLE_IN_ALL
369void gtk_text_view_set_wrap_mode (GtkTextView *text_view,
370 GtkWrapMode wrap_mode);
371GDK_AVAILABLE_IN_ALL
372GtkWrapMode gtk_text_view_get_wrap_mode (GtkTextView *text_view);
373GDK_AVAILABLE_IN_ALL
374void gtk_text_view_set_editable (GtkTextView *text_view,
375 gboolean setting);
376GDK_AVAILABLE_IN_ALL
377gboolean gtk_text_view_get_editable (GtkTextView *text_view);
378GDK_AVAILABLE_IN_ALL
379void gtk_text_view_set_overwrite (GtkTextView *text_view,
380 gboolean overwrite);
381GDK_AVAILABLE_IN_ALL
382gboolean gtk_text_view_get_overwrite (GtkTextView *text_view);
383GDK_AVAILABLE_IN_ALL
384void gtk_text_view_set_accepts_tab (GtkTextView *text_view,
385 gboolean accepts_tab);
386GDK_AVAILABLE_IN_ALL
387gboolean gtk_text_view_get_accepts_tab (GtkTextView *text_view);
388GDK_AVAILABLE_IN_ALL
389void gtk_text_view_set_pixels_above_lines (GtkTextView *text_view,
390 gint pixels_above_lines);
391GDK_AVAILABLE_IN_ALL
392gint gtk_text_view_get_pixels_above_lines (GtkTextView *text_view);
393GDK_AVAILABLE_IN_ALL
394void gtk_text_view_set_pixels_below_lines (GtkTextView *text_view,
395 gint pixels_below_lines);
396GDK_AVAILABLE_IN_ALL
397gint gtk_text_view_get_pixels_below_lines (GtkTextView *text_view);
398GDK_AVAILABLE_IN_ALL
399void gtk_text_view_set_pixels_inside_wrap (GtkTextView *text_view,
400 gint pixels_inside_wrap);
401GDK_AVAILABLE_IN_ALL
402gint gtk_text_view_get_pixels_inside_wrap (GtkTextView *text_view);
403GDK_AVAILABLE_IN_ALL
404void gtk_text_view_set_justification (GtkTextView *text_view,
405 GtkJustification justification);
406GDK_AVAILABLE_IN_ALL
407GtkJustification gtk_text_view_get_justification (GtkTextView *text_view);
408GDK_AVAILABLE_IN_ALL
409void gtk_text_view_set_left_margin (GtkTextView *text_view,
410 gint left_margin);
411GDK_AVAILABLE_IN_ALL
412gint gtk_text_view_get_left_margin (GtkTextView *text_view);
413GDK_AVAILABLE_IN_ALL
414void gtk_text_view_set_right_margin (GtkTextView *text_view,
415 gint right_margin);
416GDK_AVAILABLE_IN_ALL
417gint gtk_text_view_get_right_margin (GtkTextView *text_view);
418GDK_AVAILABLE_IN_3_18
419void gtk_text_view_set_top_margin (GtkTextView *text_view,
420 gint top_margin);
421GDK_AVAILABLE_IN_3_18
422gint gtk_text_view_get_top_margin (GtkTextView *text_view);
423GDK_AVAILABLE_IN_3_18
424void gtk_text_view_set_bottom_margin (GtkTextView *text_view,
425 gint bottom_margin);
426GDK_AVAILABLE_IN_3_18
427gint gtk_text_view_get_bottom_margin (GtkTextView *text_view);
428GDK_AVAILABLE_IN_ALL
429void gtk_text_view_set_indent (GtkTextView *text_view,
430 gint indent);
431GDK_AVAILABLE_IN_ALL
432gint gtk_text_view_get_indent (GtkTextView *text_view);
433GDK_AVAILABLE_IN_ALL
434void gtk_text_view_set_tabs (GtkTextView *text_view,
435 PangoTabArray *tabs);
436GDK_AVAILABLE_IN_ALL
437PangoTabArray* gtk_text_view_get_tabs (GtkTextView *text_view);
438
439/* note that the return value of this changes with the theme */
440GDK_AVAILABLE_IN_ALL
441GtkTextAttributes* gtk_text_view_get_default_attributes (GtkTextView *text_view);
442
443GDK_AVAILABLE_IN_3_6
444void gtk_text_view_set_input_purpose (GtkTextView *text_view,
445 GtkInputPurpose purpose);
446GDK_AVAILABLE_IN_3_6
447GtkInputPurpose gtk_text_view_get_input_purpose (GtkTextView *text_view);
448
449GDK_AVAILABLE_IN_3_6
450void gtk_text_view_set_input_hints (GtkTextView *text_view,
451 GtkInputHints hints);
452GDK_AVAILABLE_IN_3_6
453GtkInputHints gtk_text_view_get_input_hints (GtkTextView *text_view);
454
455GDK_AVAILABLE_IN_3_16
456void gtk_text_view_set_monospace (GtkTextView *text_view,
457 gboolean monospace);
458GDK_AVAILABLE_IN_3_16
459gboolean gtk_text_view_get_monospace (GtkTextView *text_view);
460
461G_END_DECLS
462
463#endif /* __GTK_TEXT_VIEW_H__ */
464