antoine-source/appleworksgs/WP/Src/Pars.aii

1 line
37 KiB
Plaintext
Raw Normal View History

2023-03-04 02:45:20 +00:00
***************************************************************************************************** ; WP Paragraph Manipulation Routines ; ; This file contains the routines used to manipulate the paragraph data structure used by WP. The ; paragraph structure is described below: ; ; The paragraph data structure is an array from 1..W_LastP of paragraph info blocks: ; ; W_pBlockHand gequ 0 : handle to the block that the par is in ; W_pOffset gequ 4 : offset into this block that starts the par ; W_pAttr gequ 6 : attribute word for the par ; W_pRulerHand gequ 8 : handle to the ruler that governs this par ; W_pPixels gequ 12 : number of pixels tall this par is ; W_pLineHand gequ 14 : handle to the line struct for this par (Purgeable) ; W_pLastLine gequ 18 : number of last line in the par+1, cr is 0 ; W_pBytes gequ 20 : equate for size of paragraph block. ; ***************************************************************************************************** load 'macros.dump' include 'driver.equ' include 'wp.equ' W_StartMaxP equ 10 W_StartBlockSize equ $1000 W_GrowAmount equ $400 IMPORT D_SetFileChanged IMPORT D_Deref IMPORT D_GrowHandle IMPORT D_GrowLHandle IMPORT D_MainZPage IMPORT D_NeedHand IMPORT W_CurDoc IMPORT W_FindFont IMPORT W_GetLRecPtr IMPORT W_GetLineRec IMPORT W_LastP IMPORT W_MakeLines IMPORT W_MaxP IMPORT W_PHandle IMPORT W_PPtr IMPORT W_RulBits IMPORT W_RulBytes IMPORT W_Selected IMPORT W_StartLine IMPORT W_StartOffset IMPORT StdRuler IMPORT W_StartPar IMPORT W_ValidLines IMPORT W_WPRuler IMPORT W_Stuff ENTRY W_GetAddr ENTRY W_GetLastLGuts ENTRY W_GetParRec ENTRY W_LessRoom ENTRY W_MakeEmptyBlock ENTRY W_MakeNewParRec ENTRY W_MakeRoom ENTRY W_NewRuler ENTRY W_UseRuler ***************************************************************************************************** ; W_InitPars ( ) ; ; This routine is called to setup and empty document. It will create a new paragraph array and a ; single carriage return paragraph. ; ; Note: Memory errors are returned. W_InitPars PROC EXPORT ;Using wpglobals ;Using W_ParData local ptr:l,TextPtr:l,RulerHand:l,TextBlock:l error err begin ; Ask for initial paragraph array handle. If memory error then exit with error. call D_NeedHand,in=(#W_StartMaxP*W_pBytes:l),out=(ax:l),err=err jcs exit ; Lock down paragraph handle and get pointer to first paragraph entry. movelong ax,W_PHandle jsl D_Deref movelong ax,W_PPtr moveword #W_StartMaxP,W_MaxP moveword #1,W_LastP rcall W_GetParRec,in=(#1:a),out=(ptr:ax) ; Get text block for 1st paragraph. call W_MakeEmptyBlock,out=(TextBlock:l),err=err jcs @killpar movelong TextBlock,[ptr] ; Initialize 1st paragraph entry in paragraph array. moveword #W_BHeader,[ptr]:#W_pOffset moveword #0,[ptr]:#W_pAttr movelong #0,[ptr]:#W_pLineHand moveword #1,[ptr]:#W_pLastLine ; Get ruler for 1st paragraph. If memory error then clean up and exit with error. Else use ruler. call W_NewRuler,out=(RulerHand:l),err=err bcs @killtext movelong RulerHand,[Ptr]:#W_pRulerHand call W_UseRuler,in=(#1:w,RulerHand:l) ; Make room for initial text block contents - if error then clean up and exit. call W_MakeRoom,in=(#1:w,#0:w,#W_TextHeader+1:w),err=err bcs @killruler ; Set up contents of 1st paragraph text block - single carriage return. rcall W_GetAddr,in=(#1:a,#0:x),out=(TextPtr:ax) moveword #W_StandFont,[TextPtr] moveword #W_StandStyle,[TextPtr]:#2 moveword #Black,[TextPtr]:#4 movebyte #cr,[TextPtr]:#W_TextHeader ; Create lines for 1st paragraph and initialize globals. If we can't make lines then return memory ; error. call W_MakeLines,in=(#1:w),err=err bcs @killruler stz W_StartLine stz W_Selected moveword #1,W_StartPar moveword #W_TextHeader,W_StartOffset bra exit ; Memory error occurred so clean up allocated memory. @killruler tool _DisposeHandle,in=(RulerHand:l) @killtext tool _DisposeHandle,in=(TextBlock:l) @killpar tool _DisposeHandle,in=(W_PHandle:l) exit return ENDP **************************************