mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
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:
@@ -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];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user