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 | |
36 | G_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 | */ |
56 | typedef 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 | */ |
74 | typedef 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 | */ |
90 | typedef 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 | |
104 | typedef struct _GtkTextView GtkTextView; |
105 | typedef struct _GtkTextViewPrivate GtkTextViewPrivate; |
106 | typedef struct _GtkTextViewClass GtkTextViewClass; |
107 | |
108 | struct _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 | */ |
149 | struct _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 | |
186 | GDK_AVAILABLE_IN_ALL |
187 | GType gtk_text_view_get_type (void) G_GNUC_CONST; |
188 | GDK_AVAILABLE_IN_ALL |
189 | GtkWidget * gtk_text_view_new (void); |
190 | GDK_AVAILABLE_IN_ALL |
191 | GtkWidget * gtk_text_view_new_with_buffer (GtkTextBuffer *buffer); |
192 | GDK_AVAILABLE_IN_ALL |
193 | void gtk_text_view_set_buffer (GtkTextView *text_view, |
194 | GtkTextBuffer *buffer); |
195 | GDK_AVAILABLE_IN_ALL |
196 | GtkTextBuffer *gtk_text_view_get_buffer (GtkTextView *text_view); |
197 | GDK_AVAILABLE_IN_ALL |
198 | gboolean 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); |
204 | GDK_AVAILABLE_IN_ALL |
205 | void 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); |
211 | GDK_AVAILABLE_IN_ALL |
212 | void gtk_text_view_scroll_mark_onscreen (GtkTextView *text_view, |
213 | GtkTextMark *mark); |
214 | GDK_AVAILABLE_IN_ALL |
215 | gboolean gtk_text_view_move_mark_onscreen (GtkTextView *text_view, |
216 | GtkTextMark *mark); |
217 | GDK_AVAILABLE_IN_ALL |
218 | gboolean gtk_text_view_place_cursor_onscreen (GtkTextView *text_view); |
219 | |
220 | GDK_AVAILABLE_IN_ALL |
221 | void gtk_text_view_get_visible_rect (GtkTextView *text_view, |
222 | GdkRectangle *visible_rect); |
223 | GDK_AVAILABLE_IN_ALL |
224 | void gtk_text_view_set_cursor_visible (GtkTextView *text_view, |
225 | gboolean setting); |
226 | GDK_AVAILABLE_IN_ALL |
227 | gboolean gtk_text_view_get_cursor_visible (GtkTextView *text_view); |
228 | |
229 | GDK_AVAILABLE_IN_ALL |
230 | void gtk_text_view_reset_cursor_blink (GtkTextView *text_view); |
231 | |
232 | GDK_AVAILABLE_IN_ALL |
233 | void gtk_text_view_get_cursor_locations (GtkTextView *text_view, |
234 | const GtkTextIter *iter, |
235 | GdkRectangle *strong, |
236 | GdkRectangle *weak); |
237 | GDK_AVAILABLE_IN_ALL |
238 | void gtk_text_view_get_iter_location (GtkTextView *text_view, |
239 | const GtkTextIter *iter, |
240 | GdkRectangle *location); |
241 | GDK_AVAILABLE_IN_ALL |
242 | gboolean gtk_text_view_get_iter_at_location (GtkTextView *text_view, |
243 | GtkTextIter *iter, |
244 | int x, |
245 | int y); |
246 | GDK_AVAILABLE_IN_ALL |
247 | gboolean gtk_text_view_get_iter_at_position (GtkTextView *text_view, |
248 | GtkTextIter *iter, |
249 | int *trailing, |
250 | int x, |
251 | int y); |
252 | GDK_AVAILABLE_IN_ALL |
253 | void gtk_text_view_get_line_yrange (GtkTextView *text_view, |
254 | const GtkTextIter *iter, |
255 | int *y, |
256 | int *height); |
257 | |
258 | GDK_AVAILABLE_IN_ALL |
259 | void gtk_text_view_get_line_at_y (GtkTextView *text_view, |
260 | GtkTextIter *target_iter, |
261 | int y, |
262 | int *line_top); |
263 | |
264 | GDK_AVAILABLE_IN_ALL |
265 | void 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); |
271 | GDK_AVAILABLE_IN_ALL |
272 | void 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 | |
279 | GDK_AVAILABLE_IN_ALL |
280 | gboolean gtk_text_view_forward_display_line (GtkTextView *text_view, |
281 | GtkTextIter *iter); |
282 | GDK_AVAILABLE_IN_ALL |
283 | gboolean gtk_text_view_backward_display_line (GtkTextView *text_view, |
284 | GtkTextIter *iter); |
285 | GDK_AVAILABLE_IN_ALL |
286 | gboolean gtk_text_view_forward_display_line_end (GtkTextView *text_view, |
287 | GtkTextIter *iter); |
288 | GDK_AVAILABLE_IN_ALL |
289 | gboolean gtk_text_view_backward_display_line_start (GtkTextView *text_view, |
290 | GtkTextIter *iter); |
291 | GDK_AVAILABLE_IN_ALL |
292 | gboolean gtk_text_view_starts_display_line (GtkTextView *text_view, |
293 | const GtkTextIter *iter); |
294 | GDK_AVAILABLE_IN_ALL |
295 | gboolean gtk_text_view_move_visually (GtkTextView *text_view, |
296 | GtkTextIter *iter, |
297 | int count); |
298 | |
299 | GDK_AVAILABLE_IN_ALL |
300 | gboolean gtk_text_view_im_context_filter_keypress (GtkTextView *text_view, |
301 | GdkEvent *event); |
302 | GDK_AVAILABLE_IN_ALL |
303 | void gtk_text_view_reset_im_context (GtkTextView *text_view); |
304 | |
305 | /* Adding child widgets */ |
306 | GDK_AVAILABLE_IN_ALL |
307 | GtkWidget *gtk_text_view_get_gutter (GtkTextView *text_view, |
308 | GtkTextWindowType win); |
309 | GDK_AVAILABLE_IN_ALL |
310 | void gtk_text_view_set_gutter (GtkTextView *text_view, |
311 | GtkTextWindowType win, |
312 | GtkWidget *widget); |
313 | GDK_AVAILABLE_IN_ALL |
314 | void gtk_text_view_add_child_at_anchor (GtkTextView *text_view, |
315 | GtkWidget *child, |
316 | GtkTextChildAnchor *anchor); |
317 | |
318 | GDK_AVAILABLE_IN_ALL |
319 | void gtk_text_view_add_overlay (GtkTextView *text_view, |
320 | GtkWidget *child, |
321 | int xpos, |
322 | int ypos); |
323 | |
324 | GDK_AVAILABLE_IN_ALL |
325 | void gtk_text_view_move_overlay (GtkTextView *text_view, |
326 | GtkWidget *child, |
327 | int xpos, |
328 | int ypos); |
329 | |
330 | GDK_AVAILABLE_IN_ALL |
331 | void gtk_text_view_remove (GtkTextView *text_view, |
332 | GtkWidget *child); |
333 | |
334 | /* Default style settings (fallbacks if no tag affects the property) */ |
335 | |
336 | GDK_AVAILABLE_IN_ALL |
337 | void gtk_text_view_set_wrap_mode (GtkTextView *text_view, |
338 | GtkWrapMode wrap_mode); |
339 | GDK_AVAILABLE_IN_ALL |
340 | GtkWrapMode gtk_text_view_get_wrap_mode (GtkTextView *text_view); |
341 | GDK_AVAILABLE_IN_ALL |
342 | void gtk_text_view_set_editable (GtkTextView *text_view, |
343 | gboolean setting); |
344 | GDK_AVAILABLE_IN_ALL |
345 | gboolean gtk_text_view_get_editable (GtkTextView *text_view); |
346 | GDK_AVAILABLE_IN_ALL |
347 | void gtk_text_view_set_overwrite (GtkTextView *text_view, |
348 | gboolean overwrite); |
349 | GDK_AVAILABLE_IN_ALL |
350 | gboolean gtk_text_view_get_overwrite (GtkTextView *text_view); |
351 | GDK_AVAILABLE_IN_ALL |
352 | void gtk_text_view_set_accepts_tab (GtkTextView *text_view, |
353 | gboolean accepts_tab); |
354 | GDK_AVAILABLE_IN_ALL |
355 | gboolean gtk_text_view_get_accepts_tab (GtkTextView *text_view); |
356 | GDK_AVAILABLE_IN_ALL |
357 | void gtk_text_view_set_pixels_above_lines (GtkTextView *text_view, |
358 | int pixels_above_lines); |
359 | GDK_AVAILABLE_IN_ALL |
360 | int gtk_text_view_get_pixels_above_lines (GtkTextView *text_view); |
361 | GDK_AVAILABLE_IN_ALL |
362 | void gtk_text_view_set_pixels_below_lines (GtkTextView *text_view, |
363 | int pixels_below_lines); |
364 | GDK_AVAILABLE_IN_ALL |
365 | int gtk_text_view_get_pixels_below_lines (GtkTextView *text_view); |
366 | GDK_AVAILABLE_IN_ALL |
367 | void gtk_text_view_set_pixels_inside_wrap (GtkTextView *text_view, |
368 | int pixels_inside_wrap); |
369 | GDK_AVAILABLE_IN_ALL |
370 | int gtk_text_view_get_pixels_inside_wrap (GtkTextView *text_view); |
371 | GDK_AVAILABLE_IN_ALL |
372 | void gtk_text_view_set_justification (GtkTextView *text_view, |
373 | GtkJustification justification); |
374 | GDK_AVAILABLE_IN_ALL |
375 | GtkJustification gtk_text_view_get_justification (GtkTextView *text_view); |
376 | GDK_AVAILABLE_IN_ALL |
377 | void gtk_text_view_set_left_margin (GtkTextView *text_view, |
378 | int left_margin); |
379 | GDK_AVAILABLE_IN_ALL |
380 | int gtk_text_view_get_left_margin (GtkTextView *text_view); |
381 | GDK_AVAILABLE_IN_ALL |
382 | void gtk_text_view_set_right_margin (GtkTextView *text_view, |
383 | int right_margin); |
384 | GDK_AVAILABLE_IN_ALL |
385 | int gtk_text_view_get_right_margin (GtkTextView *text_view); |
386 | GDK_AVAILABLE_IN_ALL |
387 | void gtk_text_view_set_top_margin (GtkTextView *text_view, |
388 | int top_margin); |
389 | GDK_AVAILABLE_IN_ALL |
390 | int gtk_text_view_get_top_margin (GtkTextView *text_view); |
391 | GDK_AVAILABLE_IN_ALL |
392 | void gtk_text_view_set_bottom_margin (GtkTextView *text_view, |
393 | int bottom_margin); |
394 | GDK_AVAILABLE_IN_ALL |
395 | int gtk_text_view_get_bottom_margin (GtkTextView *text_view); |
396 | GDK_AVAILABLE_IN_ALL |
397 | void gtk_text_view_set_indent (GtkTextView *text_view, |
398 | int indent); |
399 | GDK_AVAILABLE_IN_ALL |
400 | int gtk_text_view_get_indent (GtkTextView *text_view); |
401 | GDK_AVAILABLE_IN_ALL |
402 | void gtk_text_view_set_tabs (GtkTextView *text_view, |
403 | PangoTabArray *tabs); |
404 | GDK_AVAILABLE_IN_ALL |
405 | PangoTabArray* gtk_text_view_get_tabs (GtkTextView *text_view); |
406 | |
407 | GDK_AVAILABLE_IN_ALL |
408 | void gtk_text_view_set_input_purpose (GtkTextView *text_view, |
409 | GtkInputPurpose purpose); |
410 | GDK_AVAILABLE_IN_ALL |
411 | GtkInputPurpose gtk_text_view_get_input_purpose (GtkTextView *text_view); |
412 | |
413 | GDK_AVAILABLE_IN_ALL |
414 | void gtk_text_view_set_input_hints (GtkTextView *text_view, |
415 | GtkInputHints hints); |
416 | GDK_AVAILABLE_IN_ALL |
417 | GtkInputHints gtk_text_view_get_input_hints (GtkTextView *text_view); |
418 | |
419 | GDK_AVAILABLE_IN_ALL |
420 | void gtk_text_view_set_monospace (GtkTextView *text_view, |
421 | gboolean monospace); |
422 | GDK_AVAILABLE_IN_ALL |
423 | gboolean gtk_text_view_get_monospace (GtkTextView *text_view); |
424 | |
425 | GDK_AVAILABLE_IN_ALL |
426 | void (GtkTextView *text_view, |
427 | GMenuModel *model); |
428 | GDK_AVAILABLE_IN_ALL |
429 | GMenuModel * (GtkTextView *text_view); |
430 | GDK_AVAILABLE_IN_ALL |
431 | PangoContext *gtk_text_view_get_rtl_context (GtkTextView *text_view); |
432 | GDK_AVAILABLE_IN_ALL |
433 | PangoContext *gtk_text_view_get_ltr_context (GtkTextView *text_view); |
434 | |
435 | G_END_DECLS |
436 | |
437 | #endif /* __GTK_TEXT_VIEW_H__ */ |
438 | |