home *** CD-ROM | disk | FTP | other *** search
- /*
- fnsint.c 5/2/87
-
- % sint_funcs
-
- Integer editing functions.
- These funcs edit ints in a string_like fashion.
- The field variable should be a int *.
-
- C-scape 3.2
- Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 4/06/88 jmd added call to sed_DoSpecial
- 5/12/88 jmd added calls to sed_GetScratchPad()
- 9/15/88 jmd removed vid_Cursor calls
- 9/17/88 jmd added global error msg strings for easy changing
- 9/17/88 jmd added std_ funcs
- 10/06/88 jmd added stdBigCur_fenter
- 10/09/88 jmd added SED_ABORT support
- 10/14/88 jdc added var_size element to field_funcs_struct
-
- 6/03/89 jmd added strclip to senter func
- 6/07/89 jmd added test for mouse code (later removed)
- 8/07/89 jmd now uses int fexit
- 10/17/89 jdc fixed filter (no extended ascii)
- 3/28/90 jmd ansi-fied
- */
-
- #include <stdio.h>
- #include <ctype.h>
- #include <string.h>
-
- #include "cscape.h"
- #include "ostdlib.h" /* for atoi() */
-
- #include "fnfunc.h" /* for field functions */
- #include "strdecl.h" /* for C-scape string functions */
- #include "scancode.h"
-
- OSTATIC sfilter_func (sint_filter);
-
- OGLOBAL field_funcs_struct sint_funcs = {
- stdBigCur_fenter,
- int_fexit,
- sint_fkey,
- sint_senter,
- sint_sexit,
- sizeof(int)
- };
-
- void sint_fkey(sed_type sed)
- /*
- Hands its work to StrCommon_fkey (fnstrcom.c)
- Passes a filter function (below) to decide which
- characters can be typed in.
- */
- {
- StrCommon_fkey(sed, sint_filter);
- }
-
- static boolean sint_filter(int key)
- /*
- Filter function for sint_funcs
- for use with StrCommon_fkey
- */
- {
- return(isprint(key) && (isdigit(key) || key == '-'));
- }
-
- void sint_senter(sed_type sed, int fieldno)
- /*
- Convert the native int into the record string.
- */
- {
- sprintf(sed_GetScratchPad(sed), "%d", *((int *) sed_GetVar(sed, fieldno)));
- strleft(sed_GetScratchPad(sed), sed_GetRecordLen(sed, fieldno));
- strclip(sed_GetScratchPad(sed));
- sed_SetRecord(sed, sed_GetScratchPad(sed), fieldno);
-
- std_senter(sed, fieldno);
- }
-
- void sint_sexit(sed_type sed, int fieldno)
- /*
- Convert the record string back into the native int.
- Remove commas from string first.
- */
- {
- if (sed_GetBaton(sed) != SED_ABORT) {
- strcpy(sed_GetScratchPad(sed), sed_GetRecord(sed, fieldno));
- strnocomma(sed_GetScratchPad(sed));
- *((int *) sed_GetVar(sed, fieldno)) = atoi(sed_GetScratchPad(sed));
- }
- }
-
-