Vim search patterns are put on the OS X Find Pasteboard

By adding search patterns to the Find Pasteboard other apps can access
Vim search patterns.  For example, if the user types
    /neat<CR>
in MacVim and then switches to Safari and hits <D-g>, then Safari will
search for the string "neat".
This commit is contained in:
Bjorn Winckler
2008-02-09 22:24:25 +01:00
parent c0447dd6ed
commit 6269aa03e0
3 changed files with 30 additions and 0 deletions
+25
View File
@@ -1516,6 +1516,31 @@ gui_macvim_update_modified_flag()
[[MMBackend sharedInstance] updateModifiedFlag];
}
/*
* Add search pattern 'pat' to the OS X find pasteboard. This allows other
* apps access the last pattern searched for (hitting <D-g> in another app will
* initiate a search for the same pattern).
*/
void
gui_macvim_add_to_find_pboard(char_u *pat)
{
if (!pat) return;
#ifdef FEAT_MBYTE
pat = CONVERT_TO_UTF8(pat);
#endif
NSString *s = [NSString stringWithUTF8String:(char*)pat];
#ifdef FEAT_MBYTE
CONVERT_TO_UTF8_FREE(pat);
#endif
if (!s) return;
NSPasteboard *pb = [NSPasteboard pasteboardWithName:NSFindPboard];
[pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil];
[pb setString:s forType:NSStringPboardType];
}
+4
View File
@@ -6111,6 +6111,10 @@ normal_search(cap, dir, pat, opt)
cap->oap->use_reg_one = TRUE;
curwin->w_set_curswant = TRUE;
#if FEAT_GUI_MACVIM
gui_macvim_add_to_find_pboard(pat);
#endif
i = do_search(cap->oap, dir, pat, cap->count1,
opt | SEARCH_OPT | SEARCH_ECHO | SEARCH_MSG, NULL);
if (i == 0)
+1
View File
@@ -194,6 +194,7 @@ void gui_mch_enter_fullscreen(void);
void gui_mch_leave_fullscreen(void);
void gui_macvim_update_modified_flag();
void gui_macvim_add_to_find_pboard(char_u *pat);
OSErr odb_buffer_close(buf_T *buf);
OSErr odb_post_buffer_write(buf_T *buf);