home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c185 / 1.ddi / FUNCS.EXE / CSCAPE / SOURCE / FNSTRING.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-07  |  2.3 KB  |  110 lines

  1. /*
  2.     fnstring.c  10/27/86
  3.  
  4.     % string_funcs
  5.  
  6.     String editting functions.
  7.     Supports insert mode (with big cursor).
  8.     The field variable should be a char *.
  9.  
  10.     C-scape 3.1
  11.     Copyright (c) 1986, 1987, 1988 by Oakland Group, Inc.
  12.     ALL RIGHTS RESERVED.
  13.  
  14.     Revision History:
  15.     -----------------
  16.      4/06/88 jmd     added call to sed_DoSpecial
  17.      6/23/88 jmd     added casting to char * in senter
  18.      9/15/88 jmd     removed vid_Cursor calls
  19.      9/17/88 jmd     added validation
  20.      9/17/88 jmd    added global error msg strings for easy changing
  21.      9/17/88 jmd     added std_ funcs
  22.     10/09/88 jmd     added SED_ABORT support
  23.     10/12/88 jmd     added SED_FIRST support
  24.     10/14/88 jdc    added var_size element to field_funcs_struct
  25.  
  26.      6/07/89 jmd    added test for mouse code (later removed)
  27. */
  28.  
  29. #include <stdio.h>
  30. #include <string.h>
  31. #include <ctype.h>
  32.  
  33. #include "cscape.h"
  34. #include "fnfunc.h"            /* for field functions */
  35. #include "scancode.h"
  36.  
  37. boolean string_filter(_arg1(int));
  38.  
  39. OGLOBAL field_funcs_struct string_funcs = {
  40.     stdBigCur_fenter,
  41.     string_fexit,
  42.     string_fkey,
  43.     string_senter,
  44.     string_sexit,
  45.     VAR_STRING
  46. };
  47.  
  48. boolean string_fexit(sed)
  49.     sed_type sed;
  50. {
  51.     if (sed_GetBaton(sed) != SED_ABORT) {
  52.         if (!valid_String(sed_GetCurrRecord(sed), (char *) sed_GetCurrFieldData(sed, 1)) ) {
  53.             tone();
  54.             sed_BorderPrompt(sed, fnstring_errmsg);
  55.             /* wait for a keystroke */
  56.             while (!kb_Check())
  57.                 ;
  58.             sed_BorderPrompt(sed, sed_GetCurrFieldData(sed, 0));
  59.             return(FALSE);
  60.         }
  61.     }
  62.  
  63.     return(std_fexit(sed));
  64. }
  65.  
  66. void string_fkey(sed)
  67.     sed_type sed;
  68. /*
  69.     Hands its work to StrCommon_fkey (fnstrcom.c)
  70.     Passes a filter function (below) to decide which
  71.     characters can be typed in.
  72. */
  73. {
  74.     StrCommon_fkey(sed, string_filter);
  75. }
  76.  
  77. boolean string_filter(key)
  78.     int key;
  79. /*
  80.     Filter function for string_funcs
  81.     for use with StrCommon_fkey
  82. */
  83. {
  84.     return(isprint(key));
  85. }
  86.  
  87. void string_senter(sed, fieldno)
  88.     sed_type sed;
  89.     int fieldno;
  90. /*
  91.     Copy the native string into the record string.
  92. */
  93. {
  94.     sed_SetRecord(sed, (char *) sed_GetVar(sed, fieldno), fieldno);
  95.  
  96.     std_senter(sed, fieldno);
  97. }
  98.  
  99. void string_sexit(sed, fieldno)
  100.     sed_type sed;
  101.     int fieldno;
  102. /*
  103.     Copy the record string back into the native string.
  104. */
  105. {
  106.     if (sed_GetBaton(sed) != SED_ABORT) {
  107.         strcpy((char *) sed_GetVar(sed, fieldno), sed_GetRecord(sed, fieldno));
  108.     }
  109. }
  110.