/* Word wrap on n-spaces. Back-over whatever precedes the point on the current * line and stop on the first word-break or the beginning of the line. If we * reach the beginning of the line, jump back to the end of the word and start * a new line. Otherwise, break the line at the word-break, eat it, and jump * back to the end of the word. * Returns TRUE on success, FALSE on errors. */ wrapword() { register int cnt; /* size of word wrapped to next line */ register int bp; /* index to wrap on */ register int first = -1; register int i; if(curwp->w_doto <= 0) /* no line to wrap? */ return(FALSE); for(bp = cnt = i = 0; cnt < llength(curwp->w_dotp) && !bp; cnt++, i++){ if(isspace((unsigned char) lgetc(curwp->w_dotp, cnt).c)){ first = 0; if(lgetc(curwp->w_dotp, cnt).c == TAB) while(i+1 & 0x07) i++; } else if(!first) first = cnt; if(first > 0 && i >= fillcol) bp = first; } if(!bp) return(FALSE); /* bp now points to the first character of the next line */ cnt = curwp->w_doto - bp; curwp->w_doto = bp; if(!lnewline()) /* break the line */ return(FALSE); /* * if there's a line below, it doesn't start with whitespace * and there's room for this line... */ if(!(curbp->b_flag & BFWRAPOPEN) && lforw(curwp->w_dotp) != curbp->b_linep && llength(lforw(curwp->w_dotp)) && !isspace((unsigned char) lgetc(lforw(curwp->w_dotp), 0).c) && (llength(curwp->w_dotp) + llength(lforw(curwp->w_dotp)) < fillcol)){ gotoeol(0, 1); /* then pull text up from below */ if(lgetc(curwp->w_dotp, curwp->w_doto - 1).c != ' ') linsert(1, ' '); forwdel(0, 1); gotobol(0, 1); } curbp->b_flag &= ~BFWRAPOPEN; /* don't open new line next wrap */ /* restore dot (account for NL) */ if(cnt && !forwchar(0, cnt < 0 ? cnt-1 : cnt)) return(FALSE); return(TRUE); }
void on_triple_click(void) { MARK save; save = DOT; TRACE(("MOUSE triple-click DOT %d.%d\n", line_no(curbp, DOT.l), DOT.o)); sel_release(); gotobol(FALSE, 1); sel_begin(); MK = DOT; gotoeol(FALSE, 1); sel_extend(FALSE, TRUE); DOT = save; update(TRUE); }
/* select all text in curbp and yank to unnamed register */ int sel_all(int f GCC_UNUSED, int n GCC_UNUSED) { int rc; MARK savedot; savedot = DOT; gotobob(0, 0); sel_begin(); gotoeob(0, 0); gotoeol(0, 0); (void) sel_setshape(rgn_EXACT); rc = sel_extend(TRUE, TRUE); DOT = savedot; if (rc) sel_yank(0); return (rc); }
int do_gotoeop(int f, int n, int *i) { int col, nospace, j = 0; /* the other way... */ if (n < 0) return (gotobop(f, -n)); /* for each one asked for */ while (n-- > 0) { *i = ++j; nospace = 0; while (lforw(curwp->w_dotp) != curbp->b_headp) { col = 0; curwp->w_doto = 0; while (col < llength(curwp->w_dotp) && (isspace(lgetc(curwp->w_dotp, col)))) col++; if (col >= llength(curwp->w_dotp)) { if (nospace) break; } else nospace = 1; curwp->w_dotp = lforw(curwp->w_dotp); curwp->w_dotline++; } } /* do not continue after end of buffer */ if (lforw(curwp->w_dotp) == curbp->b_headp) { gotoeol(FFRAND, 1); curwp->w_rflag |= WFMOVE; return (FALSE); } /* force screen update */ curwp->w_rflag |= WFMOVE; return (TRUE); }