Deleted Added
full compact
internals.c (1.30) internals.c (1.31)
1/* $NetBSD: internals.c,v 1.30 2004/11/24 11:57:09 blymn Exp $ */
1/* $NetBSD: internals.c,v 1.31 2006/03/19 20:08:09 christos Exp $ */
2
3/*-
4 * Copyright (c) 1998-1999 Brett Lymn
5 * (blymn@baea.com.au, brett_lymn@yahoo.com.au)
6 * All rights reserved.
7 *
8 * This code has been donated to The NetBSD Foundation by the Author.
9 *

--- 15 unchanged lines hidden (view full) ---

25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 *
30 */
31
32#include <sys/cdefs.h>
2
3/*-
4 * Copyright (c) 1998-1999 Brett Lymn
5 * (blymn@baea.com.au, brett_lymn@yahoo.com.au)
6 * All rights reserved.
7 *
8 * This code has been donated to The NetBSD Foundation by the Author.
9 *

--- 15 unchanged lines hidden (view full) ---

25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 *
30 */
31
32#include <sys/cdefs.h>
33__RCSID("$NetBSD: internals.c,v 1.30 2004/11/24 11:57:09 blymn Exp $");
33__RCSID("$NetBSD: internals.c,v 1.31 2006/03/19 20:08:09 christos Exp $");
34
35#include <limits.h>
36#include <ctype.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <strings.h>
40#include <assert.h>
41#include "internals.h"

--- 906 unchanged lines hidden (view full) ---

948 }
949
950#ifdef DEBUG
951 if (dbg_ok == TRUE) {
952 fprintf(dbg,
953 "split_line: enter: length = %d, expanded = %d\n",
954 row->length, row->expanded);
955 }
34
35#include <limits.h>
36#include <ctype.h>
37#include <stdio.h>
38#include <stdlib.h>
39#include <strings.h>
40#include <assert.h>
41#include "internals.h"

--- 906 unchanged lines hidden (view full) ---

948 }
949
950#ifdef DEBUG
951 if (dbg_ok == TRUE) {
952 fprintf(dbg,
953 "split_line: enter: length = %d, expanded = %d\n",
954 row->length, row->expanded);
955 }
956#endif
956
957 assert((row->length < INT_MAX) && (row->expanded < INT_MAX));
958
957
958 assert((row->length < INT_MAX) && (row->expanded < INT_MAX));
959
959#endif
960
961 /* add new line to the row list */
962 new_line->next = row->next;
963 new_line->prev = row;
964 row->next = new_line;
965 if (new_line->next != NULL)
966 new_line->next->prev = new_line;
967

--- 41 unchanged lines hidden (view full) ---

1009 field->cursor_xpos--;
1010
1011 field->cursor_ypos++;
1012 if (field->cursor_ypos >= field->rows) {
1013 if (field->start_line->next != NULL) {
1014 field->start_line = field->start_line->next;
1015 field->cursor_ypos = field->rows - 1;
1016 }
960
961 /* add new line to the row list */
962 new_line->next = row->next;
963 new_line->prev = row;
964 row->next = new_line;
965 if (new_line->next != NULL)
966 new_line->next->prev = new_line;
967

--- 41 unchanged lines hidden (view full) ---

1009 field->cursor_xpos--;
1010
1011 field->cursor_ypos++;
1012 if (field->cursor_ypos >= field->rows) {
1013 if (field->start_line->next != NULL) {
1014 field->start_line = field->start_line->next;
1015 field->cursor_ypos = field->rows - 1;
1016 }
1017#ifdef DEBUG
1018 else
1019 assert(field->start_line->next == NULL);
1017 else
1018 assert(field->start_line->next == NULL);
1020#endif
1021 }
1022 }
1023
1024 /*
1025 * If the line split had a hard return then replace the
1026 * current line's hard return with a soft return and carry
1027 * the hard return onto the line after.
1028 */

--- 5 unchanged lines hidden (view full) ---

1034 /*
1035 * except where we are doing a hard split then the current
1036 * row must have a hard return on it too...
1037 */
1038 if (hard_split == TRUE) {
1039 row->hard_ret = TRUE;
1040 }
1041
1019 }
1020 }
1021
1022 /*
1023 * If the line split had a hard return then replace the
1024 * current line's hard return with a soft return and carry
1025 * the hard return onto the line after.
1026 */

--- 5 unchanged lines hidden (view full) ---

