2 * @defgroup CopyPaste CopyPaste
4 * Implements the following functionality
5 * a. select, copy/cut and paste
8 * in order to share data across application windows.
10 * Contains functions to select text or a portion of data,
11 * send it to a buffer, and paste the data into a target.
13 * elm_cnp provides a generic copy and paste facility based on its windowing system.
14 * It is not necessary to know the details of each windowing system,
15 * but some terms and behavior are common.
16 * Currently the X11 window system is widely used, and only X11 functionality is implemented.
18 * In X11R6 window system, CopyPaste works like a peer-to-peer communication.
19 * Copying is an operation on an object in an X server.
20 * X11 calls those objects 'selections' which have names.
21 * Generally, two selection types are needed for copy and paste:
22 * The Primary selection and the Clipboard selection.
23 * Primary selection is for selecting text (that means highlighted text).
24 * Clipboard selection is for explicit copying behavior
25 * (such as ctrl+c, or 'copy' in a menu).
26 * Thus, in applications most cases only use the clipboard selection.
27 * As stated before, taking ownership of a selection doesn't move any actual data.
28 * Copying and Pasting is described as follows:
29 * 1. Copy text in Program A : Program A takes ownership of the selection
30 * 2. Paste text in Program B : Program B notes that Program A owns the selection
31 * 3. Program B asks A for the text
32 * 4. Program A responds and sends the text to program B
33 * 5. Program B pastes the response
34 * More information is on
35 * - http://www.jwz.org/doc/x-cut-and-paste.html
36 * - X11R6 Inter-Client Communication Conventions Manual, section 2
38 * TODO: add for other window system.
44 * Defines the types of selection property names.
45 * @see http://www.x.org/docs/X11/xlib.pdf
50 ELM_SEL_TYPE_PRIMARY, /**< Primary text selection (highlighted or selected text) */
51 ELM_SEL_TYPE_SECONDARY, /**< Used when primary selection is in use */
52 ELM_SEL_TYPE_XDND, /**< Drag 'n' Drop */
53 ELM_SEL_TYPE_CLIPBOARD, /**< Clipboard selection (ctrl+C) */
57 * Defines the types of content.
61 /** For matching every possible atom */
62 ELM_SEL_FORMAT_TARGETS = -1,
63 /** Content is from outside of Elementary */
64 ELM_SEL_FORMAT_NONE = 0x0,
65 /** Plain unformatted text: Used for things that don't want rich markup */
66 ELM_SEL_FORMAT_TEXT = 0x01,
67 /** Edje textblock markup, including inline images */
68 ELM_SEL_FORMAT_MARKUP = 0x02,
70 ELM_SEL_FORMAT_IMAGE = 0x04,
72 ELM_SEL_FORMAT_VCARD = 0x08,
73 /** Raw HTML-like data (eg. webkit) */
74 ELM_SEL_FORMAT_HTML = 0x10,
78 * Structure holding the info about selected data.
80 struct _Elm_Selection_Data
83 Elm_Sel_Format format;
87 typedef struct _Elm_Selection_Data Elm_Selection_Data;
90 * Callback invoked in when the selected data is 'dropped' at its destination.
92 * @param data Application specific data
93 * @param obj The evas object where selected data is 'dropped'.
94 * @param ev struct holding information about selected data
95 * FIXME: this should probably be a smart callback
97 typedef Eina_Bool (*Elm_Drop_Cb)(void *data, Evas_Object *obj, Elm_Selection_Data *ev);
101 * @brief Set copy data for a widget.
103 * Set copy data and take ownership of selection. Format is used for specifying the selection type,
104 * and this is used during pasting.
106 * @param selection Selection type for copying and pasting
107 * @param obj The source widget pointer
108 * @param format Selection format
109 * @param buf The data selected
110 * @param buflen The size of @p buf
111 * @return If EINA_TRUE, setting data was successful.
116 EAPI Eina_Bool elm_cnp_selection_set(Evas_Object *obj, Elm_Sel_Type selection,
117 Elm_Sel_Format format,
118 const void *buf, size_t buflen);
121 * @brief Retrieve data from a widget that has a selection.
123 * Gets the current selection data from a widget.
124 * The widget input here will usually be elm_entry,
125 * in which case @p datacb and @p udata can be NULL.
126 * If a different widget is passed, @p datacb and @p udata are used for retrieving data.
128 * @see also elm_cnp_selection_set()
130 * @param selection Selection type for copying and pasting
131 * @param format Selection format
132 * @param obj The source widget
133 * @param datacb The user data callback if the target widget isn't elm_entry
134 * @param udata The user data pointer for @p datacb
135 * @return If EINA_TRUE, getting selection data was successful.
139 EAPI Eina_Bool elm_cnp_selection_get(Evas_Object *obj, Elm_Sel_Type selection,
140 Elm_Sel_Format format,
141 Elm_Drop_Cb datacb, void *udata);
144 * @brief Clear the selection data of a widget.
146 * Clear all data from the selection which is owned by a widget.
148 * @see also elm_cnp_selection_set()
150 * @param obj The source widget
151 * @param selection Selection type for copying and pasting
152 * @return If EINA_TRUE, clearing data was successful.
157 EAPI Eina_Bool elm_object_cnp_selection_clear(Evas_Object *obj,
158 Elm_Sel_Type selection);