changeset 888:cd6ff038e38b

Implemented dw_mle_search on Mac.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 07 Apr 2011 19:17:52 +0000
parents 29d8ae25a78c
children 238ca78e71a7
files mac/dw.m
diffstat 1 files changed, 19 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Thu Apr 07 18:44:07 2011 +0000
+++ b/mac/dw.m	Thu Apr 07 19:17:52 2011 +0000
@@ -4141,8 +4141,25 @@
  */
 int API dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
 {
-    NSLog(@"dw_mle_search() unimplemented\n");
-    return 0;
+    NSScrollView *sv = handle;
+    DWMLE *mle = [sv documentView];
+    NSTextStorage *ts = [mle textStorage];
+    NSMutableString *ms = [ts mutableString];
+    NSString *searchForMe = [NSString stringWithUTF8String:text];
+    NSRange searchRange = NSMakeRange(point, [ms length] - point);
+    NSRange range = NSMakeRange(NSNotFound, 0);
+    NSUInteger options = flags ? flags : NSCaseInsensitiveSearch;
+    
+    if(ms)
+    {
+        range = [ms rangeOfString:searchForMe options:options range:searchRange];
+    }
+    
+    if(range.location != NSNotFound) 
+    {
+        return -1;
+    }
+    return (int)range.location;
 }
 
 /*