Newer
Older
Microsoft / ice / ICE_FEDI.C
@tundra tundra on 24 May 2012 4 KB Initial revision
/* ICE_FEDI.C - IceScreen Field Edit Routines

                Copyright (c) 1988, 1989, 1990 By T.A. Daneliuk
                Last Modified: 06-06-90

        These routines edit a specific field in accordance with the
        definitions in a structure type called ICE_FIELD.  On entry,
        the calling routine passes a pointer to such a field.  On
        return, ICE_NOERR is returned if the edit was successful.
        An error code is returned if the edit failed for some reason.
        This will occur under the following conditions:

            The pointer passed to ice_fedit() is NULL     (ICE_NULFPTR)
            The passed structure points to a Prompt field (ICE_ENOTRES)
            The the "field" structure member is NULL      (ICE_EFNULL)

        The function will not accept any characters which do not meet
        the character validation conditions, and will not return until
        the whole field validation function passes successfully.
*/

#include    <stdio.h>
#include    <stdlib.h>
#include    <malloc.h>
#include    <string.h>
#include    <ice_defs.h>
#include    <ctype.h>

#if ANSI
static void dsply_fld(struct ICE_FIELD *x, FLEN y);
#else
static void dsply_fld();
#endif


/*====================== MAIN FIELD EDITING FUNCTION =========================*/

ICE_ERROR ice_fedit(fldptr, retnkey)

struct  ICE_FIELD   *fldptr;
KEYSTR              *retnkey;

{
    BOOL        done, getkey, insert;
    FLEN        posn;
    ICE_ERROR   fedit_status;
    KEYSTR      *buffer, key;

    fedit_status = ICE_NOERR;

    if (fldptr == NULL)                         /* See If Bad Pointer Passed  */
        fedit_status = ICE_NULFPTR;

    if (fldptr->ftype != FLD_RESP)              /* See If Response Allowed    */
        fedit_status = ICE_ENOTRES;
    else
        if (fldptr->field == NULL)              /* Is Response Fld. Ptr. OK?  */
            fedit_status = ICE_EFNULL;

    if ((buffer = (KEYSTR *) malloc((size_t) ((fldptr->rlen) + 1))) == NULL)
        fedit_status = ICE_NOMEM;               /* No Mem. For Wking. Buffer */

    if (fedit_status != ICE_NOERR)              /* Error Detected, Get Out    */
        return(fedit_status);


    insert = done = FALSE;                      /* Prepare To Edit Field */
    getkey = TRUE;
    posn = 0;
    ice_rowcol(fldptr->frow, fldptr->fcol);
    (void) strcpy((char *) buffer, (char *) fldptr->field); /* Bld Wrk Buffer */
    ice_cursor(CURSML);

    while (!done)
        {
        if (getkey)
            key = ice_keyin();

        switch(key)
            {
            case NXT_FLD:     /* All These Initiate Close & Exit Processing */
            case PRV_FLD:
            case FST_FLD:
            case LST_FLD:
            case SCR_DONE:
            case FLD_DONE:    
                *retnkey = key;
                done = TRUE;
                break;

            case HELP:
                break;

            case CUR_LEFT:
                break;

            case CUR_RIGHT:
                break;

            case CUR_UP:
                break;

            case CUR_DOWN:
                break;

            case CUR_PG_UP:
                break;

            case CUR_PG_DOWN:
                break;

            case CUR_BGN_LIN:
                break;

            case CUR_END_LIN:
                break;

            case CUR_BGN_FLD:
                break;

            case CUR_END_FLD:
                break;

            case CLR_FLD:
                break;

            case CLR_TO_END:
                break;

            case CANCEL_EDIT:
                break;

            case INSERT:
                break;

            case DELETE:
                break;

            case BS:
                break;

            default:
                break;
            }

        }

    free(buffer);
    return(fedit_status);
}

/*************** Paint All Or Part Of A Field With Trailing Fill **************/

static void dsply_fld(buffer, offset)
struct ICE_FIELD *buffer;
FLEN             offset;

{

}