示例#1
0
文件: zle_vi.c 项目: Osse/zsh
int
vibackwarddeletechar(char **args)
{
    int n = zmult;

    if (invicmdmode())
	startvichange(-1);
    /* handle negative argument */
    if (n < 0) {
	int ret;
	zmult = -n;
	ret = videletechar(args);
	zmult = n;
	return ret;
    }
    /* It is an error to be at the beginning of the line, or (in *
     * insert mode) to delete past the beginning of insertion.   */
    if ((!invicmdmode() && zlecs - n < viinsbegin) || zlecs == findbol()) {
	return 1;
    }
    /* Put argument into the acceptable range -- it is not an error to  *
     * specify a greater count than the number of available characters. */
    /* HERE: we should do the test properly with DECPOS(). */
    if (n > zlecs - findbol()) {
	n = zlecs - findbol();
	/* do the deletion */
	backkill(n, CUT_FRONT|CUT_RAW);
    } else
	backkill(n, CUT_FRONT);
    return 0;
}
示例#2
0
文件: zle_misc.c 项目: MPOWER4RU/zsh
int
killregion(UNUSED(char **args))
{
    if (mark > zlell)
	mark = zlell;
    if (region_active == 2) {
	int a, b;
	regionlines(&a, &b);
	zlecs = a;
	region_active = 0;
	cut(zlecs, b - zlecs, CUT_RAW);
	shiftchars(zlecs, b - zlecs);
	if (zlell) {
	    if (zlecs == zlell)
		DECCS();
	    foredel(1, 0);
	    vifirstnonblank(zlenoargs);
	}
    } else if (mark > zlecs) {
	if (invicmdmode())
	    INCPOS(mark);
	forekill(mark - zlecs, CUT_RAW);
    } else {
	if (invicmdmode())
	    INCCS();
	backkill(zlecs - mark, CUT_FRONT|CUT_RAW);
    }
    return 0;
}
示例#3
0
文件: zle_vi.c 项目: Osse/zsh
int
vireplacechars(UNUSED(char **args))
{
    ZLE_INT_T ch;
    int n = zmult, fail = 0, newchars = 0;

    if (n > 0) {
	int pos = zlecs;
	while (n-- > 0) {
	    if (pos == zlell || zleline[pos] == ZWC('\n')) {
		fail = 1;
		break;
	    }
	    newchars++;
	    INCPOS(pos);
	}
	n = pos - zlecs;
    }
    startvichange(1);
    /* check argument range */
    if (n < 1 || fail) {
	if(vichgrepeat)
	    vigetkey();
	if(vichgflag) {
	    free(vichgbuf);
	    vichgbuf = NULL;
	    vichgflag = 0;
	}
	return 1;
    }
    /* get key */
    if((ch = vigetkey()) == ZLEEOF) {
	vichgflag = 0;
	return 1;
    }
    /* do change */
    if (ch == ZWC('\r') || ch == ZWC('\n')) {
	/* <return> handled specially */
	zlecs += n - 1;
	backkill(n - 1, CUT_RAW);
	zleline[zlecs++] = '\n';
    } else {
	/*
	 * Make sure we delete displayed characters, including
	 * attach combining characters. n includes this as a raw
	 * buffer offset.
	 * Use shiftchars so as not to adjust the cursor position;
	 * we are overwriting anything that remains directly.
	 */
	if (n > newchars)
	    shiftchars(zlecs, n - newchars);
	else if (n < newchars)
	    spaceinline(newchars - n);
	while (newchars--)
	    zleline[zlecs++] = ch;
	zlecs--;
    }
    vichgflag = 0;
    return 0;
}
示例#4
0
文件: zle_word.c 项目: zsh-users/zsh
int
backwardkillword(char **args)
{
    int x = zlecs;
    int n = zmult;

    if (n < 0) {
	int ret;
	zmult = -n;
	ret = killword(args);
	zmult = n;
	return ret;
    }
    while (n--) {
	while (x) {
	    int pos = x;
	    DECPOS(pos);
	    if (ZC_iword(zleline[pos]))
		break;
	    x = pos;
	}
	while (x) {
	    int pos = x;
	    DECPOS(pos);
	    if (!ZC_iword(zleline[pos]))
		break;
	    x = pos;
	}
    }
    backkill(zlecs - x, CUT_FRONT|CUT_RAW);
    return 0;
}
示例#5
0
文件: zle_word.c 项目: zsh-users/zsh
int
vibackwardkillword(UNUSED(char **args))
{
    int x = zlecs, lim = (viinsbegin > findbol()) ? viinsbegin : findbol();
    int n = zmult;

    if (n < 0)
	return 1;
/* this taken from "vibackwardword" */
    while (n--) {
	while (x > lim) {
	    int pos = x;
	    DECPOS(pos);
	    if (!ZC_iblank(zleline[pos]))
		break;
	    x = pos;
	}
	if (x > lim) {
	    int cc;
	    int pos = x;
	    DECPOS(pos);
	    cc = wordclass(zleline[pos]);
	    for (;;) {
		x = pos;
		if (x <= lim)
		    break;
		DECPOS(pos);
		if (wordclass(zleline[pos]) != cc)
		    break;
	    }
	}
    }
    backkill(zlecs - x, CUT_FRONT|CUT_RAW);
    return 0;
}
示例#6
0
void
vireplacechars(void)
{
    int ch;

    startvichange(1);
    /* get key */
    if((ch = vigetkey()) == -1) {
	vichgflag = 0;
	feep();
	return;
    }
    /* check argument range */
    if (zmult < 0 || zmult + cs > findeol()) {
	vichgflag = 0;
	feep();
	return;
    }
    /* do change */
    if (ch == '\r' || ch == '\n') {
	/* <return> handled specially */
	cs += zmult - 1;
	backkill(zmult - 1, 0);
	line[cs++] = '\n';
    } else {
	while (zmult--)
	    line[cs++] = ch;
	cs--;
    }
    vichgflag = 0;
}
示例#7
0
void vibackwarddeletechar() /**/
{
	if (mult < 0) { mult = -mult; videletechar(); return; }
	if (mult > cs)
		mult = cs;
	if (cs-mult < viinsbegin) { feep(); return; }
	backkill(mult,1);
}
示例#8
0
void killregion() /**/
{
	if (mark > ll)
		mark = ll;
	if (mark > cs)
		forekill(mark-cs,0);
	else
		backkill(cs-mark,1);
}
示例#9
0
文件: zle_misc.c 项目: Jaharmi/zsh
int
killregion(UNUSED(char **args))
{
    if (mark > zlell)
	mark = zlell;
    if (mark > zlecs)
	forekill(mark - zlecs, CUT_RAW);
    else
	backkill(zlecs - mark, CUT_FRONT|CUT_RAW);
    return 0;
}
示例#10
0
void killline() /**/
{
int i = 0;

	if (mult < 0) { mult = -mult; backwardkillline(); return; }
	while (mult--) {
		if (line[cs] == '\n')
			cs++,i++;
		while (cs != ll && line[cs] != '\n') cs++,i++;
	}
	backkill(i,0);
}
示例#11
0
void videletechar() /**/
{
	if (mult < 0) { mult = -mult; vibackwarddeletechar(); return; }
	if (c == 4 && !ll) {
		eofsent = 1;
		return;
	}
	if (!(cs+mult > ll || line[cs] == '\n')) {
		cs += mult;
		backkill(mult,0);
		if (cs && (cs == ll || line[cs] == '\n')) cs--;
	} else
		feep();
}
示例#12
0
文件: zle_misc.c 项目: MPOWER4RU/zsh
int
killline(char **args)
{
    int i = 0, n = zmult;

    if (n < 0) {
	int ret;
	zmult = -n;
	ret = backwardkillline(args);
	zmult = n;
	return ret;
    }
    while (n--) {
	if (zleline[zlecs] == ZWC('\n'))
	    zlecs++, i++;
	else
	    while (zlecs != zlell && zleline[zlecs] != ZWC('\n'))
		zlecs++, i++;
    }
    backkill(i, CUT_RAW);
    clearlist = 1;
    return 0;
}
示例#13
0
void
vibackwarddeletechar(void)
{
    if (bindtab == altbindtab)
	startvichange(-1);
    /* handle negative argument */
    if (zmult < 0) {
	zmult = -zmult;
	videletechar();
	return;
    }
    /* It is an error to be at the beginning of the line, or (in *
     * insert mode) to delete past the beginning of insertion.   */
    if ((bindtab != altbindtab && cs - zmult < viinsbegin) || cs == findbol()) {
	feep();
	return;
    }
    /* Put argument into the acceptable range -- it is not an error to  *
     * specify a greater count than the number of available characters. */
    if (zmult > cs - findbol())
	zmult = cs - findbol();
    /* do the deletion */
    backkill(zmult, 1);
}