home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / alt / sources / 2903 / rn100src.exe / BROWSMSG.PRG < prev    next >
Encoding:
Text File  |  1992-12-16  |  4.7 KB  |  188 lines

  1. #include "marislib.ch"
  2. #include "inkey.ch"
  3. #include "rn.ch"
  4.  
  5.  
  6. FUNCTION BrowseMessages(nTop, nLeft, nBottom, nRight, a, cNewsgroup)
  7.  
  8.    LOCAL b:= TBrowseNew(nTop, nLeft, nBottom, nRight)
  9.    LOCAL i:= 1
  10.    LOCAL nKey
  11.    LOCAL lSavReadexit := readexit(.t.)
  12.    LOCAL bUdf
  13.    LOCAl bColumn
  14.    LOCAl aKill := GetKillInfo( cNewsgroup )
  15.  
  16.    if len(a) < 1
  17.       RETURN (a)
  18.    endif
  19.  
  20.    KeyBar({" = Select", "─┘ = Read", "Space or Tab = Read NEW", "Esc = Exit", "F1 = Help"}, CLR_HDR)
  21.  
  22.    @ 1,0 say space(80) color "w/w"
  23.    saycenter(1, cNewsGroup, "b/w")
  24.  
  25.    b:colorspec := "bg+/b, n/bg, bg+/b, bg+/b, bg+/b, gr+/b, gr+/bg, w/b, w/bg, r+/b, r/bg"
  26.    bColumn := TBColumnNew("", {|| " " + padr(From2Name(a[i,2]),25) + space(3) + padr(a[i,1],50) + " " })
  27.    bColumn:colorBlock := {|x| rowcolor(aKill, a, i) }
  28.  
  29.    b:addColumn( bColumn )
  30.  
  31.    bUdf := {|a, b, nKey, i|UdfBrowseMessages(a, b, nKey, i, cNewsgroup)}
  32.  
  33.    b:goTopBlock := { ||i := 1 }
  34.    b:goBottomBlock := { || i := len(a) }
  35.    b:skipBlock := {|n, si| si := i, ;
  36.                         i := if(n > 0, ;
  37.                            min(len(a), i + n), ;
  38.                            max (1, i+n)), ;
  39.                         i -si }
  40.    b:freeze := 1
  41.  
  42.    do while nKey != K_ESC
  43.       while ! b:stabilize()
  44.       enddo
  45.  
  46.        IF b:hitTop .OR. b:hitBottom
  47.           sound(3500, 10, 80, -25)
  48.        ENDIF
  49.  
  50.        // Make sure that the current record is showing
  51.        // up-to-date data in case we are on a network.
  52.        b:refreshCurrent()
  53.        ForceStable(b)
  54.  
  55.       nKey := inkey(0)
  56.       b := eval(bUdf, a, b, nKey, i)
  57.    enddo
  58.    readexit (lSavReadexit)
  59. RETURN (a)
  60.  
  61.  
  62.  
  63. STATIC FUNCTION UDFBrowseMessages ( a,   ;   // array
  64.                                     b,   ;   // TBrowse object
  65.                                     nKey,;   // key pressed
  66.                                     i,   ;   // current position within array
  67.                                     cNewsgroup;
  68.                                    )
  69.    LOCAL nSavPos, n, nChoice
  70.  
  71.    do case
  72.       case chr(nKey) == "S"
  73.          if (nChoice := ask(" Sort ", " Sort on ", { " ~Subject ", " ~Poster "}, CLR_POP)) > 0
  74.             PushVideo()
  75.             ScrStat("Sorting", "n*/w")
  76.             do case
  77.                case nChoice == 1
  78.                   asort(a,,,{|x, y | ;
  79.                   strtran(lower(trim(x[1])), "re: ") + SortableDate(x[5]) ;
  80.                   < strtran(lower(trim(y[1])), "re: ") + SortableDate(y[5]) })
  81.  
  82.                case nChoice == 2
  83.                   asort(a,,,{|x, y |lower(x[2]) < lower(y[2])})
  84.             endcase
  85.             PopVideo()
  86.             b:refreshall()
  87.             forcestable( b )
  88.             b:gotop()
  89.          endif
  90.  
  91.  
  92.       case chr(nKey) == "p"
  93.          NwsPost( cNewsGroup, a)
  94.          b:refreshall()
  95.          forcestable( b )
  96.  
  97.       case chr(nKey) == '!'
  98.          Shell()
  99.  
  100.       case chr(nKey) == "c"
  101.          Catchup(a)
  102.          b:refreshall()
  103.          forcestable( b )
  104.  
  105.       case nKey == asc("P")
  106.          pmail()
  107.  
  108.       case nKey == K_ALT_S
  109.          KillIt(cNewsgroup, a[i, 1], KILL_OLD )
  110.  
  111.       case nKey == K_ALT_F
  112.          KillIt(cNewsgroup, a[i, 2], KILL_OLD)
  113.  
  114.       case nKey == K_ALT_P
  115.          KillIt(cNewsgroup, a[i, 2], KILL_HI)
  116.  
  117.       case nKey == K_ALT_H
  118.          KillIt(cNewsgroup, a[i, 1], KILL_HI)
  119.  
  120.       case nKey == K_ALT_E
  121.          EditKillFile()
  122.  
  123.       case nKey == K_DOWN .or. chr(nKey) == "+"
  124.          b:down()
  125.  
  126.       case nKey == K_PGDN
  127.          b:pageDown()
  128.  
  129.       case nKey == K_PGUP
  130.          b:pageUp()
  131.  
  132.       case nKey == K_CTRL_PGDN .or. nKey == K_END
  133.          b:goBottom()
  134.  
  135.       case nKey == K_CTRL_PGUP .or. nKey == K_HOME
  136.          b:goTop()
  137.  
  138.       case nKey == K_UP .or. chr(nKey) == "-"
  139.          b:up()
  140.  
  141.       case nKey == K_RETURN
  142.          nSavPos := i
  143.          i := ViewMessage(cNewsgroup, a, i, READ_OLD)
  144.  
  145.          b:Refreshall()
  146.          forcestable( b)
  147.  
  148.          if i # len(a)
  149.             for n := nSavPos to i
  150.                b:down()
  151.             next
  152.          endif
  153.  
  154.       case nKey == K_SPACE .or. nKey == K_TAB
  155.          nSavPos := i
  156.          i := ViewMessage(cNewsgroup, a, i, READ_NEW)
  157.  
  158.          b:Refreshall()
  159.          forcestable( b)
  160.  
  161.          for n := nSavPos to i -1
  162.             b:down()
  163.          next
  164.  
  165.    endcase
  166.  
  167. RETURN (b)
  168.  
  169.  
  170. FUNCTION RowColor (aKill, a, i)
  171.    LOCAL killstat
  172.  
  173.    killstat := GetKill (aKill, a[i,2], a[i,1])
  174.    if IsNew(a[i,4])
  175.       do case
  176.          case killstat == KILL_NEW .or. killstat == KILL_NONE
  177.             RETURN {6,7}
  178.          case killstat == KILL_OLD
  179.             RETURN {8,9}
  180.          case killstat == KILL_HI
  181.             RETURN {10,11}
  182.       endcase
  183.    else
  184.       RETURN {1,2}
  185.    endif
  186.  
  187.  
  188.