home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Sample Code / Text / SimpleText Sample / TextFile.a < prev    next >
Encoding:
Text File  |  1996-10-17  |  2.6 KB  |  81 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        TextFile.a
  3. ;
  4. ;    Contains:    utility routines for SimpleText
  5. ;
  6. ; Copyright 1995-1996 Apple Computer. All rights reserved.
  7. ;
  8. ;    You may incorporate this sample code into your applications without
  9. ;    restriction, though the sample code has been provided "AS IS" and the
  10. ;    responsibility for its operation is 100% yours.  However, what you are
  11. ;    not permitted to do is to redistribute the source as "DSC Sample Code"
  12. ;    after having made changes. If you're going to re-distribute the source,
  13. ;    we require that you make it clear in the source that the code was
  14. ;    descended from Apple Sample Code, but that you've made changes.
  15.  
  16. ;    AsmClikLoop
  17. ;
  18. ;    This routine gets called by the TextEdit Manager from TEClick.
  19. ;    It calls the old, default click loop routine that scrolls the
  20. ;    text, and then calls our own Pascal routine that handles
  21. ;    tracking the scroll bars to follow along.  It doesn't bother
  22. ;    with saving registers A0 and D0, because they are trashed
  23. ;    anyway by TextEdit.
  24. ;
  25.  
  26. AsmClikLoop    PROC        EXPORT
  27.  
  28.             IMPORT        GETOLDCLICKLOOP
  29.             IMPORT        TEXTCLICKLOOP
  30.             
  31.             MOVEM.L        D1-D2/A1,-(SP)        ; D0 and A0 need not be saved
  32.             CLR.L        -(SP)                ; make space for procedure pointer
  33.             JSR            GETOLDCLICKLOOP        ; get the old clikLoop
  34.             MOVEA.L        (SP)+,A0            ; into A0
  35.             MOVEM.L        (SP)+,D1-D2/A1        ; restore the world as it was
  36.             
  37.             JSR            (A0)                ; and execute old clikLoop
  38.  
  39.             MOVEM.L        D1-D2/A1,-(SP)        ; D0 and A0 need not be saved
  40.             JSR            TEXTCLICKLOOP        ; do our clikLoop
  41.             MOVEM.L        (SP)+,D1-D2/A1        ; restore the world as it was
  42.             MOVEQ        #1,D0                ; clear the zero flag so TextEdit keeps going
  43.             RTS
  44.  
  45. ;-----------------------------------------------------------------
  46. ; Glue routine for TextEdit's DrawHook
  47. ;-----------------------------------------------------------------
  48.  
  49. MyDrawGlue    proc export
  50.     
  51.     import    MyDrawHook:code
  52.     
  53.     ; We must save registers which are used in external C procedure.
  54.     ; Note that MPW C uses a0-a1 and d0-d2 registers without presavation
  55.     ; because these registers need not to be preserved in usual traps.
  56.     ; But in this draw hook routine, all registers should be preserved.
  57.     ; (See IM-6 15-25)
  58.     
  59.     movem.l    a0-a1/d0-d2, -(sp)        ; save registers
  60.     
  61.     move.l    a4, -(sp)                ; push locked TEHandle (1st param)
  62.     move.l    a3, -(sp)                ; push TEPtr
  63.     move.l    a0, -(sp)                ; push pointer to text to draw
  64.     move.w    d1, -(sp)                ; push length of text to draw
  65.     move.w    d0, -(sp)                ; push offset into text (last param)
  66.     
  67.     lea        MyDrawHook, a0            ; get routine pointer
  68.     jsr        (a0)                    ; jump to it
  69.     
  70.     movem.l    (sp)+, a0-a1/d0-d2        ; restore registers
  71.     
  72.     ; We can use rts instruction to return to caller because
  73.     ; this procedure doesn't have any parameters on the stack.
  74.     
  75.     rts                                ; return to caller
  76.     
  77.     endp
  78.     
  79.     END 
  80.  
  81.