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

source code of gtk/gtk/gtktextview.h