int vikillline(UNUSED(char **args)) { if (viinsbegin > zlecs) return 1; backdel(zlecs - viinsbegin, CUT_RAW); return 0; }
void vikillline(void) { if (viinsbegin > cs) { feep(); return; } backdel(cs - viinsbegin); }
/* * Delete forward. This is real easy, because the basic delete routine does * all of the work. Watches for negative arguments, and does the right thing. * If any argument is present, it kills rather than deletes, to prevent loss * of text if typed with a big argument. Normally bound to "C-D" */ int forwdel(int f, int n) { if (n < 0) return (backdel(f, -n)); if (f != FALSE) { /* Really a kill */ if ((lastflag & CFKILL) == 0) kdelete(); thisflag |= CFKILL; } return (ldelete(n, f)); }
int backwarddeletechar(char **args) { if (zmult < 0) { int ret; zmult = -zmult; ret = deletechar(args); zmult = -zmult; return ret; } backdel(zmult > zlecs ? zlecs : zmult, 0); return 0; }
/* * Add a character, checking for word wrapping. * Check to see if we're past fillcol, and if so, * justify this line. As a last step, justify the line. */ int fillword (int f, int n, int k) { register char c; register int col, i, nce; for (i = col = 0; col <= fillcol; ++i, ++col) { if (i == curwp->w_dot.o) return selfinsert (f, n, k); c = lgetc (curwp->w_dot.p, i); if (c == '\t') col += (tabsize - col % tabsize) - 1; else if (ISCTRL (c) != FALSE) ++col; } if (curwp->w_dot.o != llength (curwp->w_dot.p)) { selfinsert (f, n, k); nce = llength (curwp->w_dot.p) - curwp->w_dot.o; } else nce = 0; curwp->w_dot.o = i; if ((c = lgetc (curwp->w_dot.p, curwp->w_dot.o)) != ' ' && c != '\t') do { backchar (FALSE, 1, KRANDOM); } while ((c = lgetc (curwp->w_dot.p, curwp->w_dot.o)) != ' ' && c != '\t' && curwp->w_dot.o > 0); if (curwp->w_dot.o == 0) do { forwchar (FALSE, 1, KRANDOM); } while ((c = lgetc (curwp->w_dot.p, curwp->w_dot.o)) != ' ' && c != '\t' && curwp->w_dot.o < llength (curwp->w_dot.p)); delwhite (FALSE, 1, KRANDOM); backdel (FALSE, 1, KRANDOM); lnewline (); curwp->w_dot.o = llength (curwp->w_dot.p) - nce; curwp->w_flag |= WFMOVE; if (nce == 0 && curwp->w_dot.o != 0) return (fillword (f, n, k)); return (TRUE); }
void deletechar() /**/ { if (mult < 0) { mult = -mult; backwarddeletechar(); return; } if (c == 4 && !ll) { eofsent = 1; return; } if (!(cs+mult > ll || line[cs] == '\n')) { cs += mult; backdel(mult); } else feep(); }
int vijoin(UNUSED(char **args)) { int x, pos; int n = zmult; int visual = region_active; startvichange(-1); if (n < 1) return 1; if (visual && zlecs > mark) { exchangepointandmark(zlenoargs); x = findeol(); if (x >= mark) { exchangepointandmark(zlenoargs); return 1; } } else if ((x = findeol()) == zlell || (visual && x >= mark)) return 1; while (n) { zlecs = x + 1; pos = zlecs; for (; zlecs != zlell && ZC_iblank(zleline[zlecs]); INCPOS(zlecs)) ; x = 1 + (zlecs - pos); backdel(x, CUT_RAW); if (zlecs) { int pos = zlecs; DECPOS(pos); if (ZC_iblank(zleline[pos])) { zlecs = pos; return 0; } } spaceinline(1); zleline[zlecs] = ZWC(' '); if ((!visual && --n < 2) || (x = findeol()) == zlell || (visual && x >= mark)) return 0; } return 0; }
void vijoin(void) { int x; startvichange(-1); if ((x = findeol()) == ll) { feep(); return; } cs = x + 1; for (x = 1; cs != ll && iblank(line[cs]); cs++, x++); backdel(x); if (cs && iblank(line[cs-1])) cs--; else { spaceinline(1); line[cs] = ' '; } }
int deletechar(char **args) { int n; if (zmult < 0) { int ret; zmult = -zmult; ret = backwarddeletechar(args); zmult = -zmult; return ret; } n = zmult; while (n--) { if (zlecs == zlell) return 1; INCCS(); } backdel(zmult, 0); return 0; }
/* * Delete forward. This is real easy, because the basic delete routine does * all of the work. Watches for negative arguments, and does the right thing. * If any argument is present, it kills rather than deletes, to prevent loss * of text if typed with a big argument. Normally bound to "C-D". */ int forwdel(int f, int n) { if (curbp->b_mode&MDVIEW) /* don't allow this command if */ return(rdonly()); /* we are in read only mode */ if (n < 0) return (backdel(f, -n)); if(TERM_OPTIMIZE && (curwp->w_dotp != curwp->w_bufp->b_linep)){ int l; if(worthit(&l) && curwp->w_doto == llength(curwp->w_dotp)) scrollup(curwp, l+1, 1); } if (f != FALSE) { /* Really a kill. */ if ((lastflag&CFKILL) == 0) kdelete(); thisflag |= CFKILL; } return (ldelete((long) n, f ? kinsert : NULL)); }
mod_export void iremovesuffix(ZLE_INT_T c, int keep) { if (suffixfunc) { Shfunc shfunc = getshfunc(suffixfunc); if (shfunc) { LinkList args = newlinklist(); char buf[20]; int osc = sfcontext; int wasmeta = (zlemetaline != 0); if (wasmeta) { /* * The suffix removal function runs as a normal * ZLE function, not a completion function, so * the line should be unmetafied if this was * called from completion. (It may not be since * we may decide to remove the suffix later.) */ unmetafy_line(); } sprintf(buf, "%d", suffixfunclen); addlinknode(args, suffixfunc); addlinknode(args, buf); startparamscope(); makezleparams(0); sfcontext = SFC_COMPLETE; doshfunc(shfunc, args, 1); sfcontext = osc; endparamscope(); if (wasmeta) metafy_line(); } zsfree(suffixfunc); suffixfunc = NULL; } else { int sl = 0, flags = 0; struct suffixset *ss; if (c == NO_INSERT_CHAR) { sl = suffixnoinsrem ? suffixlen : 0; } else { ZLE_CHAR_T ch = c; /* * Search for a match for ch in the suffix list. * We stop if we encounter a match in a positive or negative * list, using the suffix length specified or zero respectively. * If we reached the end and passed through a negative * list, we use the suffix length for that, else zero. * This would break if it were possible to have negative * sets with different suffix length: that's not supposed * to happen. */ int negsuflen = 0, found = 0; for (ss = suffixlist; ss; ss = ss->next) { switch (ss->tp) { case SUFTYP_POSSTR: if (ZS_memchr(ss->chars, ch, ss->lenstr)) { sl = ss->lensuf; found = 1; } break; case SUFTYP_NEGSTR: if (ZS_memchr(ss->chars, ch, ss->lenstr)) { sl = 0; found = 1; } else { negsuflen = ss->lensuf; } break; case SUFTYP_POSRNG: if (ss->chars[0] <= ch && ch <= ss->chars[1]) { sl = ss->lensuf; found = 1; } break; case SUFTYP_NEGRNG: if (ss->chars[0] <= ch && ch <= ss->chars[1]) { sl = 0; found = 1; } else { negsuflen = ss->lensuf; } break; } if (found) { flags = ss->flags; break; } } if (!found) sl = negsuflen; } if (sl) { /* must be shifting wide character lengths */ backdel(sl, CUT_RAW); if (flags & SUFFLAGS_SPACE) { /* Add a space and advance over it */ spaceinline(1); if (zlemetaline) { zlemetaline[zlemetacs++] = ' '; } else { zleline[zlecs++] = ZWC(' '); } } if (!keep) invalidatelist(); } } fixsuffix(); }