home *** CD-ROM | disk | FTP | other *** search
- /*
- tedword.c
-
- % ted_FindWord
-
- text editting right and left word function
-
- C-scape 3.2
- Copyright (c) 1988 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/09/88 jdc created
-
- 3/24/89 jmd added sed_ macros
- 5/23/89 jdc made tb_setcursor menu_setcursor
-
- 2/22/90 jdc preened
- 3/28/90 jmd ansi-fied
- 5/02/90 jdc now moves to beginning/end as default
- fixed find old spaces bug
- 12/10/90 jdc added check for ted_GotoPosition's return value
- */
-
- #include "ted.h"
-
- boolean ted_FindWord(sed_type sed, int mode)
- {
- tb_type tb;
- long cursor;
- bbpeek_struct bp;
- int i, white, done, dlen, row, col;
-
- tb = sed_GetTextbuf(sed);
- cursor = tb->cursor;
-
- bp.b = tb->bbc->b;
- bp.len = tb->size;
- bp.off = bp.b->off + tb_GetCursor(tb);
- if (mode != TED_FORWARD) {
- bp.off -= 1;
- }
-
- for (done = FALSE, white = (mode == TED_FORWARD) ? FALSE:TRUE; !done;) {
- for (i = 0, dlen = bbpeek(&bp); dlen > 0;) {
-
- if (is_whitespace(bp.p[i]) == white) {
-
- if (mode == TED_FORWARD) {
- i++;
- bp.off++;
- if (i >= dlen) {
- break;
- }
- }
- else { /* TED_BACKWARD */
- i--;
- bp.off--;
- break;
- }
- }
- else if (mode == TED_FORWARD && white == FALSE) {
- white = TRUE;
- }
- else if (mode != TED_FORWARD && white == TRUE) {
- white = FALSE;
- }
- else {
- done = TRUE;
- break;
- }
- }
- if (dlen == 0) break;
-
- cursor += i;
- }
-
- row = tb_GetRow(tb);
- col = tb_GetCol(tb);
- tb->cursor = cursor;
- menu_setcursor(sed_GetMenu(sed));
-
- if (!ted_GotoPosition(sed, tb_GetRow(tb), tb_GetCol(tb))) {
- tb_FindPosition(tb, row, col);
- }
-
- return(TRUE);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-