home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP26.EXE / CHP2616.PRG < prev   
Encoding:
Text File  |  1991-04-30  |  3.2 KB  |  135 lines

  1. /*
  2.    Listing 26.16 Alternate GetApplyKey() function for Step Entry
  3.    Author: Greg Lief
  4.    Excerpted from Grumpfish Library
  5.    Copyright (c) 1991 Greg Lief
  6. */
  7.  
  8. //───── NOTE: must compile with the /N option!
  9.  
  10. #include "inkey.ch"
  11. #include "getexit.ch"
  12.  
  13. procedure gkeystep(get, key)
  14. local cKey
  15. local oldvalue
  16. local bKeyBlock
  17.  
  18. //───── check for SET KEY first
  19. if bKeyBlock != NIL
  20.    GetDoSetKey(bKeyBlock, get)
  21. else
  22.    do case
  23.  
  24.       case ( key == K_UP )
  25.          get:exitState := GE_UP
  26.  
  27.       case ( key == K_SH_TAB )
  28.          get:exitState := GE_UP
  29.  
  30.       case ( key == K_DOWN )
  31.          get:exitState := GE_DOWN
  32.  
  33.       case ( key == K_TAB )
  34.          get:exitState := GE_DOWN
  35.  
  36.       case ( key == K_ENTER )
  37.          get:exitState := GE_ENTER
  38.  
  39.       case ( key == K_ESC )
  40.          if ( Set(_SET_ESCAPE) )
  41.             get:undo()
  42.             get:exitState := GE_ESCAPE
  43.          endif
  44.  
  45.       case ( key == K_PGUP )
  46.          get:exitState := GE_WRITE
  47.  
  48.       case ( key == K_PGDN )
  49.          get:exitState := GE_WRITE
  50.  
  51.       case ( key == K_CTRL_HOME )
  52.          get:exitState := GE_TOP
  53.  
  54.       // both ^W and ^End terminate the READ (the default)
  55.       case (key == K_CTRL_W)
  56.          get:exitState := GE_WRITE
  57.  
  58.       case (key == K_INS)
  59.          Set( _SET_INSERT, ! Set(_SET_INSERT) )
  60.          setcursor( if(set(_SET_INSERT), 3, 1) )
  61.  
  62.       case (key == K_CTRL_U)
  63.          get:Undo()
  64.  
  65.       case (key == K_HOME)
  66.          get:Home()
  67.  
  68.       case (key == K_END)
  69.          get:End()
  70.  
  71.       case (key == K_RIGHT)
  72.          get:Right()
  73.  
  74.       case (key == K_LEFT)
  75.          get:Left()
  76.  
  77.       case (key == K_CTRL_RIGHT)
  78.          get:WordRight()
  79.  
  80.       case (key == K_CTRL_LEFT)
  81.          get:WordLeft()
  82.  
  83.       case (key == K_BS)
  84.          get:BackSpace()
  85.  
  86.       case (key == K_DEL)
  87.          get:Delete()
  88.  
  89.       case (key == K_CTRL_T)
  90.          get:DelWordRight()
  91.  
  92.       case (key == K_CTRL_Y)
  93.          get:DelEnd()
  94.  
  95.       case (key == K_CTRL_BS)
  96.          get:DelWordLeft()
  97.  
  98.       otherwise
  99.  
  100.          if (key >= 32 .and. key <= 255)
  101.             cKey := chr(key)
  102.             //───── test for step entry on numerics and dates
  103.             if cKey $ '-+' .and. get:type $ "ND"
  104.                oldvalue := get:varGet()
  105.                if cKey == "-"
  106.                   get:varPut(get:varGet() - 1)
  107.                else
  108.                   get:varPut(get:varGet() + 1)
  109.                endif
  110.                if get:postBlock != NIL .and. ! eval(get:postBlock, get)
  111.                   get:varPut(oldvalue)
  112.                endif
  113.                get:updateBuffer()
  114.             else
  115.                if (get:type == "N" .and. (cKey == "." .or. cKey == ","))
  116.                   get:ToDecPos()
  117.                else
  118.                   if ( Set(_SET_INSERT) )
  119.                      get:Insert(cKey)
  120.                   else
  121.                      get:Overstrike(cKey)
  122.                   endif
  123.                   if (get:typeOut .and. !Set(_SET_CONFIRM) )
  124.                      if ( Set(_SET_BELL) )
  125.                         ?? Chr(7)
  126.                      endif
  127.                      get:exitState := GE_ENTER
  128.                   endif
  129.                endif
  130.             endif
  131.          endif
  132.    endcase
  133. endif
  134. return
  135.