1 #ifndef GTK_TEXT_VIEW_H
2 #define GTK_TEXT_VIEW_H
4 #include <gtk/gtkcontainer.h>
5 #include <gtk/gtkimcontext.h>
6 #include <gtk/gtktextbuffer.h>
10 #endif /* __cplusplus */
13 GTK_TEXT_MOVEMENT_CHAR, /* move by forw/back chars */
14 GTK_TEXT_MOVEMENT_POSITIONS, /* move by left/right chars */
15 GTK_TEXT_MOVEMENT_WORD, /* move by forward/back words */
16 GTK_TEXT_MOVEMENT_LINE, /* move up/down lines (wrapped lines) */
17 GTK_TEXT_MOVEMENT_PARAGRAPH, /* move up/down paragraphs (newline-ended lines) */
18 GTK_TEXT_MOVEMENT_PARAGRAPH_ENDS, /* move to either end of a paragraph */
19 GTK_TEXT_MOVEMENT_BUFFER_ENDS /* move to ends of the buffer */
20 } GtkTextViewMovementStep;
23 GTK_TEXT_SCROLL_TO_TOP,
24 GTK_TEXT_SCROLL_TO_BOTTOM,
25 GTK_TEXT_SCROLL_PAGE_DOWN,
26 GTK_TEXT_SCROLL_PAGE_UP
27 } GtkTextViewScrollType;
31 GTK_TEXT_DELETE_HALF_WORD, /* delete only the portion of the word to the
32 left/right of cursor if we're in the middle
34 GTK_TEXT_DELETE_WHOLE_WORD,
35 GTK_TEXT_DELETE_HALF_LINE,
36 GTK_TEXT_DELETE_WHOLE_LINE,
37 GTK_TEXT_DELETE_HALF_PARAGRAPH, /* like C-k in Emacs (or its reverse) */
38 GTK_TEXT_DELETE_WHOLE_PARAGRAPH, /* C-k in pico, kill whole line */
39 GTK_TEXT_DELETE_WHITESPACE, /* M-\ in Emacs */
40 GTK_TEXT_DELETE_WHITESPACE_LEAVE_ONE /* M-space in Emacs */
41 } GtkTextViewDeleteType;
43 #define GTK_TYPE_TEXT_VIEW (gtk_text_view_get_type())
44 #define GTK_TEXT_VIEW(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_TEXT_VIEW, GtkTextView))
45 #define GTK_TEXT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
46 #define GTK_IS_TEXT_VIEW(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_TEXT_VIEW))
47 #define GTK_IS_TEXT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_TEXT_VIEW))
48 #define GTK_TEXT_VIEW_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GTK_TYPE_TEXT_VIEW, GtkTextViewClass))
50 typedef struct _GtkTextView GtkTextView;
51 typedef struct _GtkTextViewClass GtkTextViewClass;
54 GtkContainer parent_instance;
56 struct _GtkTextLayout *layout;
57 GtkTextBuffer *buffer;
59 guint selection_drag_handler;
60 guint selection_drag_scan_timeout;
61 gint scrolling_accel_factor;
63 gboolean overwrite_mode;
65 GtkWrapMode wrap_mode; /* Default wrap mode */
67 GdkWindow *bin_window;
68 GtkAdjustment *hadjustment;
69 GtkAdjustment *vadjustment;
71 gint xoffset; /* Offsets between widget coordinates and buffer coordinates */
73 gint width; /* Width and height of the buffer */
76 /* The virtual cursor position is normally the same as the
77 * actual (strong) cursor position, except in two circumstances:
79 * a) When the cursor is moved vertically with the keyboard
80 * b) When the text view is scrolled with the keyboard
82 * In case a), virtual_cursor_x is preserved, but not virtual_cursor_y
83 * In case b), both virtual_cursor_x and virtual_cursor_y are preserved.
85 gint virtual_cursor_x; /* -1 means use actual cursor position */
86 gint virtual_cursor_y; /* -1 means use actual cursor position */
88 GtkTextMark *first_para_mark; /* Mark at the beginning of the first onscreen paragraph */
89 gint first_para_pixels; /* Offset of top of screen in the first onscreen paragraph */
91 GtkTextMark *dnd_mark;
94 guint first_validate_idle; /* Idle to revalidate onscreen portion, runs before resize */
95 guint incremental_validate_idle; /* Idle to revalidate offscreen portions, runs after redraw */
97 GtkIMContext *im_context;
100 struct _GtkTextViewClass {
101 GtkContainerClass parent_class;
103 /* These are all RUN_ACTION signals for keybindings */
105 /* move insertion point */
106 void (* move_insert) (GtkTextView *text_view, GtkTextViewMovementStep step, gint count, gboolean extend_selection);
107 /* move the "anchor" (what Emacs calls the mark) to the cursor position */
108 void (* set_anchor) (GtkTextView *text_view);
110 void (* scroll_text) (GtkTextView *text_view, GtkTextViewScrollType type);
112 void (* delete_text) (GtkTextView *text_view, GtkTextViewDeleteType type, gint count);
114 void (* cut_text) (GtkTextView *text_view);
115 void (* copy_text) (GtkTextView *text_view);
116 void (* paste_text) (GtkTextView *text_view);
118 void (* toggle_overwrite) (GtkTextView *text_view);
119 void (*set_scroll_adjustments) (GtkTextView *text_view,
120 GtkAdjustment *hadjustment,
121 GtkAdjustment *vadjustment);
124 GtkType gtk_text_view_get_type (void);
125 GtkWidget * gtk_text_view_new (void);
126 GtkWidget * gtk_text_view_new_with_buffer (GtkTextBuffer *buffer);
127 void gtk_text_view_set_buffer (GtkTextView *text_view,
128 GtkTextBuffer *buffer);
129 GtkTextBuffer *gtk_text_view_get_buffer (GtkTextView *text_view);
130 void gtk_text_view_get_iter_at_pixel (GtkTextView *text_view,
134 gboolean gtk_text_view_scroll_to_mark (GtkTextView *text_view,
136 gint mark_within_margin);
137 gboolean gtk_text_view_move_mark_onscreen (GtkTextView *text_view,
139 gboolean gtk_text_view_place_cursor_onscreen (GtkTextView *text_view);
141 void gtk_text_view_get_visible_rect (GtkTextView *text_view,
142 GdkRectangle *visible_rect);
143 void gtk_text_view_set_wrap_mode (GtkTextView *text_view,
144 GtkWrapMode wrap_mode);
145 GtkWrapMode gtk_text_view_get_wrap_mode (GtkTextView *text_view);
149 #endif /* __cplusplus */
151 #endif /* GTK_TEXT_VIEW_H */