home *** CD-ROM | disk | FTP | other *** search
- /*
- tedfoll.c
-
- % ted_Follow
-
- C-scape 3.2
- Copyright (c) 1988 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 6/17/88 jdc created
-
- 3/24/89 jmd added sed_ macros
- 8/04/89 jdc added tb->cursor_set stuff (sed_GetTB loop bug)
-
- 3/28/90 jmd ansi-fied
- 10/28/90 jdc fixed boolean/int ret conflict
- */
-
- #include "ted.h"
-
- boolean ted_Follow(sed_type sed, int row, int col)
- /*
- forces the cursor to follow the lines of text
- */
- {
- tb_type tb;
- int lrow, lcol, set;
- boolean ret = TRUE;
-
- tb = sed_GetTextbuf(sed);
- ted_GetPosition(sed, &lrow, &lcol);
- set = tb->cursor_set;
-
- if (row <= 0) {
- row = 0;
- if (col < 0) {
- col = 0;
- }
- }
- if (tb_FindLine(tb, row) <= 0) {
- row = lrow;
- col = lcol;
- ret = FALSE;
- }
- else if (col == lcol) {
- if (row == lrow) {
- ret = FALSE;
- }
- else if (tb->xcol < tb->exp_len) {
- col = tb->xcol;
- }
- else {
- col = tb->exp_len - 1;
- }
- }
- else if (col < 0) {
- tb_FindLine(tb, --row);
- col = tb->exp_len - 1;
- tb->xcol = col;
- }
- else if (col >= tb->exp_len) {
- if (tb_FindLine(tb, ++row) <= 0) {
- row = lrow;
- col = lcol;
- ret = FALSE;
- }
- else {
- col = 0;
- tb->xcol = col;
- }
- }
- else {
- tb->xcol = col;
- }
- tb_FindPosition(tb, row, col);
- ted_SetCursor(sed, row, col);
- if (ted_GetRefresh(sed)) {
- ted_Scroll(sed);
- }
- if (!ret) {
- tb->cursor_set = set;
- }
- return(ret);
- }
-