home *** CD-ROM | disk | FTP | other *** search
-
- !═════════════════════════════════════════════════════════════════════════
- !
- ! %%keyword%% '%n'
- ! 'ME_BLOCK.CLA' - Block Operations for MEMOEDIT
- !
- ! %%keyword%% '%v'
- ! Revision Number: '1'
- ! %%keyword%% '%d'
- ! Revision Date : '15-Feb-92'
- !
- ! Copyright : Bobcat Systems (c) 1992
- ! Author : Robert J. Pupazzoni
- ! CIS:[70441,204]
- !
- ! Compiler : Clarion Professional Developer v. 2.1, Batch 2105
- !
- !
- ! DESCRIPTION
- !
- ! This module contains all functions related to block operations.
- !
- !═════════════════════════════════════════════════════════════════════════
-
- ME_Block MEMBER()
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Copy Marked Text in Edit Buffer to Hold Area
- ! ═════════════════════════════════════════════════════════════════════════
- Copy_Hold PROCEDURE( tHold, tTable )
-
- ! Parameters:
- tHold EXTERNAL,TABLE ! Hold area
- tTable EXTERNAL,TABLE ! Edit buffer
-
- ! Locals:
- ilIndex LONG ! Loop index
-
- CODE
- IF NOT MED:ilMarkBegRow THEN RETURN. ! Quit if nothing is marked
-
- FREE(tHold) ! Clear Hold area
-
- GET(tTable, MED:ilMarkBegRow) ! Get first marked line
- IF MED:ilMarkBegRow = MED:ilMarkEndRow ! If only one line marked
- tHold = SUB(tTable, MED:ibMarkBegCol, MED:ibMarkEndCol-MED:ibMarkBegCol+1)
- ELSE ! Else
- tHold = SUB(tTable, MED:ibMarkBegCol, 255) ! Get mark to EOL
- . ! Endif
- ADD(tHold) ! Copy to Hold area
-
- ! Loop thru fully marked lines
- LOOP ilIndex = MED:ilMarkBegRow+1 TO MED:ilMarkEndRow-1
- GET(tTable, ilIndex) ! Get line
- tHold = tTable ! Copy to Hold area
- ADD(tHold) !
- . ! End loop
-
- IF MED:ilMarkBegRow <> MED:ilMarkEndRow ! If more than one line marked
- GET(tTable, MED:ilMarkEndRow) ! Get last marked line
- tHold = SUB(tTable, 1, MED:ibMarkEndCol) ! Isolate marked section
- ADD(tHold) ! Copy to Hold area
- . ! Endif
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Paste Hold Area into Edit Buffer at Passed Position
- ! ═════════════════════════════════════════════════════════════════════════
- Paste_Hold PROCEDURE( tHold, tTable, ilTblNdx, ibCol )
-
- ! Parameters:
- tHold EXTERNAL,TABLE ! Hold area
- tTable EXTERNAL,TABLE ! Edit buffer
- ilTblNdx LONG ! Line index to paste into
- ibCol BYTE ! Column to paste into
-
- ! Locals:
- sTemp STRING(255) ! Temporary line buffer
- ilHoldNdx LONG ! Hold index
-
- CODE
- IF RECORDS(tHold) = 0 THEN RETURN. ! Return if Hold is empty
-
- GET(tHold, 1) ! Get first Hold line
- GET(tTable, ilTblNdx) ! Get line from edit buffer
- sTemp = SUB(tTable, ibCol, 255) ! Save trailing portion
- tTable = SUB(tTable, 1, ibCol-1) & tHold ! Insert Hold at paste column
- PUT(tTable) ! Update edit buffer
-
- LOOP ilHoldNdx = 2 TO RECORDS(tHold)-1 ! Loop for subsequent lines
- GET(tHold, ilHoldNdx) ! Get Hold line
- ilTblNdx += 1 ! Paste into edit buffer
- tTable = tHold !
- ADD(tTable, ilTblNdx) !
- . ! End loop
-
- IF RECORDS(tHold) = 1 ! If only one line in Hold
- GET(tTable, ilTblNdx) ! Get displayed line
- tTable = CLIP(tTable) & sTemp ! Join line and saved sect.
- PUT(tTable) ! Update edit buffer
- ELSE ! Else
- GET(tHold, RECORDS(tHold)) ! Get last Hold line
- ilTblNdx += 1 ! Increment table index
- tTable = CLIP(tHold) & sTemp ! Join Hold and saved sect.
- ADD(tTable, ilTblNdx) ! Add to edit buffer
- . ! End if
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Cut Currently Marked Block
- ! ═════════════════════════════════════════════════════════════════════════
- Cut_Block PROCEDURE( tTable )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
-
- ! Parameters:
- sTemp STRING(255) ! Temporary line buffer
- ilIndex LONG ! Loop index
-
- CODE
- GET(tTable, MED:ilMarkEndRow) ! Get last marked line
- sTemp = SUB(tTable, MED:ibMarkEndCol+1, 255) ! Isolate unmarked section
-
- GET(tTable, MED:ilMarkBegRow) ! Get first marked line
- ! Join unmarked sections
- tTable = SUB(tTable, 1, MED:ibMarkBegCol-1) & sTemp
- PUT(tTable) ! Update edit buffer
-
- ! Loop for each marked row
- LOOP ilIndex = MED:ilMarkBegRow+1 TO MED:ilMarkEndRow
- GET(tTable, MED:ilMarkBegRow+1) ! Get line
- IF ERRORCODE() THEN CYCLE. ! Ignore if not found
- DELETE(tTable) ! Delete line
- . ! End loop
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Toggle Block Marking Mode On/Off
- ! ═════════════════════════════════════════════════════════════════════════
- Block_Mark PROCEDURE( ilTblNdx, ibCol )
-
- ! Parameters:
- ilTblNdx LONG ! Line index
- ibCol BYTE ! Cursor column
-
- CODE
- IF NOT MED:bbMarking ! If not in marking mode
- MED:ilMarkBegRow = ilTblNdx ! Set block start
- MED:ibMarkBegCol = ibCol !
- MED:ilMarkEndRow = MED:ilMarkBegRow ! Set block end
- MED:ibMarkEndCol = MED:ibMarkBegCol !
- MED:bbMarking = 1 ! Turn marking mode on
- ELSE ! Else
- MED:bbMarking = 0 ! Turn marking mode off
- . ! Endif
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Unmark Marked Block
- ! ═════════════════════════════════════════════════════════════════════════
- Block_Unmark PROCEDURE( tTable, ilRowTop )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilRowTop LONG ! Top row index
-
- CODE
- MED:bbMarking = 0 ! Turn marking off
- MED:ilMarkBegRow = 0 ! Clear mark locations
- MED:ibMarkBegCol = 0 !
- MED:ilMarkEndRow = 0 !
- MED:ibMarkEndCol = 0 !
- Show_Page(tTable, ilRowTop, 1, MED:ibRows) ! Refresh screen
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Delete Marked Block
- ! ═════════════════════════════════════════════════════════════════════════
- Block_Delete PROCEDURE( tTable, ilRowTop, ibRow, ibCol )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilRowTop LONG ! Top row index
- ibRow EXTERNAL ! Cursor row
- ibCol EXTERNAL ! Cursor column
-
- CODE
- IF NOT MED:ilMarkBegRow THEN RETURN. ! Return if nothing marked
-
- MED:bbModified = 1 ! Set modified flag
- Cut_Block(tTable) ! Delete marked block
- IF INRANGE(MED:ilMarkBegRow, ilRowTop+1, ilRowTop+MED:ibRows)
- ibRow = MED:ilMarkBegRow - ilRowTop ! Update cursor position
- ibCol = MED:ibMarkBegCol !
- . !
- Block_Unmark(tTable, ilRowTop) ! Unmark the block
- Reformat(tTable, ilRowTop+ibRow) ! Reformat paragraph
- Show_Page(tTable, ilRowTop, ibRow, MED:ibRows) ! Display rest of page
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Copy Marked Block to Cursor Location
- ! ═════════════════════════════════════════════════════════════════════════
- Block_Copy PROCEDURE( tHold, tTable, ilRowTop, ibRow, ibCol )
-
- ! Parameters:
- tHold EXTERNAL,TABLE ! Hold area
- tTable EXTERNAL,TABLE ! Edit buffer
- ilRowTop LONG ! Top row index
- ibRow EXTERNAL ! Cursor row
- ibCol EXTERNAL ! Cursor column
-
- ! Locals:
- ilAbsTarget LONG ! Temporaries used in block
- ilAbsMrkBeg LONG ! operations
- ilAbsMrkEnd LONG !
-
- CODE
- IF NOT MED:ilMarkBegRow THEN RETURN. ! Return if nothing marked
-
- ilAbsTarget = 255*(ilRowTop+ibRow) + ibCol ! Calculate absolute locations
- ilAbsMrkBeg = 255*MED:ilMarkBegRow + MED:ibMarkBegCol
- ilAbsMrkEnd = 255*MED:ilMarkEndRow + MED:ibMarkEndCol
-
- IF INRANGE(ilAbsTarget,ilAbsMrkBeg,ilAbsMrkEnd)! If target in middle of block
- ! Not implemented ! Can't do that!
- RETURN ! Exit
- . ! Endif
-
- MED:bbModified = 1 ! Set modified flag
- Copy_Hold(tHold, tTable) ! Copy marked block to hold
- Paste_Hold(tHold, tTable, ilRowTop+ibRow, ibCol) ! Copy hold to cursor pos.
- Block_Unmark(tTable, ilRowTop) ! Unmark the block
- Reformat(tTable, ilRowTop+ibRow) ! Reformat paragraph
- Show_Page(tTable, ilRowTop, ibRow, MED:ibRows) ! Display rest of page
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Move Marked Block to Cursor Location
- ! ═════════════════════════════════════════════════════════════════════════
- Block_Move PROCEDURE( tHold, tTable, ilRowTop, ibRow, ibCol )
-
- ! Parameters:
- tHold EXTERNAL,TABLE ! Hold area
- tTable EXTERNAL,TABLE ! Edit buffer
- ilRowTop LONG ! Top row index
- ibRow EXTERNAL ! Cursor row
- ibCol EXTERNAL ! Cursor column
-
- ! Locals:
- ilAbsTarget LONG ! Temporaries used in block
- ilAbsMrkBeg LONG ! operations
- ilAbsMrkEnd LONG !
-
- CODE
- IF NOT MED:ilMarkBegRow THEN RETURN. ! Return if nothing marked
-
- ilAbsTarget = 255*(ilRowTop+ibRow) + ibCol ! Calculate absolute locations
- ilAbsMrkBeg = 255*MED:ilMarkBegRow + MED:ibMarkBegCol
- ilAbsMrkEnd = 255*MED:ilMarkEndRow + MED:ibMarkEndCol
-
- IF ilAbsTarget < ilAbsMrkBeg ! If target before block
- MED:bbModified = 1 ! Set modified flag
- Copy_Hold(tHold, tTable) ! Copy marked block to hold
- Cut_Block(tTable) ! Delete the block
- ! Copy hold to cursor pos.
- Paste_Hold(tHold, tTable, ilRowTop+ibRow, ibCol)
- Block_Unmark(tTable, ilRowTop) ! Unmark the block
- ELSIF ilAbsTarget > ilAbsMrkEnd ! Else if target after block
- MED:bbModified = 1 ! Set modified flag
- Copy_Hold(tHold, tTable) ! Copy marked block to hold
- ! Copy hold to cursor pos.
- Paste_Hold(tHold, tTable, ilRowTop+ibRow, ibCol)
- Cut_Block(tTable) ! Delete the block
- Block_Unmark(tTable, ilRowTop) ! Unmark the block
- ELSE ! Else target is inside block
- ! Not implemented ! Can't do that!
- . ! Endif
- RETURN !
-
-