Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/efaca1c1fa7238aa0edc46a0e3e0eda61efda682
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/efaca1c1fa7238aa0edc46a0e3e0eda61efda682
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/efaca1c1fa7238aa0edc46a0e3e0eda61efda682

The branch, master has been updated
       via  efaca1c1fa7238aa0edc46a0e3e0eda61efda682 (commit)
      from  1d827d2cf32fc6bcc3d2b39362ec67309c097f19 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commitdiff/efaca1c1fa7238aa0edc46a0e3e0eda61efda682
commit efaca1c1fa7238aa0edc46a0e3e0eda61efda682
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    Add core function for copy to clipboard, so we don't need to expose 
render/box.h internals to front ends.

diff --git a/desktop/selection.c b/desktop/selection.c
index a3d93ef..6679be6 100644
--- a/desktop/selection.c
+++ b/desktop/selection.c
@@ -730,6 +730,55 @@ void selection_redraw(struct selection *s, unsigned 
start_idx, unsigned end_idx)
 
 
 /**
+ * Selection traversal routine for appending text to the current contents
+ * of the clipboard.
+ *
+ * \param  text                pointer to text being added, or NULL for newline
+ * \param  length      length of text to be appended (bytes)
+ * \param  box         pointer to text box, or NULL if from textplain
+ * \param  handle      unused handle, we don't need one
+ * \param  whitespace_text    whitespace to place before text for formatting
+ *                            may be NULL
+ * \param  whitespace_length  length of whitespace_text
+ * \return true iff successful and traversal should continue
+ */
+
+static bool selection_copy_handler(const char *text, size_t length,
+               struct box *box, void *handle, const char *whitespace_text,
+               size_t whitespace_length)
+{
+       bool add_space = box != NULL ? box->space != 0 : false;
+
+       /* add any whitespace which precedes the text from this box */
+       if (whitespace_text != NULL && whitespace_length > 0) {
+               if (!gui_add_to_clipboard(whitespace_text,
+                               whitespace_length, false)) {
+                       return false;
+               }
+       }
+
+       /* add the text from this box */
+       if (!gui_add_to_clipboard(text, length, add_space))
+               return false;
+
+       return true;
+}
+
+
+/**
+ * Copy the selected contents to the clipboard
+ *
+ * \param s  selection
+ * \return true iff successful, ie. cut operation can proceed without losing 
data
+ */
+
+bool selection_copy_to_clipboard(struct selection *s)
+{
+       return selection_traverse(s, selection_copy_handler, NULL);
+}
+
+
+/**
  * Clears the current selection, optionally causing the screen to be updated.
  *
  * \param  s       selection object
diff --git a/desktop/selection.h b/desktop/selection.h
index 69d145c..16b002a 100644
--- a/desktop/selection.h
+++ b/desktop/selection.h
@@ -95,6 +95,8 @@ bool selection_click(struct selection *s, browser_mouse_state 
mouse,
 void selection_track(struct selection *s, browser_mouse_state mouse,
                unsigned idx);
 
+bool selection_copy_to_clipboard(struct selection *s);
+
 /** Handles completion of a drag operation */
 /* void selection_drag_end(struct selection *s); */
 #define selection_drag_end(s) ((s)->drag_state = DRAG_NONE)


-----------------------------------------------------------------------

Summary of changes:
 desktop/selection.c |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 desktop/selection.h |    2 ++
 2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/desktop/selection.c b/desktop/selection.c
index a3d93ef..6679be6 100644
--- a/desktop/selection.c
+++ b/desktop/selection.c
@@ -730,6 +730,55 @@ void selection_redraw(struct selection *s, unsigned 
start_idx, unsigned end_idx)
 
 
 /**
+ * Selection traversal routine for appending text to the current contents
+ * of the clipboard.
+ *
+ * \param  text                pointer to text being added, or NULL for newline
+ * \param  length      length of text to be appended (bytes)
+ * \param  box         pointer to text box, or NULL if from textplain
+ * \param  handle      unused handle, we don't need one
+ * \param  whitespace_text    whitespace to place before text for formatting
+ *                            may be NULL
+ * \param  whitespace_length  length of whitespace_text
+ * \return true iff successful and traversal should continue
+ */
+
+static bool selection_copy_handler(const char *text, size_t length,
+               struct box *box, void *handle, const char *whitespace_text,
+               size_t whitespace_length)
+{
+       bool add_space = box != NULL ? box->space != 0 : false;
+
+       /* add any whitespace which precedes the text from this box */
+       if (whitespace_text != NULL && whitespace_length > 0) {
+               if (!gui_add_to_clipboard(whitespace_text,
+                               whitespace_length, false)) {
+                       return false;
+               }
+       }
+
+       /* add the text from this box */
+       if (!gui_add_to_clipboard(text, length, add_space))
+               return false;
+
+       return true;
+}
+
+
+/**
+ * Copy the selected contents to the clipboard
+ *
+ * \param s  selection
+ * \return true iff successful, ie. cut operation can proceed without losing 
data
+ */
+
+bool selection_copy_to_clipboard(struct selection *s)
+{
+       return selection_traverse(s, selection_copy_handler, NULL);
+}
+
+
+/**
  * Clears the current selection, optionally causing the screen to be updated.
  *
  * \param  s       selection object
diff --git a/desktop/selection.h b/desktop/selection.h
index 69d145c..16b002a 100644
--- a/desktop/selection.h
+++ b/desktop/selection.h
@@ -95,6 +95,8 @@ bool selection_click(struct selection *s, browser_mouse_state 
mouse,
 void selection_track(struct selection *s, browser_mouse_state mouse,
                unsigned idx);
 
+bool selection_copy_to_clipboard(struct selection *s);
+
 /** Handles completion of a drag operation */
 /* void selection_drag_end(struct selection *s); */
 #define selection_drag_end(s) ((s)->drag_state = DRAG_NONE)


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to