Multiline Text Editing Widget (3)

From: http://www.bravegnu.org/gtktext/x234.html

3. Cut, Copy and Paste

In this section you will learn how to do common clipboard related activities like cut, copy and paste. First, you will have to get hold of a clipboard object using

GtkClipboard *gtk_clipboard_get( GdkAtom selection );
Usually, a value of GDK_NONE is passed to selection, which gives the default clipboard. A value of GDK_SELECTION_PRIMARY identifies the primary X selection.

Selected text can be then copied to the clipboard using

void gtk_text_buffer_copy_clipboard( GtkTextBuffer *buffer,
                                     GtkClipboard *clipboard );
The clipboard is a clipboard object obtained from gtk_clipboard_get.

Selected text can be cut to the clipboard using

void gtk_text_buffer_cut_clipboard( GtkTextBuffer *buffer,
                                    GtkClipboard *clipboard, 
                                    gboolean default_editable );
For portions of the selected text that do not have the editable tag applied, the edit-ability is assumed from default_editable.

Text can be pasted from the clipboard using

void gtk_text_buffer_paste_clipboard( GtkTextBuffer *buffer,
                                      GtkClipboard *clipboard,
                                      GtkTextIter *override_location,
                                      gboolean default_editable );
If override_location is not NULL, text is inserted at the iter specified by override_location. Else, text is inserted at the current cursor location.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章