1032 /*
1033 * except where we are doing a hard split then the current
1034 * row must have a hard return on it too...
1035 */
1036 if (hard_split == TRUE) {
1037 row->hard_ret = TRUE;
1038 }
1039
1042#ifdef DEBUG
1043 assert(((row->expanded < INT_MAX) &&
1044 (new_line->expanded < INT_MAX) &&
1045 (row->length < INT_MAX) &&
1046 (new_line->length < INT_MAX)));
1047
1040 assert(((row->expanded < INT_MAX) &&
1041 (new_line->expanded < INT_MAX) &&
1042 (row->length < INT_MAX) &&
1043 (new_line->length < INT_MAX)));
1044
1045#ifdef DEBUG
1048 if (dbg_ok == TRUE) {
1049 fprintf(dbg, "split_line: exit: ");
1050 fprintf(dbg, "row.length = %d, row.expanded = %d, ",
1051 row->length, row->expanded);
1052 fprintf(dbg,
1053 "next_line.length = %d, next_line.expanded = %d, ",
1054 new_line->length, new_line->expanded);
1055 fprintf(dbg, "row_count = %d\n", field->row_count + 1);

--- 386 unchanged lines hidden (view full) ---

1442 /* skip tabs to the lhs of our starting point */
1443 while ((ts != NULL) && (ts->in_use == TRUE)
1444 && (ts->pos < end))
1445 ts = ts->fwd;
1446
1447 while ((expanded <= field->cols)
1448 && (end < row->length)) {
1449 if (row->string[end] == '\t') {
1046 if (dbg_ok == TRUE) {
1047 fprintf(dbg, "split_line: exit: ");
1048 fprintf(dbg, "row.length = %d, row.expanded = %d, ",
1049 row->length, row->expanded);
1050 fprintf(dbg,
1051 "next_line.length = %d, next_line.expanded = %d, ",
1052 new_line->length, new_line->expanded);
1053 fprintf(dbg, "row_count = %d\n", field->row_count + 1);

--- 386 unchanged lines hidden (view full) ---

1440 /* skip tabs to the lhs of our starting point */
1441 while ((ts != NULL) && (ts->in_use == TRUE)
1442 && (ts->pos < end))
1443 ts = ts->fwd;
1444
1445 while ((expanded <= field->cols)
1446 && (end < row->length)) {
1447 if (row->string[end] == '\t') {
1450#ifdef DEBUG
1451 assert((ts != NULL)
1452 && (ts->in_use == TRUE));
1448 assert((ts != NULL)
1449 && (ts->in_use == TRUE));
1453#endif
1454 if (ts->pos == end) {
1455 if ((expanded + ts->size)
1456 > field->cols)
1457 break;
1458 expanded += ts->size;
1459 ts = ts->fwd;
1460 }
1450 if (ts->pos == end) {
1451 if ((expanded + ts->size)
1452 > field->cols)
1453 break;
1454 expanded += ts->size;
1455 ts = ts->fwd;
1456 }
1461#ifdef DEBUG
1462 else
1463 assert(ts->pos == end);
1457 else
1458 assert(ts->pos == end);
1464#endif
1465 } else
1466 expanded++;
1467 end++;
1468 }
1469 }
1470
1471 scroll_amt = tab_fit_window(field, end, field->cols);
1472 if (scroll_amt < field->start_char)

--- 283 unchanged lines hidden (view full) ---

1756add_tab(FORM *form, _FORMI_FIELD_LINES *row, unsigned int i, char c)
1757{
1758 int j;
1759 _formi_tab_t *ts = row->tabs;
1760
1761 while ((ts != NULL) && (ts->pos != i))
1762 ts = ts->fwd;
1763
1459 } else
1460 expanded++;
1461 end++;
1462 }
1463 }
1464
1465 scroll_amt = tab_fit_window(field, end, field->cols);
1466 if (scroll_amt < field->start_char)

--- 283 unchanged lines hidden (view full) ---

1750add_tab(FORM *form, _FORMI_FIELD_LINES *row, unsigned int i, char c)
1751{
1752 int j;
1753 _formi_tab_t *ts = row->tabs;
1754
1755 while ((ts != NULL) && (ts->pos != i))
1756 ts = ts->fwd;
1757
1764#ifdef DEBUG
1765 assert(ts != NULL);
1758 assert(ts != NULL);
1766#endif
1767
1768 for (j = 0; j < ts->size; j++)
1769 waddch(form->scrwin, c);
1770
1771 return ts->size;
1772}
1773
1774

--- 202 unchanged lines hidden (view full) ---

1977 if ((field->cursor_xpos >= field->cols) &&
1978 (field->cursor_ypos == (field->rows - 1))) {
1979 field->cursor_ypos--;
1980 field->start_line = field->start_line->next;
1981 }
1982 }
1983 }
1984
1759
1760 for (j = 0; j < ts->size; j++)
1761 waddch(form->scrwin, c);
1762
1763 return ts->size;
1764}
1765
1766

--- 202 unchanged lines hidden (view full) ---

