Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TSDWIN: Clipper 5.0 Interface Library - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

 twMemoEdit( wT, wL, wB, wR, cMemo, cTitle, cFooters,;
             mUdf, ActionKeys, wColor, wSType, wFType,;
             wFColor, lMsgs, lWrap, lEditMode, nLineLength,;
             nTabSize, nTBufRow, nTBufColumn,;
             nWinRow, nWinColumn, lScBar, lWindow )
FUNCTION twMemoEdit( wT, wL, wB, wR, cMemo, cTitle, cFooters, mUdf, ActionKeys, ;
                    wColor, wSType, wFType, wFColor, lMsgs, lWrap, lEditMode, nLineLength, ;
                    nTabSize, nTBufRow, nTBufColumn, ;
                    nWinRow, nWinColumn, lScBar, lWindow )
 ----------------------------------------------------------------------------
     Display a MEMOEDIT() in a window and provide an optional UDF to
     govern its action.

       MouseSupport:

     twMemoEdit() offers moused hot spots like the other TSDWIN moused 
     MAXI functions.

     The scroll bars, if displayed are mouse hot spots. The arrows 
     operate as follows:

     Vertical Scroll Bar:

       Direction Arrows:

           Left Button: Up or Down one line.
          Right Button: Page Up or Down.
          Both Buttons: Top or Bottom of memo string.

       Shaded Area: Move to Relative position in string.

     Horizontal Scroll Bar: Left Button

       Direction Arrows:

           Left Button: Left  or Right one character.
          Right Button: Start or End of line.

       Shaded Area: Move to Relative Column
                    Position in string.

     The mouse support in twMemoEdit() is accomplished in the user 
     defined function. TSDWIN includes a default UDF:

     FUNCTION twMemoUdf( nMode, nLine, nColumn )
     LOCAL  RetVal, aMsg := {}
     LOCAL GetVar := "Y", nKey, nMethNo

     IF ( nMode = ME_INIT )
         nLength := nRight - nLeft - 1
         nNumLines  := MLCOUNT( cNewMemo, nLenLine,, .T. )
         IF lVBar
             twScBarUpdate( aVBar, nCurrent, nNumLines, .T. )
         ENDIF
         IF lHBar
             twScBarUpdate( aHBar, nColPos, nLenLine, .T. )
         ENDIF
         RetVal := ME_DEFAULT

     ELSEIF ( nMode == ME_IDLE )
         MemoWait()  // Moused Key or Button Input Handler.
         nKey := NEXTKEY() //LASTKEY()
         DO CASE
             CASE nKey == K_DOWN
                 nCurrent += IIF( nCurrent < nNumLines, 1, 0 )
             CASE nKey == K_UP
                 nCurrent += IIF( nCurrent > 1, ;
                                  -1, 0 )
             CASE nKey == K_PGUP
                 nCurrent += IIF( nCurrent >= 1, ;
                                  -nBottom + nTop, 0 )
             CASE nKey == K_PGDN
                 nCurrent += IIF( nCurrent <= nNumLines, ;
                                  nBottom - nTop, 0 )
             CASE nKey == K_CTRL_PGUP
                 nCurrent := 1
             CASE nKey == K_CTRL_PGDN
                 nCurrent := nNumLines
             CASE nKey == K_LEFT
                 nColPos += IIF( nColPos > 1, -1, 0 )
             CASE nKey == K_RIGHT
                 nColPos += IIF( nColPos < nLenLine, 1, 0 )
             CASE nKey == K_END
                 nColPos := nLenLine
             CASE nKey == K_HOME
                 nColPos := 1
             OTHERWISE
         ENDCASE
         nNumLines := MLCOUNT( cNewMemo, nLenLine,, .T. )
         IF lVBar
             twScBarUpdate( aVBar, nCurrent, nNumLines, .T. )
         ENDIF
         IF lHBar
             twScBarUpdate( aHBar, nColPos, nLenLine, .T. )
         ENDIF
     ELSE
         nKey := LASTKEY()
         IF ExtraKeys != NIL
             nMethNo := ASCAN( ExtraKeys, { |ra| nKey == ra[ 1 ] } )
             IF nMethNo != 0
                 EVAL( ExtraKeys[ nMethNo, 2 ] )
             ENDIF
         ELSE
             IF nKey = K_ESC //.AND. ( nMode = ME_UNKEYX )
                 ??CHR(7)
                 SET CONFIRM ON
                 GetVar := twInquire( "Retain Changes (Y/N)?",, GetVar )
                 IF UPPER( GetVar ) == "Y"
                     RetVal := ME_CTRLW
                 ELSE
                     RetVal := ME_DEFAULT
                 ENDIF

             ELSEIF nKey = K_F1 .OR. nKey = K_ALT_F1
                 // help
                 // HelpScreen Here.
                 RetVal := ME_DEFAULT

             ELSEIF nKey = K_F2
                 // save and exit
                 RetVal := ME_SAVE

             ELSEIF nKey = K_F3
                 // reformat
                 RetVal := ME_CTRLB

             ELSEIF nKey = K_INS
                 // toggle insert mode
                 RetVal := ME_CTRLV

             ELSEIF nKey = K_F4
                 // toggle word wrap
                 Wrap_tog++
                 IF MsgOK
                     @ _twBottom(), twCol( 2 ) SAY "WRAP " + ;
                        IIF( INT(Wrap_Tog/2) = Wrap_Tog/2, "ON ","OFF" ) ;
                        COLOR twUnsClr(SETCOLOR()) 
                  ENDIF 
                  RetVal := ME_TOGGLEWRAP
             ELSE
                 RetVal := ME_DEFAULT
             ENDIF

         ENDIF

     ENDIF
     RETURN RetVal

       Arguments:

     wT, wL
     wB, wR      - 'N' Screen Coordinates

     cMemo       - 'C' Memo string to be edited.

     cTitle      - 'C' Optional header title for the edit window.

     cFooters    - 'C' Optional footer for the edit window.

     mUdf        - 'C' Optional User Defined Function to execute on
                       keypresses.

                          Default Key Assignments:

                          F1   - Display Help
                          F2   - Save Memo and Exit
                          F3   - Re-Format Paragraph
                          F4   - Toggle Word Wrap
                          INS  - Toggle Insert Mode
                          ESC  - Exit w/o Save

     ActionKeys  - 'A' You may pass an array of keys and code to
                       execute inside the default UDF, but it is
                       probably simpler just ti pass your own UDF.
                       However, if you choose to use this feature, it
                       operates the same way as in twArBrowse(),
                       twDBrowse() and the Alert Class functions.

     wColor      - 'C' Optional window color. Defaults to SETCOLOR().

     wSType       - 'N' TSDWIN Shadow Type. Defaults to no shadow.

     wFType       - 'N' TSDWIN Frame Type. Default to single line
                       border.

     wFColor      - 'C' Optional frame colour to indicate the active
                       window.

     lMsgs       - 'L' If true, twMemoEdit() uses twInfoLine() to
                       display a list of default keys in the area
                       defined for Area Messages.

                 *** These are from Clipper ***

     lWrap       - 'L' Word wrap toggle.

     lEditMode   - 'L' Logical to allow/disallow editing.

     nLineLength - 'N' Line length. Defaults to the width of the
                       window, less four for the border.

     nTabSize    - 'N' Defaults to insert 4 spaces when TAB key is
                       pressed.

     nTBufRow    - 'N' Position within the text buffer to open the
                       display.

     nTBufColum  - 'N' Position within the text buffer to open the
                       display.

     nnWinRow    - 'N' Position within the display window to open the
                       display.

     nWinColumn  - 'N' Position within the display window

                 *** The above are from Clipper ***

     lScBar      - 'L' Logical for Scroll Bars. Defaults to .F. If 
                       lSCBar is TRUE, the horizontal scroll bar is 
                       displayed only if the linelength is greater than 
                       the display width.

     lWindow     - 'L' Logical for display in a TSDWIN window.

       Return:

     Edited memo string.

       Example:

     FUNCTION main()
     LOCAL wT := 3, wL := 10, wB := 15, wR := 70
     LOCAL cTitle := "Title String"
     LOCAL cFooters := "Footer String"
     LOCAL cMemo := "Printer Not Ready! You can try it if"+;
                     " you want but it will not work."+;
                     " Oh Well... I knew you had to go ahead and "+;
                     "see for yourself. That really"+;
                     " is a pity. Lack of trust will defeat us all, "+;
                     "then that will be it! "+;
                     "I wonder where it will all end. Probably at my"+;
                     "own crucifiction!"+;
                     " Whatever became of good old deceit and "+;
                     "corporate skullduggery?"+;
                     " I guess Santa ain't coming to town yet, eh?"

     SET SCOREBOARD OFF
     SET CURSOR OFF
     SETCOLOR( "n/bg" )

     twOpen()
     SETCOLOR( "w+/b,gr+/r,,,n/w" )

     lEditMode  := .T.
     nWinColumn := NIL
     lScBar     := .T.
     lWindow    := .T.
     nLineLength := 100
     // other variables set to NIL.

     cMemo := twMemoEdit( wT, wL, wB, wR, cMemo, cTitle, cFooters, mUdf, ActionKeys, ;
                          wColor, wSType, wFType, wFColor, lMsgs, lWrap, lEditMode, nLineLength, ;
                          nTabSize, nTBufRow, nTBufColumn, ;
                          nWinRow, nWinColumn, lScBar, lWindow )

     RETURN NIL

See Also: twMEHotSpot() twMEMouseLine() twMemoView()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson