示例#1
0
文件: zle_misc.c 项目: MPOWER4RU/zsh
int
bracketedpaste(char **args)
{
    char *pbuf = bracketedstring();

    if (*args) {
	setsparam(*args, pbuf);
    } else {
	int n;
	ZLE_STRING_T wpaste;
	wpaste = stringaszleline((zmult == 1) ? pbuf :
	    quotestring(pbuf, NULL, QT_SINGLE_OPTIONAL), 0, &n, NULL, NULL);
	cuttext(wpaste, n, CUT_REPLACE);
	if (!(zmod.flags & MOD_VIBUF)) {
	    kct = -1;
	    kctbuf = &cutbuf;
	    zmult = 1;
	    if (region_active)
		killregion(zlenoargs);
	    yankcs = yankb = zlecs;
	    doinsert(wpaste, n);
	    yanke = zlecs;
	}
	free(pbuf); free(wpaste);
    }
    return 0;
}
示例#2
0
文件: paragraph.c 项目: hboetes/mg
/* ARGSUSED */
int
killpara(int f, int n)
{
    int	lineno, status;

    if (n == 0)
        return (TRUE);

    if (findpara() == FALSE)
        return (TRUE);

    /* go to the beginning of the paragraph */
    (void)gotobop(FFRAND, 1);

    /* take a note of the line number for after deletions and set mark */
    lineno = curwp->w_dotline;
    curwp->w_markp = curwp->w_dotp;
    curwp->w_marko = curwp->w_doto;

    (void)gotoeop(FFRAND, n);

    if ((status = killregion(FFRAND, 1)) != TRUE)
        return (status);

    curwp->w_dotline = lineno;
    return (TRUE);
}
示例#3
0
PASCAL NEAR delfold(f, n)
{
	BUFFER *bp;		 /* buffer having fold deleted */
	WINDOW *wp;		 /* windows to fix up pointers in as well */
	LINE   *lp;		 /* lines being deleted */

	/* find the proper buffer */
	bp = curwp->w_bufp;		

	if (curwp->w_dotp->l_type == LSOFOLD) {

		/* set all line types to normal */
		lp = curwp->w_dotp;
		while (lp != curwp->w_dotp->l_foldp->l_fp) {
			lp->l_type = LNORMAL; 
			lp = lp->l_fp;
		}
		curwp->w_doto = 0;
		curwp->w_markp[0] = curwp->w_dotp->l_foldp->l_fp;
		curwp->w_marko[0] = 0;
		killregion(FALSE, 0);
		mlwrite(TEXT229);
		/* "[Fold Deleted]" */
		return(TRUE);
	}
	else {
		mlwrite(TEXT225);
		/* "%% Not a fold line" */
		return(FALSE);
	}
}
示例#4
0
/*
 * Delete n paragraphs starting with the current one.
 */
int
killpara (int f, int n, int k)
{
  register int status;		/* returned status of functions */

  while (n--)
    {				/* for each paragraph to delete */

      /* mark out the end and begining of the para to delete */
      gotoeop (FALSE, 1, KRANDOM);

      /* set the mark here */
      curwp->w_mark = curwp->w_dot;

      /* go to the begining of the paragraph */
      gotobop (FALSE, 1, KRANDOM);
      curwp->w_dot.o = 0;	/* force us to the begining of line */

      /* and delete it */
      if ((status = killregion (FALSE, 1, KRANDOM)) != TRUE)
	return (status);

      /* and clean up the 2 extra lines */
      ldelete (1, TRUE);
    }
  return (TRUE);
}
示例#5
0
/* ARGSUSED */
int
killpara(int f, int n)
{
	int	status;		/* returned status of functions */

	/* for each paragraph to delete */
	while (n--) {

		/* mark out the end and beginning of the para to delete */
		(void)gotoeop(FFRAND, 1);

		/* set the mark here */
		curwp->w_markp = curwp->w_dotp;
		curwp->w_marko = curwp->w_doto;

		/* go to the beginning of the paragraph */
		(void)gotobop(FFRAND, 1);

		/* force us to the beginning of line */
		curwp->w_doto = 0;

		/* and delete it */
		if ((status = killregion(FFRAND, 1)) != TRUE)
			return (status);

		/* and clean up the 2 extra lines */
		(void)ldelete((RSIZE) 1, KFORW);
	}
	return (TRUE);
}
示例#6
0
文件: paragraph.c 项目: jcvernaleo/mg
/* ARGSUSED */
int
killpara(int f, int n)
{
	int	status, end = FALSE;	/* returned status of functions */

	/* for each paragraph to delete */
	while (n--) {

		/* mark out the end and beginning of the para to delete */
		if (!gotoeop(FFRAND, 1))
			end = TRUE;

		/* set the mark here */
		curwp->w_markp = curwp->w_dotp;
		curwp->w_marko = curwp->w_doto;

		/* go to the beginning of the paragraph */
		(void)gotobop(FFRAND, 1);

		/* force us to the beginning of line */
		curwp->w_doto = 0;

		/* and delete it */
		if ((status = killregion(FFRAND, 1)) != TRUE)
			return (status);

		if (end)
			return (TRUE);
	}
	return (TRUE);
}
示例#7
0
static int
chgreg(void)
{
    if (regionshape == rgn_RECTANGLE) {
	return stringrect();
    } else {
	killregion();
	if (regionshape == rgn_FULLLINE && !is_empty_buf(curbp)) {
	    if (backline(FALSE, 1) == TRUE)
		/* backline returns FALSE at top of buf */
		return opendown(TRUE, 1);
	    else
		return openup(TRUE, 1);
	}
	return ins();
    }
}
示例#8
0
文件: paragraph.c 项目: troglobit/mg
/* ARGSUSED */
int
transposepara(int f, int n)
{
	int	i = 0, status;
	char	flg;

	if (n == 0)
		return (TRUE);

	undo_boundary_enable(FFRAND, 0);

	/* find a paragraph, set mark, then goto the end */
	gotobop(FFRAND, 1);
	curwp->w_markp = curwp->w_dotp;
	curwp->w_marko = curwp->w_doto;
	(void)gotoeop(FFRAND, 1);

	/* take a note of buffer flags - we may need them */
	flg = curbp->b_flag;	

	/* clean out kill buffer then kill region */
	kdelete();
	if ((status = killregion(FFRAND, 1)) != TRUE)
		return (status);

	/* 
	 * Now step through n paragraphs. If we reach the end of buffer,
	 * stop and paste the killed region back, then display a message.
	 */
	if (do_gotoeop(FFRAND, n, &i) == FALSE) {
		ewprintf("Cannot transpose paragraph, end of buffer reached.");
		(void)gotobop(FFRAND, i);
		(void)yank(FFRAND, 1);
		curbp->b_flag = flg;	
		return (FALSE);
	}
	(void)yank(FFRAND, 1);

	undo_boundary_enable(FFRAND, 1);

	return (TRUE);
}
示例#9
0
文件: zle_misc.c 项目: MPOWER4RU/zsh
int
putreplaceselection(UNUSED(char **args))
{
    int n = zmult;
    struct cutbuffer prevbuf;
    Cutbuffer putbuf;
    int clear = 0;
    int pos = 2;

    startvichange(-1);
    if (n < 0 || zmod.flags & MOD_NULL)
	return 1;
    putbuf = (zmod.flags & MOD_VIBUF) ? &vibuf[zmod.vibuf] : &cutbuf;
    if (!putbuf->buf)
	return 1;
    memcpy(&prevbuf, putbuf, sizeof(prevbuf));

    /* if "9 was specified, prevent killregion from freeing it */
    if (zmod.vibuf == 35) {
	putbuf->buf = 0;
	clear = 1;
    }

    zmod.flags = 0; /* flags apply to paste not kill */
    if (region_active == 2 && prevbuf.flags & CUTBUFFER_LINE) {
	int a, b;
	regionlines(&a, &b);
	pos = (b == zlell);
    }
    killregion(zlenoargs);

    pastebuf(&prevbuf, n, pos);
    if (clear)
	free(prevbuf.buf);
    return 0;
}
示例#10
0
文件: zle_vi.c 项目: jackleaks/zsh
int
visubstitute(UNUSED(char **args))
{
    int n = zmult;

    startvichange(1);
    if (n < 0)
	return 1;
    /* it is an error to be on the end of line */
    if (zlecs == zlell || zleline[zlecs] == '\n')
	return 1;
    if (region_active) {
	killregion(zlenoargs);
    } else {
	/* Put argument into the acceptable range -- it is not an error to  *
	* specify a greater count than the number of available characters. */
	if (n > findeol() - zlecs)
	    n = findeol() - zlecs;
	/* do the substitution */
	forekill(n, CUT_RAW);
    }
    startvitext(1);
    return 0;
}