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