/****************************************************************************1* Copyright (c) 1998 Free Software Foundation, Inc. *2* *3* Permission is hereby granted, free of charge, to any person obtaining a *4* copy of this software and associated documentation files (the *5* "Software"), to deal in the Software without restriction, including *6* without limitation the rights to use, copy, modify, merge, publish, *7* distribute, distribute with modifications, sublicense, and/or sell *8* copies of the Software, and to permit persons to whom the Software is *9* furnished to do so, subject to the following conditions: *10* *11* The above copyright notice and this permission notice shall be included *12* in all copies or substantial portions of the Software. *13* *14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *15* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *16* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *17* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *20* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *21* *22* Except as contained in this notice, the name(s) of the above copyright *23* holders shall not be used in advertising or otherwise to promote the *24* sale, use or other dealings in this Software without prior written *25* authorization. *26****************************************************************************/2728/****************************************************************************29* Author: Juergen Pfeifer <[email protected]> 1995,1997 *30****************************************************************************/3132#include "form.priv.h"3334MODULE_ID("$Id$")3536extern int winnstr(WINDOW *, char *, int);3738/*---------------------------------------------------------------------------39| Facility : libnform40| Function : bool data_behind(const FORM *form)41|42| Description : Check for off-screen data behind. This is nearly trivial43| becose the begin of a field is fixed.44|45| Return Values : TRUE - there are off-screen data behind46| FALSE - there are no off-screen data behind47+--------------------------------------------------------------------------*/48bool data_behind(const FORM *form)49{50bool result = FALSE;5152if (form && (form->status & _POSTED) && form->current)53{54FIELD *field;5556field = form->current;57if (!Single_Line_Field(field))58{59result = (form->toprow==0) ? FALSE : TRUE;60}61else62{63result = (form->begincol==0) ? FALSE : TRUE;64}65}66return(result);67}6869/*---------------------------------------------------------------------------70| Facility : libnform71| Function : static char * After_Last_Non_Pad_Position(72| char *buffer,73| int len,74| int pad)75|76| Description : Find the last position in the buffer that doesn't77| contain a padding character.78|79| Return Values : The pointer to this position80+--------------------------------------------------------------------------*/81INLINE82static char * After_Last_Non_Pad_Position(char *buffer, int len, int pad)83{84char *end = buffer + len;8586assert(buffer && len>=0);87while ( (buffer < end) && (*(end-1)==pad) )88end--;8990return end;91}9293#define SMALL_BUFFER_SIZE (80)9495/*---------------------------------------------------------------------------96| Facility : libnform97| Function : bool data_ahead(const FORM *form)98|99| Description : Check for off-screen data ahead. This is more difficult100| because a dynamic field has a variable end.101|102| Return Values : TRUE - there are off-screen data ahead103| FALSE - there are no off-screen data ahead104+--------------------------------------------------------------------------*/105bool data_ahead(const FORM *form)106{107bool result = FALSE;108109if (form && (form->status & _POSTED) && form->current)110{111static char buffer[SMALL_BUFFER_SIZE + 1];112FIELD *field;113bool large_buffer;114bool cursor_moved = FALSE;115char *bp;116char *found_content;117int pos;118119field = form->current;120assert(form->w != 0);121122large_buffer = (field->cols > SMALL_BUFFER_SIZE);123if (large_buffer)124bp = (char *)malloc((size_t)(field->cols) + 1);125else126bp = buffer;127128assert(bp != 0);129130if (Single_Line_Field(field))131{132int check_len;133134pos = form->begincol + field->cols;135while (pos < field->dcols)136{137check_len = field->dcols - pos;138if ( check_len >= field->cols )139check_len = field->cols;140cursor_moved = TRUE;141wmove(form->w,0,pos);142winnstr(form->w,bp,check_len);143found_content =144After_Last_Non_Pad_Position(bp,check_len,field->pad);145if (found_content==bp)146pos += field->cols;147else148{149result = TRUE;150break;151}152}153}154else155{156pos = form->toprow + field->rows;157while (pos < field->drows)158{159cursor_moved = TRUE;160wmove(form->w,pos,0);161pos++;162winnstr(form->w,bp,field->cols);163found_content =164After_Last_Non_Pad_Position(bp,field->cols,field->pad);165if (found_content!=bp)166{167result = TRUE;168break;169}170}171}172173if (large_buffer)174free(bp);175176if (cursor_moved)177wmove(form->w,form->currow,form->curcol);178}179return(result);180}181182/* frm_data.c ends here */183184185