changeset 37:8215e3fcbb6f

Added #find, #mark, #unmark and #highlight=
author unexist
date Sat, 23 Jan 2010 23:21:52 +0100
parents a672f0142d27
children 3efacab12daa
files subtly/webkit.rb
diffstat 1 files changed, 116 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/subtly/webkit.rb	Fri Jan 22 18:32:18 2010 +0100
+++ b/subtly/webkit.rb	Sat Jan 23 23:21:52 2010 +0100
@@ -32,7 +32,7 @@
     ## uri
     # Load given uri in view
     #
-    # @param  [Pointer, #read]  Webkit view, #GtkWidget
+    # @param [Pointer, #read]  Webkit view, #GtkWidget
     #
     # @return [String] Uri in webkit view
     ##
@@ -44,7 +44,7 @@
     ## uri=
     # Set given uri
     #
-    # @param  [String, #read] uri  Uri to set
+    # @param [String, #read] uri  Uri to set
     ##
     
     def uri=(uri)
@@ -128,6 +128,45 @@
       Subtly::Webkit.ffi_zoom_level(@widget)
     end
 
+    ## find
+    # Find text
+    #
+    # @param [String, #read]  str      String to look for
+    # @param [Bool,   #read]  forward  Whther to find forward
+    ##
+
+    def find(str, forward)
+      Subtly::Webkit.ffi_find_text(@widget, str, false, forward, true)
+    end
+
+    ## mark
+    # Mark text matches
+    #
+    # @param [String, #read]  str  String to look for
+    ##
+
+    def mark(str)
+      Subtly::Webkit.ffi_mark(@widget, str, false, 0)
+    end
+
+    ## unmark
+    # Unmark text matches
+    ##
+
+    def unmark
+      Subtly::Webkit.ffi_unmark(@widget)
+    end
+
+    # highlight=
+    # Enable text highlights
+    #
+    # @param [Bool, #read]  high  Whether to enable highlight
+    ##
+
+    def highlight=(high)
+      Subtly::Webkit.ffi_highlight(@widget, high)
+    end
+
     private
 
     ## ffi_new
@@ -143,7 +182,7 @@
     ## ffi_get_uri
     # Load given uri in view
     #
-    # @param  [Pointer, #read] web_view  A #WebKitWebView
+    # @param [Pointer, #read] web_view  A #WebKitWebView
     #
     # @return [String] Uri in webkit view
     ##
@@ -155,8 +194,8 @@
     ## ffi_set_uri
     # Set given uri in view
     #
-    # @param  [Pointer, #read]  web_view  A #WebKitWebView
-    # @param  [String,  #read] uri        Uri to set
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
+    # @param [String,  #read] uri        Uri to set
     ##
 
     attach_function(:ffi_set_uri,
@@ -166,7 +205,7 @@
     ## ffi_get_title
     # Get title or uri loaded
     #
-    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
     #
     # @return [String] Title of uri
     ##
@@ -178,8 +217,8 @@
     ## ffi_go_steps
     # Go back or forward in history
     #
-    # @param  [Pointer, #read]  web_view  A #WebKitWebView
-    # @param  [Int,     #read]  steps     Steps to go
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
+    # @param [Int,     #read]  steps     Steps to go
     ##
 
     attach_function(:ffi_go_steps,
@@ -189,7 +228,7 @@
     ## ffi_stop
     # Stop page loading
     #
-    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
     ##
 
 
@@ -210,7 +249,7 @@
     ## ffi_reload
     # Reload view bypassing cache
     #
-    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
     ##
 
     attach_function(:ffi_reload,
@@ -220,7 +259,7 @@
     ## ffi_zoom_level
     # Get zoom level
     #
-    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
 
     attach_function(:ffi_zoom_level,
       :webkit_web_view_get_zoom_level, [ :pointer ], :float
@@ -229,7 +268,7 @@
     ## ffi_zoom_in
     # Reload view bypassing cache
     #
-    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
     ##
 
     attach_function(:ffi_zoom_in,
@@ -239,11 +278,75 @@
     ## ffi_zoom_out
     # Reload view bypassing cache
     #
-    # @param  [Pointer, #read]  web_view  A #WebKitWebView
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
     ##
 
     attach_function(:ffi_zoom_out,
       :webkit_web_view_zoom_out, [ :pointer ], :void
     )
+
+    ## ffi_get_target_list
+    # Gets the DND target list
+    #
+    # @param [Pointer, #read]  web_view  A #WebKitWebView
+    ##
+
+    attach_function(:ffi_get_target_list,
+      :webkit_web_view_get_paste_target_list, [ :pointer ], :pointer
+    )
+
+    ## ffi_find_text
+    # Find text
+    #
+    # @param [Pointer, #read]  web_view        A #WebKitWebView
+    # @param [String,  #read]  text            String to look for
+    # @param [Bool,    #read]  case_sensitive  Whether to respect case
+    # @param [Bool,    #read]  forward         Whether to find forward
+    # @param [Bool,    #read]  wrap            Whether to continue at end
+    #
+    # @return [Bool]  Success or not
+    ##
+
+    attach_function(:ffi_find_text,
+      :webkit_web_view_search_text, 
+      [ :pointer, :string, :bool, :bool, :bool ],
+      :bool
+    )
+
+    ## ffi_mark
+    # Mark text matches
+    #
+    # @param [Pointer, #read]  web_view        A #WebKitWebView
+    # @param [String,  #read]  string          String to look for
+    # @param [Bool,    #read]  case_sensitive  Whether to respect case
+    # @param [Fixnum,  #read]  limit           Number of highlights
+    ##
+
+    attach_function(:ffi_mark,
+      :webkit_web_view_mark_text_matches, 
+      [ :pointer, :string, :bool, :uint ], 
+      :uint
+    )
+
+    ## ffi_unmark
+    # Unmark text matches
+    #
+    # @param [Pointer, #read]  web_view   A #WebKitWebView
+    ##
+
+    attach_function(:ffi_unmark,
+      :webkit_web_view_unmark_text_matches, [ :pointer ], :void
+    )
+
+    ## ffi_highlight
+    # Enable text highlights
+    #
+    # @param [Pointer, #read]  web_view   A #WebKitWebView
+    # @param [Bool,    #read]  highlight  Whether to enable highlight
+    ##
+
+    attach_function(:ffi_highlight,
+      :webkit_web_view_set_highlight_text_matches, [ :pointer, :bool ], :void
+    )
   end # }}}
 end