home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 612a.lha / PowerVisor_v1.13 / PowerVisor_v1.13.lzh / Source / SearchHist.asm < prev    next >
Assembly Source File  |  1991-09-24  |  3KB  |  94 lines

  1.     ;Machinelanguage script, search line in history
  2.     ;This ML-script is installed by s:PowerVisor-startup on the
  3.     ;<shift>+<up> key
  4.     ;a2 = pointer to PVCallTable
  5.     ;Version 1.1    Mon Sep 23 15:03:28 1991
  6.  
  7.  
  8.     INCLUDE    "pv:PVDevelop/include/PV/MainBase.i"
  9.     INCLUDE    "pv:PVDevelop/include/PV/PVCallTable.i"
  10.  
  11.  
  12. Search:
  13.         move.l    PVCGetStringGBuf(a2),a0
  14.         jsr        (a0)                        ;Get pointer to stringgadget buffer
  15.         move.l    d0,a3
  16.         move.l    PVCGetStringInfo(a2),a0
  17.         jsr        (a0)                        ;Get pointer to StringInfo of stringgadget
  18.         move.l    d0,a4
  19.         move.l    PVCGetMainBase(a2),a0
  20.         jsr        (a0)                        ;Get pointer to MainBase
  21.         move.l    d0,a5
  22.  
  23.         move.w    8(a4),d5                    ;Position in stringgadget buffer
  24.         move.b    0(a3,d5.w),d7            ;Remember byte
  25.         move.b    #0,0(a3,d5.w)            ;Clear byte
  26.  
  27.     ;Pointer to scanning history line
  28.         move.l    base_ScanHistory(a5),d0
  29.         bne.s        1$
  30.  
  31.     ;No, we are not scanning. Take the pointer to the first history line
  32. 2$        move.l    base_FirstHistLine(a5),d0
  33.     ;If 0, there are no history lines, so we can do nothing at all
  34.         beq.s        3$
  35.         move.l    d0,a6
  36.         bra.s        4$
  37.  
  38.     ;Yes, we are scanning, skip this line and go to the next
  39. 1$        move.l    d0,a6
  40.         move.l    pvhl_Next(a6),d0
  41.     ;If d0 == 0 we are at the end of the history buffer, so we must return
  42.     ;to the first line
  43.         beq.s        2$
  44.         move.l    d0,a6
  45.  
  46.     ;Everything is fine, a6 points to the first history line we must check
  47.     ;We can start searching here
  48. 4$        move.l    a6,d6                        ;Remember first line we have checked
  49. 6$        lea        pvhl_String(a6),a0    ;Pointer to string in history
  50.         move.l    a3,a1                        ;Pointer to stringgadget
  51.         bsr.s        Compare                    ;Compare two strings
  52.         beq.s        5$
  53.     ;Not found, we go to the next history line
  54.         move.l    pvhl_Next(a6),d0
  55.         bne.s        7$
  56.     ;We must go to the first line (wrap)
  57.         move.l    base_FirstHistLine(a5),d0
  58. 7$        move.l    d0,a6
  59.         cmp.l        a6,d6                        ;If a6==d6 we have turned around
  60.         bne.s        6$
  61.  
  62.     ;The end, and we didn't find anything, restore the byte we cleared
  63. 3$        move.b    d7,0(a3,d5.w)
  64.         moveq        #0,d0                        ;Return code failure
  65.         rts
  66.  
  67.     ;Yes ! We have found a matching line !
  68.     ;We must now copy it to the stringgadget buffer and display it
  69.     ;We also set ScanHistory to that line so that we can use
  70.     ;this routine more than one time
  71. 5$        move.l    a6,base_ScanHistory(a5)
  72.         move.l    PVCGetHistoryLine(a2),a0
  73.         jsr        (a0)
  74.         move.l    PVCRefreshStringG(a2),a0
  75.         jsr        (a0)                        ;Refresh stringgadget
  76.  
  77.     ;The end, we did find something
  78.         moveq        #1,d0                        ;Return code success
  79.         rts
  80.  
  81.     ;***
  82.     ;Compare two strings
  83.     ;a0 = string 1
  84.     ;a1 = string 2
  85.     ;-> Z flag true if equal
  86.     ;***
  87. Compare:
  88.         cmp.b        (a0)+,(a1)+
  89.         beq.s        Compare
  90.         tst.b        -1(a1)
  91.         rts
  92.  
  93.     END
  94.