Exemple #1
0
void
clip_mch_set_selection(VimClipboard *cbd)
{
    int type;
    long_u  len;
    char_u *text_clip, vim_clip[2], *str = NULL;
    PhClipHeader clip_header[2];

    /* Prevent recursion from clip_get_selection() */
    if (cbd->owned == TRUE)
	return;

    cbd->owned = TRUE;
    clip_get_selection(cbd);
    cbd->owned = FALSE;

    type = clip_convert_selection(&str, &len, cbd);
    if (type >= 0)
    {
	text_clip = lalloc(len + 1, TRUE); /* Normal text */

	if (text_clip && vim_clip)
	{
	    memset(clip_header, 0, sizeof(clip_header));

	    STRNCPY(clip_header[0].type, CLIP_TYPE_VIM, 8);
	    clip_header[0].length = sizeof(vim_clip);
	    clip_header[0].data   = vim_clip;

	    STRNCPY(clip_header[1].type, CLIP_TYPE_TEXT, 8);
	    clip_header[1].length = len + 1;
	    clip_header[1].data   = text_clip;

	    switch(type)
	    {
		default: /* fallthrough to MLINE */
		case MLINE:	*vim_clip = 'L'; break;
		case MCHAR:	*vim_clip = 'C'; break;
		case MBLOCK:	*vim_clip = 'B'; break;
	    }

	    vim_strncpy(text_clip, str, len);

	    vim_clip[ 1 ] = NUL;

	    PhClipboardCopy(PhInputGroup(NULL), 2, clip_header);
	}
	vim_free(text_clip);
    }
    vim_free(str);
}
Exemple #2
0
/**
 * Send the current selection to the clipboard
 */
void
clip_mch_set_selection(VimClipboard *cbd)
{
	int type;
	long size;
	char_u *str = NULL;

	if (!cbd->owned) {
		return;
	}

	cbd->owned = TRUE;
	clip_get_selection(cbd);
	cbd->owned = FALSE;

	type = clip_convert_selection(&str, (long_u *)&size, cbd);
	if (type >= 0) {
		QClipboard *clip = QApplication::clipboard();
		clip->setText( VimWrapper::convertFrom(str, size), (QClipboard::Mode)cbd->clipboardMode);
	}

	vim_free(str);
}
Exemple #3
0
void android_clip_set_selection (VimClipboard *cbd)
{
    long_u  len;
    char_u *str = NULL;

    /* Prevent recursion from clip_get_selection() */
    if (cbd->owned == TRUE)
        return;

    cbd->owned = TRUE;
    clip_get_selection(cbd);
    cbd->owned = FALSE;

    int type = clip_convert_selection(&str, &len, cbd);

    if (type >= 0 && str)
    {
        str[len] = '\0';
        jstring result = global_env->NewStringUTF((const char*)str);
        global_env->CallStaticVoidMethod(class_Exec, method_Exec_setClipText, result);
    }

    vim_free(str);
}