1 /*-----------------------------------------------------------------------------+
2 | The ncurses form library is Copyright (C) 1995-1997 |
3 | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
4 | All Rights Reserved. |
6 | Permission to use, copy, modify, and distribute this software and its |
7 | documentation for any purpose and without fee is hereby granted, provided |
8 | that the above copyright notice appear in all copies and that both that |
9 | copyright notice and this permission notice appear in supporting |
10 | documentation, and that the name of the above listed copyright holder(s) not |
11 | be used in advertising or publicity pertaining to distribution of the |
12 | software without specific, written prior permission. |
14 | THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
15 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
16 | NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
17 | ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
18 | SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
19 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
20 | THE USE OR PERFORMANCE OF THIS SOFTWARE. |
21 +-----------------------------------------------------------------------------*/
23 #include "form.priv.h"
25 MODULE_ID("$Id: frm_data.c,v 1.3 1997/05/01 16:47:54 juergen Exp $")
27 /*---------------------------------------------------------------------------
29 | Function : bool data_behind(const FORM *form)
31 | Description : Check for off-screen data behind. This is nearly trivial
32 | becose the begin of a field is fixed.
34 | Return Values : TRUE - there are off-screen data behind
35 | FALSE - there are no off-screen data behind
36 +--------------------------------------------------------------------------*/
37 bool data_behind(const FORM *form)
41 if (form && (form->status & _POSTED) && form->current)
45 field = form->current;
46 if (!Single_Line_Field(field))
48 result = (form->toprow==0) ? FALSE : TRUE;
52 result = (form->begincol==0) ? FALSE : TRUE;
58 /*---------------------------------------------------------------------------
60 | Function : static char * After_Last_Non_Pad_Position(
65 | Description : Find the last position in the buffer that doesn't
66 | contain a padding character.
68 | Return Values : The pointer to this position
69 +--------------------------------------------------------------------------*/
71 static char * After_Last_Non_Pad_Position(char *buffer, int len, int pad)
73 char *end = buffer + len;
75 assert(buffer && len>=0);
76 while ( (buffer < end) && (*(end-1)==pad) )
82 #define SMALL_BUFFER_SIZE (80)
84 /*---------------------------------------------------------------------------
86 | Function : bool data_ahead(const FORM *form)
88 | Description : Check for off-screen data ahead. This is more difficult
89 | because a dynamic field has a variable end.
91 | Return Values : TRUE - there are off-screen data ahead
92 | FALSE - there are no off-screen data ahead
93 +--------------------------------------------------------------------------*/
94 bool data_ahead(const FORM *form)
98 if (form && (form->status & _POSTED) && form->current)
100 static char buffer[SMALL_BUFFER_SIZE + 1];
103 bool cursor_moved = FALSE;
108 field = form->current;
111 large_buffer = (field->cols > SMALL_BUFFER_SIZE);
113 bp = (char *)malloc((size_t)(field->cols) + 1);
119 if (Single_Line_Field(field))
123 pos = form->begincol + field->cols;
124 while (pos < field->dcols)
126 check_len = field->dcols - pos;
127 if ( check_len >= field->cols )
128 check_len = field->cols;
130 wmove(form->w,0,pos);
131 winnstr(form->w,bp,check_len);
133 After_Last_Non_Pad_Position(bp,check_len,field->pad);
134 if (found_content==bp)
145 pos = form->toprow + field->rows;
146 while (pos < field->drows)
149 wmove(form->w,pos,0);
151 winnstr(form->w,bp,field->cols);
153 After_Last_Non_Pad_Position(bp,field->cols,field->pad);
154 if (found_content!=bp)
166 wmove(form->w,form->currow,form->curcol);
171 /* frm_data.c ends here */