📄 edbasic.c
字号:
return(forwword(theEnv,0, 1) && forwchar(theEnv,0, cnt)); }/* * Move the cursor backward by "n" words. All of the details of motion are * performed by the "backchar" and "forwchar" routines. Error if you try to * move beyond the buffers. */#if IBM_TBC#pragma argsused#endifgloble int backword( void *theEnv, int f, int n) { if (n < 0) return (forwword(theEnv,f, -n)); if (backchar(theEnv,FALSE, 1) == FALSE) return (FALSE); while (n--) { while (inword() == FALSE) { if (backchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } while (inword() != FALSE) { if (backchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } } return (forwchar(theEnv,FALSE, 1)); }/* * Move the cursor forward by the specified number of words. All of the motion * is done by "forwchar". Error if you try and move beyond the buffer's end. */#if IBM_TBC#pragma argsused#endifgloble int forwword( void *theEnv, int f, int n) { if (n < 0) return (backword(theEnv,f, -n)); while (n--) { while (inword() == FALSE) { if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } while (inword() != FALSE) { if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } } return (TRUE); }/* * Move the cursor forward by the specified number of words. As you move, * convert any characters to upper case. Error if you try and move beyond the * end of the buffer. Bound to "M-U". */#if IBM_TBC#pragma argsused#endifgloble int upperword( void *theEnv, int f, int n) { register int c; if (n < 0) return (FALSE); while (n--) { while (inword() == FALSE) { if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } while (inword() != FALSE) { c = lgetc(curwp->w_dotp, curwp->w_doto); if (c>='a' && c<='z') { c -= 'a'-'A'; lputc(curwp->w_dotp, curwp->w_doto, c); lchange(WFHARD); } if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } } return (TRUE); }/* * Move the cursor forward by the specified number of words. As you move * convert characters to lower case. Error if you try and move over the end of * the buffer. Bound to "M-L". */#if IBM_TBC#pragma argsused#endifgloble int lowerword( void *theEnv, int f, int n) { register int c; if (n < 0) return (FALSE); while (n--) { while (inword() == FALSE) { if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } while (inword() != FALSE) { c = lgetc(curwp->w_dotp, curwp->w_doto); if (c>='A' && c<='Z') { c += 'a'-'A'; lputc(curwp->w_dotp, curwp->w_doto, c); lchange(WFHARD); } if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } } return (TRUE); }/* * Move the cursor forward by the specified number of words. As you move * convert the first character of the word to upper case, and subsequent * characters to lower case. Error if you try and move past the end of the * buffer. Bound to "M-C". */#if IBM_TBC#pragma argsused#endifgloble int capword( void *theEnv, int f, int n) { register int c; if (n < 0) return (FALSE); while (n--) { while (inword() == FALSE) { if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } if (inword() != FALSE) { c = lgetc(curwp->w_dotp, curwp->w_doto); if (c>='a' && c<='z') { c -= 'a'-'A'; lputc(curwp->w_dotp, curwp->w_doto, c); lchange(WFHARD); } if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); while (inword() != FALSE) { c = lgetc(curwp->w_dotp, curwp->w_doto); if (c>='A' && c<='Z') { c += 'a'-'A'; lputc(curwp->w_dotp, curwp->w_doto, c); lchange(WFHARD); } if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); } } } return (TRUE); }/* * Kill forward by "n" words. Remember the location of dot. Move forward by * the right number of words. Put dot back where it was and issue the kill * command for the right number of characters. Bound to "M-D". */#if IBM_TBC#pragma argsused#endifgloble int delfword( void *theEnv, int f, int n) { register int size; register LINE *dotp; register int doto; if (n < 0) return (FALSE); if ((lastflag&CFKILL) == 0) /* Clear kill buffer if */ kdelete(theEnv); /* last wasn't a kill. */ thisflag |= CFKILL; dotp = curwp->w_dotp; doto = curwp->w_doto; size = 0; while (n--) { while (inword() == FALSE) { if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); ++size; } while (inword() != FALSE) { if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); ++size; } } curwp->w_dotp = dotp; curwp->w_doto = doto; return (ldelete(theEnv,(long) size, TRUE)); }/* * Kill backwards by "n" words. Move backwards by the desired number of words, * counting the characters. When dot is finally moved to its resting place, * fire off the kill command. Bound to "M-Rubout" and to "M-Backspace". */#if IBM_TBC#pragma argsused#endifgloble int delbword( void *theEnv, int f, int n) { register int size; if (n < 0) return (FALSE); if (backchar(theEnv,FALSE, 1) == FALSE) return (FALSE); if ((lastflag&CFKILL) == 0) /* Clear kill buffer if */ kdelete(theEnv); /* last wasn't a kill. */ thisflag |= CFKILL; size = 0; while (n--) { while (inword() == FALSE) { if (backchar(theEnv,FALSE, 1) == FALSE) return (FALSE); ++size; } while (inword() != FALSE) { if (backchar(theEnv,FALSE, 1) == FALSE) return (FALSE); ++size; } } if (forwchar(theEnv,FALSE, 1) == FALSE) return (FALSE); return (ldelete(theEnv,(long) size, TRUE)); }/* * Return TRUE if the character at dot is a character that is considered * part of a word. The word character list is hard coded. Should be setable. */globle int inword(){ register int c; if (curwp->w_doto == llength(curwp->w_dotp)) return (FALSE); c = lgetc(curwp->w_dotp, curwp->w_doto); if (c>='a' && c<='z') return (TRUE); if (c>='A' && c<='Z') return (TRUE); if (c>='0' && c<='9') return (TRUE); if (c=='$') /* For identifiers */ return (TRUE); return (FALSE);}/* ======================================================================= * REGION FUNCTIONS * ======================================================================= *//* * The routines in this section deal with the region, that magic space * between "." and mark. Some functions are commands. Some functions are * just for internal use. *//* * Kill the region. Ask "getregion" * to figure out the bounds of the region. * Move "." to the start, and kill the characters. * Bound to "C-W". */#if IBM_TBC#pragma argsused#endifgloble int killregion( void *theEnv, int f, int n) { register int s; REGION region; if ((s=getregion(®ion)) != TRUE) { return (s); } if ((lastflag&CFKILL) == 0) /* This is a kill type */ { kdelete(theEnv); } /* command, so do magic */ thisflag |= CFKILL; /* kill buffer stuff. */ curwp->w_dotp = region.r_linep; curwp->w_doto = region.r_offset; return (ldelete(theEnv,region.r_size, TRUE)); }/* * Copy all of the characters in the * region to the kill buffer. Don't move dot * at all. This is a bit like a kill region followed * by a yank. Bound to "M-W". */#if IBM_TBC#pragma argsused#endifgloble int copyregion( void *theEnv, int f, int n) { register LINE *linep; register int loffs; register int s; REGION region; if ((s=getregion(®ion)) != TRUE) return (s); if ((lastflag&CFKILL) == 0) /* Kill type command. */ kdelete(theEnv); thisflag |= CFKILL; linep = region.r_linep; /* Current line. */ loffs = region.r_offset; /* Current offset. */ while (region.r_size--) { if (loffs == llength(linep)) { /* End of line. */ if ((s=kinsert(theEnv,'\n')) != TRUE) return (s); linep = lforw(linep); loffs = 0; } else { /* Middle of line. */ if ((s=kinsert(theEnv,lgetc(linep, loffs))) != TRUE) return (s); ++loffs; } } mlwrite("Region copied to buffer"); return (TRUE); }/* * Lower case region. Zap all of the upper * case characters in the region to lower case. Use * the region code to set the limits. Scan the buffer, * doing the changes. Call "lchange" to ensure that * redisplay is done in all buffers. Bound to * "C-X C-L". */#if IBM_TBC#pragma argsused#endifgloble int lowerregion( void *theEnv, int f, int n) { register LINE *linep; register int loffs; register int c; register int s; REGION region; if ((s=getregion(®ion)) != TRUE) return (s); lchange(WFHARD); linep = region.r_linep; loffs = region.r_offset; while (region.r_size--) { if (loffs == llength(linep)) { linep = lforw(linep); loffs = 0; } else { c = lgetc(linep, loffs); if (c>='A' && c<='Z') lputc(linep, loffs, c+'a'-'A'); ++loffs; } } return (TRUE); }/* * Upper case region. Zap all of the lower * case characters in the region to upper case. Use * the region code to set the limits. Scan the buffer, * doing the changes. Call "lchange" to ensure that * redisplay is done in all buffers. Bound to * "C-X C-L". */#if IBM_TBC#pragma argsused#endifgloble int upperregion( void *theEnv, int f, int n) { register LINE *linep; register int loffs; register int c; register int s; REGION region; if ((s=getregion(®ion)) != TRUE) return (s); lchange(WFHARD); linep = region.r_linep; loffs = region.r_offset; while (region.r_size--) { if (loffs == llength(linep)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -