home *** CD-ROM | disk | FTP | other *** search
-
- !═════════════════════════════════════════════════════════════════════════
- !
- ! %%keyword%% '%n'
- ! 'ME_CORE.CLA' - Core Editing functions for MEMOEDIT
- !
- ! %%keyword%% '%v'
- ! Revision Number: '2'
- ! %%keyword%% '%d'
- ! Revision Date : '21-Mar-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 the core editing functions which change the
- ! contents of the edit buffer.
- !
- !═════════════════════════════════════════════════════════════════════════
-
- ME_Core MEMBER()
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Check for Buffer Full
- ! ═════════════════════════════════════════════════════════════════════════
- Buffer_Full FUNCTION( tTable )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
-
- ! Return:
- bbRetVal BYTE ! Return flag
-
- ! Screen:
- wBufferFull SCREEN WINDOW(5,33),AT(12,28),HUE(15,4)
- ROW(1,1) STRING('╔═{31}╗')
- ROW(2,1) REPEAT(3);STRING('║<0{31}>║') .
- ROW(5,1) STRING('╚═{31}╝')
- ROW(3,4) STRING('No more room in memo field!')
- .
-
- CODE
- bbRetVal = 0 ! Assume enough room
- IF RECORDS(tTable) >= MED:ilMemoRows ! If max lines exceeded
- OPEN(wBufferFull) ! Notify user
- BEEP; ASK !
- CLOSE(wBufferFull) !
- bbRetVal = 1 ! Set return flag
- . ! Endif
- RETURN( bbRetVal ) !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Insert Text String
- ! ═════════════════════════════════════════════════════════════════════════
- Insert_Text PROCEDURE( tTable, ilRowTop, ibRow, ibCol, sText, bbInsert )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilRowTop EXTERNAL ! Top row index
- ibRow EXTERNAL ! Cursor row
- ibCol EXTERNAL ! Cursor column
- sText STRING(255) ! Text to insert
- bbInsert BYTE ! Insert mode flag
-
- CODE
- GET(tTable, ilRowTop+ibRow) ! Get current line
- IF NOT OMITTED(6) ! If insert mode passed
- IF NOT bbInsert ! If not in insert mode
- tTable = Str_Delete(tTable, ibCol, 1) ! Delete cursor char
- . . ! Endif
- tTable = Str_Insert(CLIP(sText), tTable, ibCol)! Insert string
- ibCol += Greater_Of(1, LEN(CLIP(sText))) ! Adjust cursor column
- PUT(tTable) ! Update edit buffer
-
- IF ibCol > MED:ibWrapCol ! If past wrap column
- IF KEYCODE() = VAL(' ') ! If keystroke was a space
- ibCol = 1 ! Go to first column
- ELSE ! Else wordwrap
- ibCol = Word_Wrap(tTable, ilRowTop+ibRow, ibCol)
- . ! Endif
- Show_Line(tTable, ilRowTop+ibRow, ibRow) ! Redisplay line
- IF RECORDS(tTable) = ilRowTop+ibRow ! If this is the last line
- CLEAR(tTable); ADD(tTable) ! Add a blank line
- . ! Endif
- Move_Down(tTable, ilRowTop, ibRow) ! Move down
- Reformat(tTable, ilRowTop+ibRow) ! Reformat paragraph
- Show_Page(tTable, ilRowTop, ibRow, MED:ibRows)! Display rest of page
- ELSIF LEN(CLIP(tTable)) > MED:ibWrapCol ! Else if too long
- Reformat(tTable, ilRowTop+ibRow) ! Reformat paragraph
- Show_Page(tTable, ilRowTop, ibRow, MED:ibRows)! Display rest of page
- ELSE ! Else
- Show_Line(tTable, ilRowTop+ibRow, ibRow) ! Just redisplay the line
- . ! Endif
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Insert 'Hard' Carriage Return
- ! ═════════════════════════════════════════════════════════════════════════
- Insert_HCR PROCEDURE( tTable, ilRowTop, ibRow, ibCol )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilRowTop LONG ! Top row index
- ibRow BYTE ! Current row
- ibCol BYTE ! Current column
-
- CODE
- tTable = Str_Insert(eHCRCode, tTable, ibCol) ! Insert format code
- PUT(tTable) ! Update edit buffer
- Split_Line(tTable, ilRowTop+ibRow, ibCol+1) ! Split current line
- Show_Line(tTable, ilRowTop+ibRow, ibRow) ! Display line
- Reformat(tTable, ilRowTop+ibRow+1) ! Reformat paragrpah
- Show_Page(tTable, ilRowTop, ibRow+1, MED:ibRows)
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Delete a Character
- ! ═════════════════════════════════════════════════════════════════════════
- Delete_Char PROCEDURE( tTable, ilRowTop, ibRow, ibCol )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilRowTop LONG ! Top row index
- ibRow BYTE ! Current row
- ibCol BYTE ! Current column
-
- CODE
- IF ibCol > LEN(CLIP(tTable)) ! If EOL
- Join_Line(tTable, ilRowTop+ibRow) ! Join next line
- ELSE ! Else
- tTable = Str_Delete(tTable, ibCol, 1) ! Delete cursor character
- PUT(tTable) ! Update edit buffer
- . ! Endif
- Reformat(tTable, ilRowTop+ibRow) ! Reformat paragrpah
- Show_Page(tTable, ilRowTop, ibRow, MED:ibRows) ! Display rest of page
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Delete to End of Line
- ! ═════════════════════════════════════════════════════════════════════════
- Delete_EOL PROCEDURE( tTable, ilRowTop, ibRow, ibCol )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilRowTop LONG ! Top row index
- ibRow BYTE ! Current row
- ibCol BYTE ! Current column
-
- ! Locals:
- sTemp STRING(255) ! Temporary line buffer
-
- CODE
- sTemp = tTable ! Save current line
- tTable = SUB(tTable, 1, ibCol-1) ! Delete from cursor
- IF INSTRING(eHCRCode, sTemp, 1) ! If line contained hard CR
- tTable = CLIP(tTable) & eHCRCode ! Put hard CR back in
- . ! Endif
- PUT(tTable) ! Update edit buffer
- Reformat(tTable, ilRowTop+ibRow) ! Reformat paragrpah
- Show_Page(tTable, ilRowTop, ibRow, MED:ibRows) ! Display rest of page
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Reformat Paragraph
- ! ═════════════════════════════════════════════════════════════════════════
- Reformat PROCEDURE( tTable, ilRowStart )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilRowStart LONG ! First row to reformat
-
- ! Locals:
- sTemp STRING(255) ! Temporary line buffer
- ibColndx BYTE ! Column index
- ilIndex LONG ! Loop index
-
- CODE
- LOOP ilIndex = ilRowStart TO RECORDS(tTable) ! Loop for each line
- GET(tTable, ilIndex) ! Get line from edit buffer
-
- IF LEN(CLIP(tTable)) <= MED:ibWrapCol ! If line is short
- IF INSTRING(eHCRCode, tTable, 1) THEN BREAK.! Quit if hard CR found
- GET(tTable, ilIndex+1) ! Get next line
- IF ERRORCODE() THEN BREAK. ! Break if no more lines
- sTemp = tTable ! Save it
- DELETE(tTable) ! Delete from edit buffer
- GET(tTable, ilIndex) ! Get back original line
- IF CLIP(tTable) ! Append next line
- tTable = CLIP(tTable) & ' ' & sTemp !
- ELSE !
- tTable = sTemp !
- . !
- PUT(tTable) ! Save back to edit buffer
- . ! Endif
-
- IF LEN(CLIP(tTable)) > MED:ibWrapCol ! If line is too long
- ibColNdx = Word_Left(tTable, MED:ibWrapCol+1) ! Find breakpoint
- IF ibColNdx = 1 THEN ibColNdx = MED:ibWrapCol.
- Split_Line(tTable, ilIndex, ibColNdx) ! Split line
- . . ! End loop
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Perform Word Wrap
- ! ═════════════════════════════════════════════════════════════════════════
- Word_Wrap FUNCTION( tTable, ilTblNdx, ibCol )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilTblNdx LONG ! Line index
- ibCol BYTE ! Cursor column
-
- ! Locals:
- sTemp STRING(255) ! Temporary line buffer
-
- CODE
- GET(tTable, ilTblNdx) ! Get current line
- ibCol = Word_Left(tTable, ibCol) ! Find start of last word
- IF ibCol = 1 THEN ibCol = MED:ibWrapCol. ! Adjust for unbroken line
- sTemp = SUB(tTable, ibCol, 255) ! Get word to be wrapped
- Split_Line(tTable, ilTblNdx, ibCol) ! Split the line
- RETURN( LEN(CLIP(sTemp))+1 ) ! Return new cursor position
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Split Line at Passed Position
- ! ═════════════════════════════════════════════════════════════════════════
- Split_Line PROCEDURE( tTable, ilTblNdx, ibSplitCol )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilTblNdx LONG ! Line index
- ibSplitCol BYTE ! Split column
-
- ! Locals:
- sTemp STRING(255) ! Temporayr line buffer
-
- CODE
- IF Buffer_Full(tTable) THEN RETURN. ! Check for enough room
-
- GET(tTable, ilTblNdx) ! Get current line
- sTemp = SUB(tTable, ibSplitCol, 255) ! Save text past split col
- tTable = SUB(tTable, 1, ibSplitCol-1) ! Delete portion past split
- PUT(tTable) ! Save back to edit buffer
-
- tTable = LEFT(sTemp) ! Create new line
- ADD(tTable, ilTblNdx+1) ! with saved text
-
- GET(tTable, ilTblNdx) ! Restore current line
- RETURN !
-
-
- ! ═════════════════════════════════════════════════════════════════════════
- ! Join Next Line with Current Line
- ! ═════════════════════════════════════════════════════════════════════════
- Join_Line PROCEDURE( tTable, ilTblNdx )
-
- ! Parameters:
- tTable EXTERNAL,TABLE ! Edit buffer
- ilTblNdx LONG ! Line index
-
- ! Locals:
- sTemp STRING(255) ! Temporary line buffer
-
- CODE
- GET(tTable, ilTblNdx+1) ! Get next line
- IF NOT ERRORCODE() ! If found
- sTemp = tTable ! Save text
- DELETE(tTable) ! Delete from edit buffer
- GET(tTable, ilTblNdx) ! Get current line
- tTable = CLIP(tTable) & ' ' & sTemp ! Join lines
- PUT(tTable) ! Update edit buffer
- . ! Endif
- RETURN !
-
-