1969 if ((field->cursor_xpos >= field->cols) &&
1970 (field->cursor_ypos == (field->rows - 1))) {
1971 field->cursor_ypos--;
1972 field->start_line = field->start_line->next;
1973 }
1974 }
1975 }
1976
1985#ifdef DEBUG
1986 assert((field->cursor_xpos <= field->cols)
1987 && (field->cursor_ypos < 400000));
1988
1977 assert((field->cursor_xpos <= field->cols)
1978 && (field->cursor_ypos < 400000));
1979
1980#ifdef DEBUG
1989 fprintf(dbg, "add_char exit: xpos=%d, row_pos=%d, start=%d\n",
1990 field->cursor_xpos, field->row_xpos, field->start_char);
1991 fprintf(dbg, "add_char_exit: length=%d(%d), allocated=%d\n",
1992 row->expanded, row->length, row->allocated);
1993 fprintf(dbg, "add_char exit: ypos=%d, start_line=%p\n",
1994 field->cursor_ypos, field->start_line);
1995 fprintf(dbg,"add_char exit: %s\n", row->string);
1996 fprintf(dbg, "add_char exit: buf0_status=%d\n", field->buf0_status);

--- 1534 unchanged lines hidden (view full) ---

3531 * left of our starting pos.
3532 */
3533 while ((ts != NULL) && (ts->in_use == TRUE) && (ts->pos > pos))
3534 ts = ts->back;
3535
3536 scroll_amt = 0;
3537 for (i = pos; i >= 0; i--) {
3538 if (field->lines->string[i] == '\t') {
1981 fprintf(dbg, "add_char exit: xpos=%d, row_pos=%d, start=%d\n",
1982 field->cursor_xpos, field->row_xpos, field->start_char);
1983 fprintf(dbg, "add_char_exit: length=%d(%d), allocated=%d\n",
1984 row->expanded, row->length, row->allocated);
1985 fprintf(dbg, "add_char exit: ypos=%d, start_line=%p\n",
1986 field->cursor_ypos, field->start_line);
1987 fprintf(dbg,"add_char exit: %s\n", row->string);
1988 fprintf(dbg, "add_char exit: buf0_status=%d\n", field->buf0_status);

--- 1534 unchanged lines hidden (view full) ---

3523 * left of our starting pos.
3524 */
3525 while ((ts != NULL) && (ts->in_use == TRUE) && (ts->pos > pos))
3526 ts = ts->back;
3527
3528 scroll_amt = 0;
3529 for (i = pos; i >= 0; i--) {
3530 if (field->lines->string[i] == '\t') {
3539#ifdef DEBUG
3540 assert((ts != NULL) && (ts->in_use == TRUE));
3531 assert((ts != NULL) && (ts->in_use == TRUE));
3541#endif
3542 if (ts->pos == i) {
3543 if ((scroll_amt + ts->size) > window) {
3544 break;
3545 }
3546 scroll_amt += ts->size;
3547 ts = ts->back;
3548 }
3532 if (ts->pos == i) {
3533 if ((scroll_amt + ts->size) > window) {
3534 break;
3535 }
3536 scroll_amt += ts->size;
3537 ts = ts->back;
3538 }
3549#ifdef DEBUG
3550 else
3551 assert(ts->pos == i);
3539 else
3540 assert(ts->pos == i);
3552#endif
3553 } else {
3554 scroll_amt++;
3555 if (scroll_amt > window)
3556 break;
3557 }
3558 }
3559
3560 return ++i;

--- 15 unchanged lines hidden (view full) ---

3576 len = 0;
3577 row_pos = 0;
3578
3579 if (width == 0)
3580 return 0;
3581
3582 while ((len < width) && (pos < row->length)) {
3583 if (row->string[pos] == '\t') {
3541 } else {
3542 scroll_amt++;
3543 if (scroll_amt > window)
3544 break;
3545 }
3546 }
3547
3548 return ++i;

--- 15 unchanged lines hidden (view full) ---

3564 len = 0;
3565 row_pos = 0;
3566
3567 if (width == 0)
3568 return 0;
3569
3570 while ((len < width) && (pos < row->length)) {
3571 if (row->string[pos] == '\t') {
3584#ifdef DEBUG
3585 assert((ts != NULL) && (ts->in_use == TRUE));
3572 assert((ts != NULL) && (ts->in_use == TRUE));
3586#endif
3587 if (ts->pos == row_pos) {
3588 if ((len + ts->size) > width)
3589 break;
3590 len += ts->size;
3591 ts = ts->fwd;
3592 }
3573 if (ts->pos == row_pos) {
3574 if ((len + ts->size) > width)
3575 break;
3576 len += ts->size;
3577 ts = ts->fwd;
3578 }
3593#ifdef DEBUG
3594 else
3595 assert(ts->pos == row_pos);
3579 else
3580 assert(ts->pos == row_pos);
3596#endif
3597 } else
3598 len++;
3599 pos++;
3600 row_pos++;
3601 }
3602
3603 if (pos > 0)
3604 pos--;

--- 60 unchanged lines hidden ---
3581 } else
3582 len++;
3583 pos++;
3584 row_pos++;
3585 }
3586
3587 if (pos > 0)
3588 pos--;

--- 60 unchanged lines hidden ---