home *** CD-ROM | disk | FTP | other *** search
- #include "marislib.ch"
- #include "inkey.ch"
- #include "rn.ch"
-
-
- FUNCTION BrowseMessages(nTop, nLeft, nBottom, nRight, a, cNewsgroup)
-
- LOCAL b:= TBrowseNew(nTop, nLeft, nBottom, nRight)
- LOCAL i:= 1
- LOCAL nKey
- LOCAL lSavReadexit := readexit(.t.)
- LOCAL bUdf
- LOCAl bColumn
- LOCAl aKill := GetKillInfo( cNewsgroup )
-
- if len(a) < 1
- RETURN (a)
- endif
-
- KeyBar({" = Select", "─┘ = Read", "Space or Tab = Read NEW", "Esc = Exit", "F1 = Help"}, CLR_HDR)
-
- @ 1,0 say space(80) color "w/w"
- saycenter(1, cNewsGroup, "b/w")
-
- b:colorspec := "bg+/b, n/bg, bg+/b, bg+/b, bg+/b, gr+/b, gr+/bg, w/b, w/bg, r+/b, r/bg"
- bColumn := TBColumnNew("", {|| " " + padr(From2Name(a[i,2]),25) + space(3) + padr(a[i,1],50) + " " })
- bColumn:colorBlock := {|x| rowcolor(aKill, a, i) }
-
- b:addColumn( bColumn )
-
- bUdf := {|a, b, nKey, i|UdfBrowseMessages(a, b, nKey, i, cNewsgroup)}
-
- b:goTopBlock := { ||i := 1 }
- b:goBottomBlock := { || i := len(a) }
- b:skipBlock := {|n, si| si := i, ;
- i := if(n > 0, ;
- min(len(a), i + n), ;
- max (1, i+n)), ;
- i -si }
- b:freeze := 1
-
- do while nKey != K_ESC
- while ! b:stabilize()
- enddo
-
- IF b:hitTop .OR. b:hitBottom
- sound(3500, 10, 80, -25)
- ENDIF
-
- // Make sure that the current record is showing
- // up-to-date data in case we are on a network.
- b:refreshCurrent()
- ForceStable(b)
-
- nKey := inkey(0)
- b := eval(bUdf, a, b, nKey, i)
- enddo
- readexit (lSavReadexit)
- RETURN (a)
-
-
-
- STATIC FUNCTION UDFBrowseMessages ( a, ; // array
- b, ; // TBrowse object
- nKey,; // key pressed
- i, ; // current position within array
- cNewsgroup;
- )
- LOCAL nSavPos, n, nChoice
-
- do case
- case chr(nKey) == "S"
- if (nChoice := ask(" Sort ", " Sort on ", { " ~Subject ", " ~Poster "}, CLR_POP)) > 0
- PushVideo()
- ScrStat("Sorting", "n*/w")
- do case
- case nChoice == 1
- asort(a,,,{|x, y | ;
- strtran(lower(trim(x[1])), "re: ") + SortableDate(x[5]) ;
- < strtran(lower(trim(y[1])), "re: ") + SortableDate(y[5]) })
-
- case nChoice == 2
- asort(a,,,{|x, y |lower(x[2]) < lower(y[2])})
- endcase
- PopVideo()
- b:refreshall()
- forcestable( b )
- b:gotop()
- endif
-
-
- case chr(nKey) == "p"
- NwsPost( cNewsGroup, a)
- b:refreshall()
- forcestable( b )
-
- case chr(nKey) == '!'
- Shell()
-
- case chr(nKey) == "c"
- Catchup(a)
- b:refreshall()
- forcestable( b )
-
- case nKey == asc("P")
- pmail()
-
- case nKey == K_ALT_S
- KillIt(cNewsgroup, a[i, 1], KILL_OLD )
-
- case nKey == K_ALT_F
- KillIt(cNewsgroup, a[i, 2], KILL_OLD)
-
- case nKey == K_ALT_P
- KillIt(cNewsgroup, a[i, 2], KILL_HI)
-
- case nKey == K_ALT_H
- KillIt(cNewsgroup, a[i, 1], KILL_HI)
-
- case nKey == K_ALT_E
- EditKillFile()
-
- case nKey == K_DOWN .or. chr(nKey) == "+"
- b:down()
-
- case nKey == K_PGDN
- b:pageDown()
-
- case nKey == K_PGUP
- b:pageUp()
-
- case nKey == K_CTRL_PGDN .or. nKey == K_END
- b:goBottom()
-
- case nKey == K_CTRL_PGUP .or. nKey == K_HOME
- b:goTop()
-
- case nKey == K_UP .or. chr(nKey) == "-"
- b:up()
-
- case nKey == K_RETURN
- nSavPos := i
- i := ViewMessage(cNewsgroup, a, i, READ_OLD)
-
- b:Refreshall()
- forcestable( b)
-
- if i # len(a)
- for n := nSavPos to i
- b:down()
- next
- endif
-
- case nKey == K_SPACE .or. nKey == K_TAB
- nSavPos := i
- i := ViewMessage(cNewsgroup, a, i, READ_NEW)
-
- b:Refreshall()
- forcestable( b)
-
- for n := nSavPos to i -1
- b:down()
- next
-
- endcase
-
- RETURN (b)
-
-
- FUNCTION RowColor (aKill, a, i)
- LOCAL killstat
-
- killstat := GetKill (aKill, a[i,2], a[i,1])
- if IsNew(a[i,4])
- do case
- case killstat == KILL_NEW .or. killstat == KILL_NONE
- RETURN {6,7}
- case killstat == KILL_OLD
- RETURN {8,9}
- case killstat == KILL_HI
- RETURN {10,11}
- endcase
- else
- RETURN {1,2}
- endif
-
-
-