home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 26.16 Alternate GetApplyKey() function for Step Entry
- Author: Greg Lief
- Excerpted from Grumpfish Library
- Copyright (c) 1991 Greg Lief
- */
-
- //───── NOTE: must compile with the /N option!
-
- #include "inkey.ch"
- #include "getexit.ch"
-
- procedure gkeystep(get, key)
- local cKey
- local oldvalue
- local bKeyBlock
-
- //───── check for SET KEY first
- if bKeyBlock != NIL
- GetDoSetKey(bKeyBlock, get)
- else
- do case
-
- case ( key == K_UP )
- get:exitState := GE_UP
-
- case ( key == K_SH_TAB )
- get:exitState := GE_UP
-
- case ( key == K_DOWN )
- get:exitState := GE_DOWN
-
- case ( key == K_TAB )
- get:exitState := GE_DOWN
-
- case ( key == K_ENTER )
- get:exitState := GE_ENTER
-
- case ( key == K_ESC )
- if ( Set(_SET_ESCAPE) )
- get:undo()
- get:exitState := GE_ESCAPE
- endif
-
- case ( key == K_PGUP )
- get:exitState := GE_WRITE
-
- case ( key == K_PGDN )
- get:exitState := GE_WRITE
-
- case ( key == K_CTRL_HOME )
- get:exitState := GE_TOP
-
- // both ^W and ^End terminate the READ (the default)
- case (key == K_CTRL_W)
- get:exitState := GE_WRITE
-
- case (key == K_INS)
- Set( _SET_INSERT, ! Set(_SET_INSERT) )
- setcursor( if(set(_SET_INSERT), 3, 1) )
-
- case (key == K_CTRL_U)
- get:Undo()
-
- case (key == K_HOME)
- get:Home()
-
- case (key == K_END)
- get:End()
-
- case (key == K_RIGHT)
- get:Right()
-
- case (key == K_LEFT)
- get:Left()
-
- case (key == K_CTRL_RIGHT)
- get:WordRight()
-
- case (key == K_CTRL_LEFT)
- get:WordLeft()
-
- case (key == K_BS)
- get:BackSpace()
-
- case (key == K_DEL)
- get:Delete()
-
- case (key == K_CTRL_T)
- get:DelWordRight()
-
- case (key == K_CTRL_Y)
- get:DelEnd()
-
- case (key == K_CTRL_BS)
- get:DelWordLeft()
-
- otherwise
-
- if (key >= 32 .and. key <= 255)
- cKey := chr(key)
- //───── test for step entry on numerics and dates
- if cKey $ '-+' .and. get:type $ "ND"
- oldvalue := get:varGet()
- if cKey == "-"
- get:varPut(get:varGet() - 1)
- else
- get:varPut(get:varGet() + 1)
- endif
- if get:postBlock != NIL .and. ! eval(get:postBlock, get)
- get:varPut(oldvalue)
- endif
- get:updateBuffer()
- else
- if (get:type == "N" .and. (cKey == "." .or. cKey == ","))
- get:ToDecPos()
- else
- if ( Set(_SET_INSERT) )
- get:Insert(cKey)
- else
- get:Overstrike(cKey)
- endif
- if (get:typeOut .and. !Set(_SET_CONFIRM) )
- if ( Set(_SET_BELL) )
- ?? Chr(7)
- endif
- get:exitState := GE_ENTER
- endif
- endif
- endif
- endif
- endcase
- endif
- return
-